Compare commits

...

50 Commits

Author SHA1 Message Date
Alexander M. Turek
78d08584f1 Fix build (#9964) 2022-08-07 17:31:32 +02:00
Adrien Foulon
f7e202f3ed fix: class normalisation test (#9966) 2022-08-07 17:07:36 +02:00
Alexander M. Turek
c8025dc4f8 Update branch info in README and .doctrine-project.json (#9943) 2022-07-31 14:53:31 +02:00
Alexander M. Turek
8bfe20073b Psalm 4.25.0, PHPStan 1.8.2 (#9941) 2022-07-28 19:35:26 +02:00
Vincent Langlet
9b37541b3b Use a more precise phpdoc for ClassMetadataInfo::versionField than mixed (#9937) 2022-07-27 23:23:43 +02:00
Alexander M. Turek
6c64bc6067 Simplify LanguageRecognitionTest (#9930) 2022-07-25 16:14:07 +02:00
Grégoire Paris
f5246bdedd Merge pull request #9927 from rdey/patch-1
GH9335: Fix for bug with objects as foreign keys
2022-07-24 15:21:28 +02:00
Louise Zetterlund
705dc6fbda test/added test for foreign keys with custom id object types 2022-07-22 18:41:35 +02:00
Alexander M. Turek
faedb90ffa Widen types for DiscriminatorMap (#9922)
* Allow integers as keys for DiscriminatorMap

* Widen types for DiscriminatorMap
2022-07-21 10:19:42 +02:00
Grégoire Paris
99d9c46bde Add tests for SQL output feature (#9907)
It is not covered yet, and that makes contributions to these commands
hard.
2022-07-18 21:28:17 +02:00
Grégoire Paris
ab4844b82a Merge pull request #9892 from greg0ire/address-array-object-type-deprecation
Address array object type deprecation
2022-07-10 23:05:34 +02:00
Grégoire Paris
00989d6671 Remove SerializationModel from generic model set
It contains fields with deprecated types.
2022-07-10 12:23:05 +02:00
Grégoire Paris
7ed0db0621 Document what we test in test method name 2022-07-10 11:23:22 +02:00
Grégoire Paris
d6dcfbd6f7 Use ::class notation 2022-07-10 11:23:21 +02:00
Grégoire Paris
baf6a394a1 Test invalid mapping file with boolean model
SerializationModel has a field with type array, and another with type
object. Both types are deprecated.
2022-07-10 11:22:46 +02:00
Alexander M. Turek
291765e879 PHPStan 1.8.0 (#9887) 2022-07-08 13:53:03 +02:00
Grégoire Paris
f79ec43e70 Merge pull request #9880 from CarlSchwan/patch-1
Fix typo in AbstractQuery
2022-07-06 21:07:32 +02:00
Carl Schwan
306b5f9812 Fix typo in AbstractQuery 2022-07-06 14:06:42 +02:00
Grégoire Paris
83c1ad2f57 Merge pull request #9870 from popov-a-e/GH-9807
[GH-9807] Fix: initialize potentially empty collections at the hydration complete
2022-07-03 22:25:18 +02:00
Alex Popov
79447cbb18 ObjectHydrator: defer initialization of potentially empty collections
If ObjectHydrator faces an empty row to an uninitialized collection,
it initializes it, to prevent it from querying again (DDC-1526).
However, if that row is the first but not the only in the collection,
the next rows will be ignored, as the collection will be considered
"existing", and "existing" collections are only replaced if REFRESH hint
is present. To prevent it, we defer initialization to the end of the
hydration.

Fixes GH-9807
2022-07-03 13:25:34 +04:00
Grégoire Paris
3295ccfa25 Merge pull request #9874 from greg0ire/migrate-to-csfm
Migrate more usages of SchemaTool::createSchema()
2022-07-02 00:11:41 +02:00
Grégoire Paris
b1419ddc6c Migrate more usages of SchemaTool::createSchema()
When I introduced OrmFunctionalTestCase::createSchemaForModels(), I made
several wrong assumptions:
- the call is always wrapped in a try / catch;
- that try / catch is always typed with "Exception".

Because of that, I missed, many, many occurrences of
SchemaTool::createSchema().

I recently noticed that contributors kept using the
SchemaTool::createSchema() and figured not everything had been
migrated.

Migrating some of them did not result in something far better until I
also introduced similar methods for
SchemaTool::getUpdateSchemaSql() and SchemaTool::getSchemaFromMetadata().
2022-07-01 21:45:45 +02:00
Thomas Landauer
0ef08c5dfb preUpdate: Add restriction that changed field needs to be in computed changeset (#9871) 2022-06-28 23:44:23 +02:00
Alexander M. Turek
278bf194ca Psalm 4.24.0, PHPStan 1.7.15 (#9865) 2022-06-28 10:41:20 +02:00
Alexander M. Turek
b9f2488c6c PHP CodeSniffer 3.7.1, PHPStan 1.7.14 (#9858) 2022-06-19 14:48:36 +02:00
Alexander M. Turek
c05e1709e9 Run tests on PHP 8.2 (#9840) 2022-06-16 15:42:23 +02:00
Alexander M. Turek
6e31758c7b PHPStan 1.7.13 (#9844) 2022-06-15 11:11:24 +02:00
Alexander M. Turek
eff540a996 Flip conditional extension of legacy AnnotationDriver class (#9843) 2022-06-13 20:10:37 +02:00
Alexander M. Turek
33d74e2e48 PHP CodeSniffer 3.7 (#9842) 2022-06-13 19:19:15 +02:00
bartholdbos
09ff36cda0 Make Reflection available to ConvertMappingCommand (#9619) 2022-06-13 17:30:08 +02:00
Grégoire Paris
e30426cbc0 Merge pull request #9841 from derrabus/bugfix/dynamic-property
Add missing property declaration
2022-06-12 16:55:59 +02:00
Alexander M. Turek
e9135b86e0 Add missing property declaration 2022-06-12 14:25:39 +02:00
Grégoire Paris
3dc5581294 Merge pull request #9818 from greg0ire/fix-wrong-type-config
Document missing possible types
2022-06-09 07:23:43 +02:00
Grégoire Paris
7bf2c4c8d1 Merge pull request #9823 from greg0ire/fix-build 2022-06-08 14:39:31 +02:00
Grégoire Paris
c81776ad12 Backport fixes from upstream branch
Not all of 01fb82b497 was ported, only
what is necessary to fix the build.
2022-06-08 13:26:35 +02:00
Grégoire Paris
d9c6f86627 Document missing possible types 2022-06-04 18:16:35 +02:00
Alexander M. Turek
67d82cdf72 PHPStan 1.7.9 (#9812) 2022-06-03 13:11:19 +02:00
Alexander M. Turek
744f0b5983 Remove empty test file (#9805) 2022-06-03 07:53:13 +02:00
wiseguy1394
768e2f3816 Add primary key on temp table (#9770)
* add primary key on temp table;fixes doctrine/orm#9768

* use all ID Columns in primary key
2022-06-02 16:08:22 +02:00
Grégoire Paris
21976471a3 Fix wrong types (#9802) 2022-06-01 22:42:51 +02:00
olegsuvorkov
aae8b43622 Update IdentifierFlattener.php
Fix for coding-standards / Coding Standards (8.1)
2022-05-27 15:35:23 +03:00
olegsuvorkov
3f4e9e397a Update IdentifierFlattener.php
Hello, I would like to make a small change.
The need arose when using \Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator in "symfony/doctrine-bridge" composite foreign keys
I'm sure these changes will not hurt performance
and allow other objects to be used as identifiers
2022-05-26 10:46:14 +03:00
Alexander M. Turek
48e4e333c7 PHPStan 1.7.0 (#9785) 2022-05-24 00:41:57 +02:00
Grégoire Paris
1f63389065 Fix wrong types for AbstractQuery and child classes (#9774)
* Remove comment about BC

I do not think we actually want to force our users to build an array
collection when they want to use setParameters().

* Make phpdoc more accurate
2022-05-23 11:26:19 +02:00
Grégoire Paris
359dd4ecfb Merge pull request #9779 from greg0ire/fix-config-phpdoc 2022-05-23 11:18:58 +02:00
Grégoire Paris
a0697c9aff Document callable as possible
Custom string functions can either be a class string or a callable
returning the function.
2022-05-23 11:05:16 +02:00
Grégoire Paris
8f7701279d Add use statement (#9769)
We are supposed to use the driver from doctrine/persistence, and not the
deprecated one from this package.
2022-05-19 13:16:51 +02:00
Grégoire Paris
45e196eb57 Omit version number in README (#9749) 2022-05-10 09:09:20 +02:00
Grégoire Paris
eed20ff4dd Better phpdoc tests (#9746)
* Fix inaccurate and imprecise phpdoc

* Remove extra argument

The method signature does not specify it, and it's always set to null.
It looks like this test and its data provider were copy/pasted from the
previous one.

* Specify what concrete class is passed

This is important as the signature of the concrete classes don't
necessarily match the one of the interface. Here, an extra argument that
is only defined in the classes is used.
2022-05-10 00:32:30 +02:00
Alexander M. Turek
07ee555279 Exclude /ci from distribution packages (#9732) 2022-05-06 13:07:36 +02:00
185 changed files with 1225 additions and 1361 deletions

View File

@@ -12,21 +12,27 @@
"upcoming": true
},
{
"name": "2.12",
"branchName": "2.12.x",
"slug": "2.12",
"name": "2.13",
"branchName": "2.13.x",
"slug": "2.13",
"upcoming": true
},
{
"name": "2.11",
"branchName": "2.11.x",
"slug": "2.11",
"name": "2.12",
"branchName": "2.12.x",
"slug": "2.12",
"current": true,
"aliases": [
"current",
"stable"
]
},
{
"name": "2.11",
"branchName": "2.11.x",
"slug": "2.11",
"maintained": false
},
{
"name": "2.10",
"branchName": "2.10.x",

5
.gitattributes vendored
View File

@@ -1,7 +1,8 @@
/.github export-ignore
/ci export-ignore
/docs export-ignore
/tests export-ignore
/tools export-ignore
/docs export-ignore
/.github export-ignore
.doctrine-project.json export-ignore
.gitattributes export-ignore
.gitignore export-ignore

View File

@@ -31,6 +31,8 @@ jobs:
dbal-version: "2.13"
- php-version: "8.1"
dbal-version: "3@dev"
- php-version: "8.2"
dbal-version: "3@dev"
steps:
- name: "Checkout"
@@ -52,6 +54,8 @@ jobs:
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
composer-options: "--ignore-platform-req=php+"
- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --coverage-clover=coverage-no-cache.xml"
@@ -88,6 +92,9 @@ jobs:
- php-version: "8.0"
dbal-version: "2.13"
postgres-version: "14"
- php-version: "8.2"
dbal-version: "3@dev"
postgres-version: "14"
services:
postgres:
@@ -120,6 +127,8 @@ jobs:
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
composer-options: "--ignore-platform-req=php+"
- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_pgsql.xml --coverage-clover=coverage.xml"
@@ -152,6 +161,14 @@ jobs:
dbal-version: "2.13"
mariadb-version: "10.6"
extension: "pdo_mysql"
- php-version: "8.2"
dbal-version: "3@dev"
mariadb-version: "10.6"
extension: "pdo_mysql"
- php-version: "8.2"
dbal-version: "3@dev"
mariadb-version: "10.6"
extension: "mysqli"
services:
mariadb:
@@ -186,6 +203,8 @@ jobs:
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
composer-options: "--ignore-platform-req=php+"
- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"
@@ -219,6 +238,14 @@ jobs:
dbal-version: "2.13"
mysql-version: "8.0"
extension: "pdo_mysql"
- php-version: "8.2"
dbal-version: "3@dev"
mysql-version: "8.0"
extension: "mysqli"
- php-version: "8.2"
dbal-version: "3@dev"
mysql-version: "8.0"
extension: "pdo_mysql"
services:
mysql:
@@ -252,6 +279,8 @@ jobs:
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
composer-options: "--ignore-platform-req=php+"
- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage-no-cache.xml"

View File

@@ -1,11 +1,11 @@
| [3.0.x][3.0] | [2.12.x][2.12] | [2.11.x][2.11] |
| [3.0.x][3.0] | [2.13.x][2.13] | [2.12.x][2.12] |
|:----------------:|:----------------:|:----------:|
| [![Build status][3.0 image]][3.0] | [![Build status][2.12 image]][2.12] | [![Build status][2.11 image]][2.11] |
| [![Coverage Status][3.0 coverage image]][3.0 coverage]| [![Coverage Status][2.12 coverage image]][2.12 coverage] | [![Coverage Status][2.11 coverage image]][2.11 coverage] |
| [![Build status][3.0 image]][3.0] | [![Build status][2.13 image]][2.13] | [![Build status][2.12 image]][2.12] |
| [![Coverage Status][3.0 coverage image]][3.0 coverage]| [![Coverage Status][2.13 coverage image]][2.13 coverage] | [![Coverage Status][2.12 coverage image]][2.12 coverage] |
[<h1 align="center">🇺🇦 UKRAINE NEEDS YOUR HELP NOW!</h1>](https://www.doctrine-project.org/stop-war.html)
Doctrine 2 is an object-relational mapper (ORM) for PHP 7.1+ that provides transparent persistence
Doctrine ORM is an object-relational mapper for PHP 7.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
@@ -22,11 +22,11 @@ without requiring unnecessary code duplication.
[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.13 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.13.x
[2.13]: https://github.com/doctrine/orm/tree/2.13.x
[2.13 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.13.x/graph/badge.svg
[2.13 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.13.x
[2.12 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.12.x
[2.12]: https://github.com/doctrine/orm/tree/2.12.x
[2.12 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.12.x/graph/badge.svg
[2.12 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.12.x
[2.11 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.11.x
[2.11]: https://github.com/doctrine/orm/tree/2.11.x
[2.11 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.11.x/graph/badge.svg
[2.11 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.11.x

View File

@@ -42,13 +42,13 @@
"doctrine/annotations": "^1.13",
"doctrine/coding-standard": "^9.0",
"phpbench/phpbench": "^0.16.10 || ^1.0",
"phpstan/phpstan": "~1.4.10 || 1.6.3",
"phpstan/phpstan": "~1.4.10 || 1.8.2",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.6.2",
"squizlabs/php_codesniffer": "3.7.1",
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"vimeo/psalm": "4.23.0"
"vimeo/psalm": "4.26.0"
},
"conflict": {
"doctrine/annotations": "<1.13 || >= 2.0"

View File

@@ -644,6 +644,9 @@ A simple example for this event looks like:
if ($eventArgs->getEntity() instanceof User) {
if ($eventArgs->hasChangedField('name') && $eventArgs->getNewValue('name') == 'Alice') {
$eventArgs->setNewValue('name', 'Bob');
// The following will only work if `status` is already present in the computed changeset.
// Otherwise it will throw an InvalidArgumentException:
$eventArgs->setNewValue('status', 'active');
}
}
}

View File

@@ -96,6 +96,8 @@ For this you just need to use the ``StaticPHPDriver``:
.. code-block:: php
<?php
use Doctrine\Persistence\Mapping\Driver\StaticPHPDriver;
$driver = new StaticPHPDriver('/path/to/entities');
$em->getConfiguration()->setMetadataDriverImpl($driver);

View File

@@ -36,6 +36,7 @@ use function is_array;
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;
@@ -196,7 +197,7 @@ abstract class AbstractQuery
}
/**
* @return bool TRUE if the query results are enable for second level cache, FALSE otherwise.
* @return bool TRUE if the query results are enabled for second level cache, FALSE otherwise.
*/
public function isCacheable()
{
@@ -282,7 +283,7 @@ abstract class AbstractQuery
* The returned SQL syntax depends on the connection driver that is used
* by this query object at the time of this method call.
*
* @return string SQL query
* @return list<string>|string SQL query
*/
abstract public function getSQL();
@@ -353,7 +354,6 @@ abstract class AbstractQuery
*/
public function setParameters($parameters)
{
// BC compatibility with 2.3-
if (is_array($parameters)) {
/** @psalm-var ArrayCollection<int, Parameter> $parameterCollection */
$parameterCollection = new ArrayCollection();
@@ -401,8 +401,8 @@ abstract class AbstractQuery
*
* @param mixed $value
*
* @return mixed[]|string|int|float|bool
* @psalm-return array|scalar
* @return mixed[]|string|int|float|bool|object|null
* @psalm-return array|scalar|object|null
*
* @throws ORMInvalidArgumentException
*/
@@ -1302,7 +1302,8 @@ abstract class AbstractQuery
$parameters[$parameter->getName()] = $this->processParameterValue($parameter->getValue());
}
$sql = $this->getSQL();
$sql = $this->getSQL();
assert(is_string($sql));
$queryCacheProfile = $this->getHydrationCacheProfile();
$hints = $this->getHints();
$hints['hydrationMode'] = $this->getHydrationMode();
@@ -1374,7 +1375,8 @@ abstract class AbstractQuery
*/
protected function getHash()
{
$query = $this->getSQL();
$query = $this->getSQL();
assert(is_string($query));
$hints = $this->getHints();
$params = array_map(function (Parameter $parameter) {
$value = $parameter->getValue();

View File

@@ -12,6 +12,7 @@ use Doctrine\ORM\UnitOfWork;
use Doctrine\ORM\Utility\IdentifierFlattener;
use function array_merge;
use function assert;
use function is_array;
use function is_object;
use function reset;
@@ -57,6 +58,7 @@ class DefaultEntityHydrator implements EntityHydrator
if ($metadata->requiresFetchAfterChange) {
if ($metadata->isVersioned) {
assert($metadata->versionField !== null);
$data[$metadata->versionField] = $metadata->getFieldValue($entity, $metadata->versionField);
}

View File

@@ -607,8 +607,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
*
* @param string $name
*
* @return string|null
* @psalm-return ?class-string
* @return string|callable|null
* @psalm-return class-string|callable|null
*/
public function getCustomStringFunction($name)
{
@@ -625,8 +625,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
*
* Any previously added string functions are discarded.
*
* @psalm-param array<string, class-string> $functions The map of custom
* DQL string functions.
* @psalm-param array<string, class-string|callable> $functions The map of custom DQL string functions.
*
* @return void
*/
@@ -659,8 +658,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
*
* @param string $name
*
* @return string|null
* @psalm-return ?class-string
* @return string|callable|null
* @psalm-return class-string|callable|null
*/
public function getCustomNumericFunction($name)
{
@@ -712,8 +711,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
*
* @param string $name
*
* @return string|null
* @psalm-return ?class-string $name
* @return string|callable|null
* @psalm-return class-string|callable|null $name
*/
public function getCustomDatetimeFunction($name)
{

View File

@@ -83,9 +83,8 @@ class HydrationException extends ORMException
}
/**
* @param string $discrValue
* @param string[] $discrValues
* @psalm-param list<string> $discrValues
* @param string $discrValue
* @param list<int|string> $discrValues
*
* @return HydrationException
*/

View File

@@ -44,6 +44,9 @@ class ObjectHydrator extends AbstractHydrator
/** @var mixed[] */
private $initializedCollections = [];
/** @var array<string, PersistentCollection> */
private $uninitializedCollections = [];
/** @var mixed[] */
private $existingCollections = [];
@@ -112,10 +115,11 @@ class ObjectHydrator extends AbstractHydrator
parent::cleanup();
$this->identifierMap =
$this->initializedCollections =
$this->existingCollections =
$this->resultPointers = [];
$this->identifierMap =
$this->initializedCollections =
$this->uninitializedCollections =
$this->existingCollections =
$this->resultPointers = [];
if ($eagerLoad) {
$this->_uow->triggerEagerLoads();
@@ -126,10 +130,11 @@ class ObjectHydrator extends AbstractHydrator
protected function cleanupAfterRowIteration(): void
{
$this->identifierMap =
$this->initializedCollections =
$this->existingCollections =
$this->resultPointers = [];
$this->identifierMap =
$this->initializedCollections =
$this->uninitializedCollections =
$this->existingCollections =
$this->resultPointers = [];
}
/**
@@ -148,6 +153,12 @@ class ObjectHydrator extends AbstractHydrator
$coll->takeSnapshot();
}
foreach ($this->uninitializedCollections as $coll) {
if (! $coll->isInitialized()) {
$coll->setInitialized(true);
}
}
return $result;
}
@@ -411,8 +422,8 @@ class ObjectHydrator extends AbstractHydrator
}
} elseif (! $reflFieldValue) {
$this->initRelatedCollection($parentObject, $parentClass, $relationField, $parentAlias);
} elseif ($reflFieldValue instanceof PersistentCollection && $reflFieldValue->isInitialized() === false) {
$reflFieldValue->setInitialized(true);
} elseif ($reflFieldValue instanceof PersistentCollection && $reflFieldValue->isInitialized() === false && ! isset($this->uninitializedCollections[$oid . $relationField])) {
$this->uninitializedCollections[$oid . $relationField] = $reflFieldValue;
}
} else {
// PATH B: Single-valued association

View File

@@ -519,9 +519,9 @@ class ClassMetadataInfo implements ClassMetadata
*
* @see discriminatorColumn
*
* @var array<string, string>
* @var array<int|string, string>
*
* @psalm-var array<string, class-string>
* @psalm-var array<int|string, class-string>
*/
public $discriminatorMap = [];
@@ -713,7 +713,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any).
*
* @var mixed
* @var string|null
*/
public $versionField;
@@ -3219,7 +3219,7 @@ class ClassMetadataInfo implements ClassMetadata
* Sets the discriminator values used by this class.
* Used for JOINED and SINGLE_TABLE inheritance mapping strategies.
*
* @psalm-param array<string, class-string> $map
* @param array<int|string, string> $map
*
* @return void
*/
@@ -3233,9 +3233,8 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Adds one entry of the discriminator map with a new class and corresponding name.
*
* @param string $name
* @param string $className
* @psalm-param class-string $className
* @param int|string $name
* @param string $className
*
* @return void
*
@@ -3519,7 +3518,7 @@ class ClassMetadataInfo implements ClassMetadata
* Sets the name of the field that is to be used for versioning if this class is
* versioned for optimistic locking.
*
* @param string $versionField
* @param string|null $versionField
*
* @return void
*/
@@ -3709,7 +3708,6 @@ class ClassMetadataInfo implements ClassMetadata
/**
* @param string|null $className
* @psalm-param string|class-string|null $className
*
* @return string|null null if the input value is null
* @psalm-return class-string|null

View File

@@ -15,15 +15,11 @@ use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
#[Attribute(Attribute::TARGET_CLASS)]
final class DiscriminatorMap implements Annotation
{
/**
* @var array<string, string>
* @psalm-var array<string, class-string>
*/
/** @var array<int|string, string> */
public $value;
/**
* @param array<string, string> $value
* @psalm-param array<string, class-string> $value
* @param array<int|string, string> $value
*/
public function __construct(array $value)
{

View File

@@ -108,7 +108,10 @@ class AttributeDriver extends CompatibilityAnnotationDriver
*/
public function loadMetadataForClass($className, PersistenceClassMetadata $metadata): void
{
$reflectionClass = $metadata->getReflectionClass();
$reflectionClass = $metadata->getReflectionClass()
// this happens when running annotation driver in combination with
// static reflection services. This is not the nicest fix
?? new ReflectionClass($metadata->name);
$classAttributes = $this->reader->getClassAnnotations($reflectionClass);

View File

@@ -9,18 +9,18 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use function class_exists;
if (class_exists(PersistenceAnnotationDriver::class)) {
/**
* @internal This class will be removed in ORM 3.0.
*/
abstract class CompatibilityAnnotationDriver extends PersistenceAnnotationDriver
{
}
} else {
if (! class_exists(PersistenceAnnotationDriver::class)) {
/**
* @internal This class will be removed in ORM 3.0.
*/
abstract class CompatibilityAnnotationDriver implements MappingDriver
{
}
} else {
/**
* @internal This class will be removed in ORM 3.0.
*/
abstract class CompatibilityAnnotationDriver extends PersistenceAnnotationDriver
{
}
}

View File

@@ -34,11 +34,9 @@ final class NativeQuery extends AbstractQuery
/**
* Gets the SQL query.
*
* @return mixed The built SQL query or an array of all SQL queries.
*
* @override
*/
public function getSQL()
public function getSQL(): string
{
return $this->sql;
}

View File

@@ -14,7 +14,9 @@ use Doctrine\ORM\Utility\PersisterHelper;
use function array_merge;
use function array_reverse;
use function array_values;
use function assert;
use function implode;
use function is_string;
/**
* Persister for one-to-many collections.
@@ -225,7 +227,9 @@ class OneToManyPersister extends AbstractCollectionPersister
. ' FROM ' . $targetClass->name . ' t0 WHERE t0.' . $mapping['mappedBy'] . ' = :owner'
)->setParameter('owner', $collection->getOwner());
$statement = 'INSERT INTO ' . $tempTable . ' (' . $idColumnList . ') ' . $query->getSQL();
$sql = $query->getSQL();
assert(is_string($sql));
$statement = 'INSERT INTO ' . $tempTable . ' (' . $idColumnList . ') ' . $sql;
$parameters = array_values($sourceClass->getIdentifierValues($collection->getOwner()));
$numDeleted = $this->conn->executeStatement($statement, $parameters);

View File

@@ -494,7 +494,8 @@ class BasicEntityPersister implements EntityPersister
}
if ($versioned) {
$versionField = $this->class->versionField;
$versionField = $this->class->versionField;
assert($versionField !== null);
$versionFieldType = $this->class->fieldMappings[$versionField]['type'];
$versionColumn = $this->quoteStrategy->getColumnName($versionField, $this->class, $this->platform);

View File

@@ -174,7 +174,7 @@ final class Query extends AbstractQuery
/**
* The query cache lifetime.
*
* @var int
* @var int|null
*/
private $queryCacheTTL;
@@ -188,7 +188,7 @@ final class Query extends AbstractQuery
/**
* Gets the SQL query/queries that correspond to this DQL query.
*
* @return mixed The built sql query or an array of all sql queries.
* @return list<string>|string The built sql query or an array of all sql queries.
*
* @override
*/
@@ -537,7 +537,7 @@ final class Query extends AbstractQuery
/**
* Defines how long the query cache will be active before expire.
*
* @param int $timeToLive How long the cache entry is valid.
* @param int|null $timeToLive How long the cache entry is valid.
*
* @return $this
*/
@@ -596,7 +596,7 @@ final class Query extends AbstractQuery
/**
* Sets a DQL query string.
*
* @param string $dqlQuery DQL Query.
* @param string|null $dqlQuery DQL Query.
*/
public function setDQL($dqlQuery): self
{

View File

@@ -18,7 +18,7 @@ use Doctrine\DBAL\Types\Type;
*/
abstract class AbstractSqlExecutor
{
/** @var mixed[]|string */
/** @var list<string>|string */
protected $_sqlStatements;
/** @var QueryCacheProfile */

View File

@@ -98,7 +98,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
}
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ', PRIMARY KEY(' . implode(',', $idColumnNames) . '))';
$this->_dropTempTableSql = $platform->getDropTemporaryTableSQL($tempTable);
}

View File

@@ -139,7 +139,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
}
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ', PRIMARY KEY(' . implode(',', $idColumnNames) . '))';
$this->_dropTempTableSql = $platform->getDropTemporaryTableSQL($tempTable);
}

View File

@@ -82,7 +82,7 @@ class XmlExporter extends AbstractExporter
foreach ($metadata->discriminatorMap as $value => $className) {
$discriminatorMappingXml = $discriminatorMapXml->addChild('discriminator-mapping');
$discriminatorMappingXml->addAttribute('value', $value);
$discriminatorMappingXml->addAttribute('value', (string) $value);
$discriminatorMappingXml->addAttribute('class', $className);
}
}

View File

@@ -54,6 +54,7 @@ use function array_merge;
use function array_pop;
use function array_sum;
use function array_values;
use function assert;
use function count;
use function current;
use function get_class;
@@ -1612,6 +1613,8 @@ class UnitOfWork implements PropertyChangedListener
case $class->isIdentifierNatural():
// Check for a version field, if available, to avoid a db lookup.
if ($class->isVersioned) {
assert($class->versionField !== null);
return $class->getFieldValue($entity, $class->versionField)
? self::STATE_DETACHED
: self::STATE_NEW;
@@ -2061,6 +2064,7 @@ class UnitOfWork implements PropertyChangedListener
return;
}
assert($class->versionField !== null);
$reflField = $class->reflFields[$class->versionField];
$managedCopyVersion = $reflField->getValue($managedCopy);
$entityVersion = $reflField->getValue($entity);
@@ -2495,6 +2499,7 @@ class UnitOfWork implements PropertyChangedListener
$entity->__load();
}
assert($class->versionField !== null);
$entityVersion = $class->reflFields[$class->versionField]->getValue($entity);
// phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator

View File

@@ -11,7 +11,7 @@ use Doctrine\Persistence\Mapping\ClassMetadataFactory;
use function assert;
use function implode;
use function is_object;
use function is_a;
/**
* The IdentifierFlattener utility now houses some of the identifier manipulation logic from unit of work, so that it
@@ -55,7 +55,7 @@ final class IdentifierFlattener
$flatId = [];
foreach ($class->identifier as $field) {
if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_object($id[$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']
);

View File

@@ -266,21 +266,4 @@
<!-- https://github.com/doctrine/orm/issues/8537 -->
<exclude-pattern>lib/Doctrine/ORM/QueryBuilder.php</exclude-pattern>
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent.Incorrect">
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/3474 -->
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/AccessLevel.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/City.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/Suit.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/Unit.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/UserStatus.php</exclude-pattern>
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent.IncorrectExact">
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/3474 -->
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/AccessLevel.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/City.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/Suit.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/Unit.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/UserStatus.php</exclude-pattern>
</rule>
</ruleset>

View File

@@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Method Doctrine\\\\ORM\\\\AbstractQuery\\:\\:processParameterValue\\(\\) should return array\\|bool\\|float\\|int\\|string but returns mixed\\.$#"
count: 1
path: lib/Doctrine/ORM/AbstractQuery.php
-
message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\EntityPersister\\:\\:getCacheRegion\\(\\)\\.$#"
count: 1
@@ -225,6 +220,11 @@ parameters:
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/AttributeDriver.php
-
message: "#^Empty array passed to foreach\\.$#"
count: 1
@@ -326,37 +326,37 @@ parameters:
path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php
-
message: "#^Parameter \\#2 \\$days of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddDaysExpression\\(\\) expects int, string given\\.$#"
message: "#^Parameter \\#2 \\$days of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddDaysExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$hours of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddHourExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$minutes of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddMinutesExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$months of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddMonthExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$seconds of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddSecondsExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$weeks of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddWeeksExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$years of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddYearsExpression\\(\\) expects int\\|numeric\\-string, string given\\.$#"
count: 1
path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php
@@ -366,37 +366,37 @@ parameters:
path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php
-
message: "#^Parameter \\#2 \\$days of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubDaysExpression\\(\\) expects int, string given\\.$#"
message: "#^Parameter \\#2 \\$days of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubDaysExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$hours of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubHourExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$minutes of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubMinutesExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$months of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubMonthExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$seconds of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubSecondsExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$weeks of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubWeeksExpression\\(\\) expects int\\|numeric\\-string, 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\\.$#"
message: "#^Parameter \\#2 \\$years of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubYearsExpression\\(\\) expects int\\|numeric\\-string, string given\\.$#"
count: 1
path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php
@@ -475,11 +475,6 @@ parameters:
count: 1
path: lib/Doctrine/ORM/Query/Expr/Select.php
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 3
path: lib/Doctrine/ORM/Query/Parser.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

View File

@@ -3,6 +3,8 @@ includes:
- phpstan-params.neon
parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
# https://github.com/doctrine/collections/pull/282
- '/Variable \$offset in isset\(\) always exists and is not nullable\./'
@@ -11,7 +13,7 @@ parameters:
# Class name will change in DBAL 3.
- '/^Class Doctrine\\DBAL\\Platforms\\PostgreSQLPlatform not found\.$/'
# Forward compatibility for DBAL 3.2
# Forward compatibility for DBAL 3.4
- '/^Call to an undefined method Doctrine\\DBAL\\Cache\\QueryCacheProfile::[gs]etResultCache\(\)\.$/'
-
message: '/^Call to an undefined static method Doctrine\\DBAL\\Configuration::[gs]etResultCache\(\)\.$/'
@@ -19,6 +21,12 @@ parameters:
-
message: '/^Parameter #3 \$resultCache of class Doctrine\\DBAL\\Cache\\QueryCacheProfile constructor/'
path: lib/Doctrine/ORM/AbstractQuery.php
-
message: '/^Parameter #2 \$\w+ of method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getDateAdd\w+Expression\(\) expects int, string given\.$/'
path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php
-
message: '/^Parameter #2 \$\w+ of method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getDateSub\w+Expression\(\) expects int, string given\.$/'
path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php
# False positive
-
@@ -55,3 +63,8 @@ parameters:
-
message: '#^Call to method injectObjectManager\(\) on an unknown class Doctrine\\Persistence\\ObjectManagerAware\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php
# https://github.com/phpstan/phpstan/issues/7292
-
message: '#^Offset class\-string on array\<class\-string, array\<string, mixed\>\> in isset\(\) always exists and is not nullable\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php

View File

@@ -15,7 +15,8 @@ parameters:
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\.$/'
- '/^Class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform not found\.$/'
- '/^Call to method \w+\(\) on an unknown class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform\.$/'
-
message: '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getSQLResultCasing\(\)\.$/'
@@ -42,13 +43,7 @@ parameters:
# Symfony cache supports passing a key prefix to the clear method.
- '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/'
# Compatibility layer for AttributeDriver
# https://github.com/phpstan/phpstan/issues/7292
-
message: "#^PHPDoc type Doctrine\\\\ORM\\\\Mapping\\\\Driver\\\\AttributeReader of property Doctrine\\\\ORM\\\\Mapping\\\\Driver\\\\AttributeDriver\\:\\:\\$reader is not covariant with PHPDoc type Doctrine\\\\Common\\\\Annotations\\\\Reader of overridden property Doctrine\\\\Persistence\\\\Mapping\\\\Driver\\\\AnnotationDriver\\:\\:\\$reader\\.$#"
path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
-
message: "#^PHPDoc type array\\<string, int\\> of property Doctrine\\\\ORM\\\\Mapping\\\\Driver\\\\AttributeDriver\\:\\:\\$entityAnnotationClasses is not covariant with PHPDoc type array\\<class\\-string, bool\\|int\\> of overridden property Doctrine\\\\Persistence\\\\Mapping\\\\Driver\\\\AnnotationDriver\\:\\:\\$entityAnnotationClasses\\.$#"
path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
-
message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\Driver\\\\AttributeReader\\) of method Doctrine\\\\ORM\\\\Mapping\\\\Driver\\\\AttributeDriver\\:\\:getReader\\(\\) should be compatible with return type \\(Doctrine\\\\Common\\\\Annotations\\\\Reader\\) of method Doctrine\\\\Persistence\\\\Mapping\\\\Driver\\\\AnnotationDriver\\:\\:getReader\\(\\)$#"
path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
message: '#^Offset class\-string on array\<class\-string, array\<string, mixed\>\> in isset\(\) always exists and is not nullable\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php

View File

@@ -15,7 +15,8 @@ parameters:
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\.$/'
- '/^Class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform not found\.$/'
- '/^Call to method \w+\(\) on an unknown class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform\.$/'
-
message: '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getSQLResultCasing\(\)\.$/'
@@ -52,3 +53,8 @@ parameters:
-
message: '#^Call to method injectObjectManager\(\) on an unknown class Doctrine\\Persistence\\ObjectManagerAware\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php
# https://github.com/phpstan/phpstan/issues/7292
-
message: '#^Offset class\-string on array\<class\-string, array\<string, mixed\>\> in isset\(\) always exists and is not nullable\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
<files psalm-version="4.26.0@6998fabb2bf528b65777bf9941920888d23c03ac">
<file src="lib/Doctrine/ORM/AbstractQuery.php">
<DeprecatedClass occurrences="1">
<code>IterableResult</code>
@@ -264,13 +264,10 @@
</TooManyArguments>
</file>
<file src="lib/Doctrine/ORM/EntityManager.php">
<ArgumentTypeCoercion occurrences="6">
<ArgumentTypeCoercion occurrences="3">
<code>$className</code>
<code>$connection</code>
<code>$entityName</code>
<code>ltrim($className, '\\')</code>
<code>ltrim($entityName, '\\')</code>
<code>ltrim($entityName, '\\')</code>
</ArgumentTypeCoercion>
<DeprecatedMethod occurrences="2">
<code>getMetadataCacheImpl</code>
@@ -459,8 +456,7 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php">
<ArgumentTypeCoercion occurrences="2">
<code>$class</code>
<ArgumentTypeCoercion occurrences="1">
<code>$repositoryClassName</code>
</ArgumentTypeCoercion>
<DeprecatedMethod occurrences="1">
@@ -517,6 +513,9 @@
<InvalidArrayOffset occurrences="1">
<code>$subClass-&gt;table[$indexType][$indexName]</code>
</InvalidArrayOffset>
<InvalidPropertyAssignmentValue occurrences="1">
<code>$subClass-&gt;table</code>
</InvalidPropertyAssignmentValue>
<MissingConstructor occurrences="2">
<code>$driver</code>
<code>$evm</code>
@@ -524,9 +523,6 @@
<PossiblyInvalidArrayAssignment occurrences="1">
<code>$subClass-&gt;table[$indexType][$indexName]</code>
</PossiblyInvalidArrayAssignment>
<InvalidPropertyAssignmentValue occurrences="1">
<code>$subClass-&gt;table</code>
</InvalidPropertyAssignmentValue>
<PossiblyInvalidIterator occurrences="1">
<code>$parentClass-&gt;table[$indexType]</code>
</PossiblyInvalidIterator>
@@ -569,15 +565,20 @@
<code>protected function _validateAndCompleteManyToManyMapping(array $mapping)</code>
<code>protected function _validateAndCompleteOneToOneMapping(array $mapping)</code>
</InvalidDocblock>
<InvalidNullableReturnType occurrences="3">
<InvalidNullableReturnType occurrences="2">
<code>ReflectionProperty</code>
<code>ReflectionProperty</code>
<code>getReflectionClass</code>
</InvalidNullableReturnType>
<InvalidPropertyAssignmentValue occurrences="2">
<code>$definition</code>
<code>$this-&gt;subClasses</code>
</InvalidPropertyAssignmentValue>
<InvalidReturnStatement occurrences="1">
<code>$this-&gt;reflClass</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>getReflectionClass</code>
</InvalidReturnType>
<LessSpecificReturnStatement occurrences="4">
<code>$cache</code>
<code>$className</code>
@@ -647,8 +648,7 @@
<code>$table</code>
<code>$tableGeneratorDefinition</code>
</PropertyNotSetInConstructor>
<PropertyTypeCoercion occurrences="11">
<code>$this-&gt;discriminatorMap</code>
<PropertyTypeCoercion occurrences="10">
<code>$this-&gt;entityListeners</code>
<code>$this-&gt;fieldMappings</code>
<code>$this-&gt;fullyQualifiedClassName($repositoryClassName)</code>
@@ -747,6 +747,9 @@
</UndefinedInterfaceMethod>
</file>
<file src="lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php">
<DocblockTypeContradiction occurrences="1">
<code>new ReflectionClass($metadata-&gt;name)</code>
</DocblockTypeContradiction>
<InvalidArrayAccess occurrences="4">
<code>$value[0]</code>
<code>$value[0]</code>
@@ -768,7 +771,8 @@
<code>assert($method instanceof ReflectionMethod)</code>
<code>assert($property instanceof ReflectionProperty)</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType occurrences="1">
<RedundantConditionGivenDocblockType occurrences="2">
<code>$metadata-&gt;getReflectionClass()</code>
<code>assert($cacheAttribute instanceof Mapping\Cache)</code>
</RedundantConditionGivenDocblockType>
</file>
@@ -820,8 +824,7 @@
</MissingParamType>
</file>
<file src="lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php">
<ArgumentTypeCoercion occurrences="3">
<code>$map</code>
<ArgumentTypeCoercion occurrences="2">
<code>(string) $xmlRoot['repository-class']</code>
<code>isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null</code>
</ArgumentTypeCoercion>
@@ -979,6 +982,10 @@
</MissingParamType>
</file>
<file src="lib/Doctrine/ORM/Mapping/MappingException.php">
<ArgumentTypeCoercion occurrences="2">
<code>$className</code>
<code>$entityName</code>
</ArgumentTypeCoercion>
<MissingParamType occurrences="4">
<code>$className</code>
<code>$className</code>
@@ -1044,9 +1051,6 @@
</PossiblyFalseOperand>
</file>
<file src="lib/Doctrine/ORM/NativeQuery.php">
<LessSpecificImplementedReturnType occurrences="1">
<code>mixed</code>
</LessSpecificImplementedReturnType>
<PropertyNotSetInConstructor occurrences="1">
<code>$sql</code>
</PropertyNotSetInConstructor>
@@ -1384,9 +1388,6 @@
<InvalidScalarArgument occurrences="1">
<code>$sqlParams</code>
</InvalidScalarArgument>
<LessSpecificImplementedReturnType occurrences="1">
<code>mixed</code>
</LessSpecificImplementedReturnType>
<LessSpecificReturnStatement occurrences="2">
<code>parent::setHint($name, $value)</code>
<code>parent::setHydrationMode($hydrationMode)</code>
@@ -1401,20 +1402,12 @@
<PossiblyNullArgument occurrences="1">
<code>$this-&gt;getDQL()</code>
</PossiblyNullArgument>
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>$timeToLive</code>
</PossiblyNullPropertyAssignmentValue>
<PossiblyNullReference occurrences="1">
<code>evictEntityRegion</code>
</PossiblyNullReference>
<PropertyNotSetInConstructor occurrences="2">
<PropertyNotSetInConstructor occurrences="1">
<code>$parserResult</code>
<code>$queryCacheTTL</code>
</PropertyNotSetInConstructor>
<RedundantConditionGivenDocblockType occurrences="2">
<code>$dqlQuery !== null</code>
<code>$timeToLive !== null</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php">
<ParamNameMismatch occurrences="1">
@@ -1548,7 +1541,7 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php">
<InvalidScalarArgument occurrences="7">
<ArgumentTypeCoercion occurrences="7">
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
@@ -1556,7 +1549,7 @@
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
</InvalidScalarArgument>
</ArgumentTypeCoercion>
<PossiblyInvalidPropertyAssignmentValue occurrences="2">
<code>$parser-&gt;ArithmeticPrimary()</code>
<code>$parser-&gt;ArithmeticPrimary()</code>
@@ -1581,7 +1574,7 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php">
<InvalidScalarArgument occurrences="7">
<ArgumentTypeCoercion occurrences="7">
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
@@ -1589,7 +1582,7 @@
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
<code>$this-&gt;intervalExpression-&gt;dispatch($sqlWalker)</code>
</InvalidScalarArgument>
</ArgumentTypeCoercion>
<UndefinedPropertyFetch occurrences="1">
<code>$this-&gt;unit-&gt;value</code>
</UndefinedPropertyFetch>
@@ -1970,6 +1963,9 @@
<PropertyNotSetInConstructor occurrences="1">
<code>MultiTableUpdateExecutor</code>
</PropertyNotSetInConstructor>
<PropertyTypeCoercion occurrences="1">
<code>$this-&gt;_sqlStatements</code>
</PropertyTypeCoercion>
</file>
<file src="lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php">
<PossiblyInvalidArgument occurrences="1">
@@ -2061,11 +2057,6 @@
<ArgumentTypeCoercion occurrences="1">
<code>$stringPattern</code>
</ArgumentTypeCoercion>
<DocblockTypeContradiction occurrences="3">
<code>call_user_func($functionClass, $functionName)</code>
<code>call_user_func($functionClass, $functionName)</code>
<code>call_user_func($functionClass, $functionName)</code>
</DocblockTypeContradiction>
<InvalidArgument occurrences="1">
<code>$lookaheadType</code>
</InvalidArgument>
@@ -2117,6 +2108,11 @@
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
</InvalidScalarArgument>
<InvalidStringClass occurrences="3">
<code>new $functionClass($functionName)</code>
<code>new $functionClass($functionName)</code>
<code>new $functionClass($functionName)</code>
</InvalidStringClass>
<LessSpecificReturnStatement occurrences="4">
<code>$function</code>
<code>$function</code>
@@ -2250,11 +2246,8 @@
<PossiblyUndefinedVariable occurrences="1">
<code>$args</code>
</PossiblyUndefinedVariable>
<RedundantConditionGivenDocblockType occurrences="4">
<RedundantConditionGivenDocblockType occurrences="1">
<code>$AST instanceof AST\SelectStatement</code>
<code>is_string($functionClass)</code>
<code>is_string($functionClass)</code>
<code>is_string($functionClass)</code>
</RedundantConditionGivenDocblockType>
<UnsafeInstantiation occurrences="3">
<code>new $funcClass($funcNameLower)</code>
@@ -2578,7 +2571,8 @@
</RedundantConditionGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php">
<InvalidReturnStatement occurrences="1">
<InvalidReturnStatement occurrences="2">
<code>$this-&gt;repositoryList[$repositoryHash]</code>
<code>$this-&gt;repositoryList[$repositoryHash] = $this-&gt;createRepository($entityManager, $entityName)</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
@@ -2783,21 +2777,12 @@
<code>$this-&gt;getClassToExtend() ?: $metadata-&gt;name</code>
<code>array_map('strlen', $paramTypes)</code>
</ArgumentTypeCoercion>
<DeprecatedConstant occurrences="1">
<code>ClassMetadataInfo::GENERATOR_TYPE_UUID</code>
</DeprecatedConstant>
<DocblockTypeContradiction occurrences="1">
<code>class_exists($metadata-&gt;name)</code>
</DocblockTypeContradiction>
<InvalidDocblock occurrences="1">
<code>public function setFieldVisibility($visibility)</code>
</InvalidDocblock>
<MissingParamType occurrences="1">
<code>$visibility</code>
</MissingParamType>
<MissingReturnType occurrences="1">
<code>setFieldVisibility</code>
</MissingReturnType>
<PossiblyFalseArgument occurrences="2">
<code>$last</code>
<code>strrpos($metadata-&gt;name, '\\')</code>
@@ -3147,8 +3132,7 @@
<code>setValue</code>
<code>setValue</code>
</PossiblyNullReference>
<PossiblyUndefinedMethod occurrences="4">
<code>addPropertyChangedListener</code>
<PossiblyUndefinedMethod occurrences="3">
<code>unwrap</code>
<code>unwrap</code>
<code>unwrap</code>

View File

@@ -24,6 +24,11 @@
<referencedClass name="Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper"/>
<!-- The exception is thrown by a deprecated method. -->
<referencedClass name="Doctrine\ORM\Cache\Exception\InvalidResultCacheDriver"/>
<!-- We wire the command as long as DBAL ships it -->
<referencedClass name="Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand" />
<!-- Remove on 2.13.x -->
<referencedClass name="Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector"/>
<referencedClass name="Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets"/>
<!-- Remove on 3.0.x -->
<referencedClass name="Doctrine\Common\Persistence\PersistentObject"/>
<referencedClass name="Doctrine\ORM\Exception\UnknownEntityNamespace"/>
@@ -42,6 +47,9 @@
<file name="lib/Doctrine/ORM/Configuration.php"/>
<file name="lib/Doctrine/ORM/Query/Lexer.php"/>
<file name="lib/Doctrine/ORM/Query/Parser.php"/>
<file name="lib/Doctrine/ORM/Tools/EntityGenerator.php"/>
<!-- Remove on 2.13.x. -->
<file name="lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php" />
</errorLevel>
</DeprecatedConstant>
<DeprecatedInterface>
@@ -53,6 +61,8 @@
<errorLevel type="suppress">
<!-- We're calling the deprecated method for BC here. -->
<file name="lib/Doctrine/ORM/Internal/SQLResultCasing.php"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getIdentitySequenceName"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::usesSequenceEmulatedIdentityColumns"/>
<!-- We need to keep the calls for DBAL 2.13 compatibility. -->
<referencedMethod name="Doctrine\DBAL\Cache\QueryCacheProfile::getResultCacheDriver"/>
<referencedMethod name="Doctrine\DBAL\Cache\QueryCacheProfile::setResultCacheDriver"/>
@@ -60,6 +70,11 @@
<referencedMethod name="Doctrine\DBAL\Configuration::setResultCacheImpl"/>
<referencedMethod name="Doctrine\DBAL\Connection::getSchemaManager"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getGuidExpression"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::supportsForeignKeyConstraints"/>
<referencedMethod name="Doctrine\DBAL\Types\Type::getName"/>
<!-- Remove on 2.13.x -->
<referencedMethod name="Doctrine\DBAL\Schema\AbstractSchemaManager::getDatabasePlatform"/>
<referencedMethod name="Doctrine\DBAL\Schema\Schema::visit"/>
<!-- Remove on 3.0.x -->
<referencedMethod name="Doctrine\ORM\Internal\Hydration\AbstractHydrator::hydrateRow"/>
<referencedMethod name="Doctrine\ORM\Configuration::ensureProductionSettings"/>

View File

@@ -6,7 +6,7 @@ namespace Doctrine\Tests\Models\Enums;
enum AccessLevel: int
{
case Admin = 1;
case User = 2;
case Admin = 1;
case User = 2;
case Guests = 3;
}

View File

@@ -6,7 +6,7 @@ namespace Doctrine\Tests\Models\Enums;
enum City: string
{
case Paris = 'Paris';
case Cannes = 'Cannes';
case Paris = 'Paris';
case Cannes = 'Cannes';
case StJulien = 'St Julien';
}

View File

@@ -6,8 +6,8 @@ namespace Doctrine\Tests\Models\Enums;
enum Suit: string
{
case Hearts = 'H';
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
case Clubs = 'C';
case Spades = 'S';
}

View File

@@ -6,6 +6,6 @@ namespace Doctrine\Tests\Models\Enums;
enum Unit: string
{
case Gram = 'g';
case Gram = 'g';
case Meter = 'm';
}

View File

@@ -6,6 +6,6 @@ namespace Doctrine\Tests\Models\Enums;
enum UserStatus: string
{
case Active = 'active';
case Active = 'active';
case Inactive = 'inactive';
}

View File

@@ -51,6 +51,9 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
/** @var CmsPhonenumber */
private $phonenumber;
/** @var array<string, mixed> */
private $previousCacheConfig = [];
protected function setUp(): void
{
$this->useModelSet('tweet');

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Tools\ToolsException;
use Doctrine\Tests\Models\Upsertable\Insertable;
use Doctrine\Tests\Models\Upsertable\Updatable;
use Doctrine\Tests\OrmFunctionalTestCase;
@@ -15,15 +14,7 @@ class InsertableUpdatableTest extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(Updatable::class),
$this->_em->getClassMetadata(Insertable::class),
]
);
} catch (ToolsException $e) {
}
$this->createSchemaForModels(Updatable::class, Insertable::class);
}
public function testNotInsertableIsFetchedFromDatabase(): void

View File

@@ -21,7 +21,7 @@ use const DIRECTORY_SEPARATOR;
*/
class ManyToOneOrphanRemovalTest extends OrmFunctionalTestCase
{
/** @var int */
/** @var string */
private $personId;
/** @var array<string, list<class-string>> */

View File

@@ -16,11 +16,9 @@ class MergeCompositeToOneKeyTest extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(Country::class),
$this->_em->getClassMetadata(CompositeToOneKeyState::class),
]
$this->createSchemaForModels(
Country::class,
CompositeToOneKeyState::class
);
}

View File

@@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\MappedSuperclass;
use Doctrine\ORM\Tools\ToolsException;
use Doctrine\Tests\OrmFunctionalTestCase;
use function serialize;
@@ -22,15 +21,7 @@ class MergeSharedEntitiesTest extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(MSEFile::class),
$this->_em->getClassMetadata(MSEPicture::class),
]
);
} catch (ToolsException $ignored) {
}
$this->createSchemaForModels(MSEFile::class, MSEPicture::class);
}
public function testMergeSharedNewEntities(): void

View File

@@ -30,10 +30,7 @@ class NotifyPolicyTest extends OrmFunctionalTestCase
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8383');
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(NotifyUser::class),
$this->_em->getClassMetadata(NotifyGroup::class),
]);
$this->createSchemaForModels(NotifyUser::class, NotifyGroup::class);
}
public function testChangeTracking(): void

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Tools\ToolsException;
use Doctrine\Tests\Models\OneToOneInverseSideLoad\InverseSide;
use Doctrine\Tests\Models\OneToOneInverseSideLoad\OwningSide;
use Doctrine\Tests\OrmFunctionalTestCase;
@@ -17,14 +16,7 @@ class OneToOneInverseSideLoadAfterDqlQueryTest extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(OwningSide::class),
$this->_em->getClassMetadata(InverseSide::class),
]);
} catch (ToolsException $e) {
// ignored
}
$this->createSchemaForModels(OwningSide::class, InverseSide::class);
}
/**

View File

@@ -98,9 +98,7 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
public function testMultiSelfReference(): void
{
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(MultiSelfReference::class),
]);
$this->createSchemaForModels(MultiSelfReference::class);
$entity1 = new MultiSelfReference();
$this->_em->persist($entity1);

View File

@@ -17,11 +17,11 @@ class OneToOneSingleTableInheritanceTest extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(Pet::class),
$this->_em->getClassMetadata(Cat::class),
$this->_em->getClassMetadata(LitterBox::class),
]);
$this->createSchemaForModels(
Pet::class,
Cat::class,
LitterBox::class
);
}
/**

View File

@@ -27,11 +27,11 @@ class OrderedJoinedTableInheritanceCollectionTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(OJTICPet::class),
$this->_em->getClassMetadata(OJTICCat::class),
$this->_em->getClassMetadata(OJTICDog::class),
]);
$this->createSchemaForModels(
OJTICPet::class,
OJTICCat::class,
OJTICDog::class
);
$dog = new OJTICDog();
$dog->name = 'Poofy';

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\SchemaTool;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Tests\Models\Company\CompanyManager;
use Doctrine\Tests\OrmFunctionalTestCase;
@@ -55,8 +56,8 @@ class CompanySchemaTest extends OrmFunctionalTestCase
*/
public function testDropPartSchemaWithForeignKeys(): void
{
if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) {
self::markTestSkipped('Foreign Key test');
if ($this->_em->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) {
self::markTestSkipped('SQLite does not support dropping foreign keys.');
}
$sql = $this->_schemaTool->getDropSchemaSQL(

View File

@@ -8,7 +8,6 @@ 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\Tests\OrmFunctionalTestCase;
use function array_filter;
@@ -16,28 +15,16 @@ use function str_contains;
class DBAL483Test extends OrmFunctionalTestCase
{
/** @var Tools\SchemaTool */
private $schemaTool;
protected function setUp(): void
{
parent::setUp();
$this->_em->getConnection();
$this->schemaTool = new Tools\SchemaTool($this->_em);
}
/**
* @group DBAL-483
*/
public function testDefaultValueIsComparedCorrectly(): void
{
$class = $this->_em->getClassMetadata(DBAL483Default::class);
$class = DBAL483Default::class;
$this->schemaTool->createSchema([$class]);
$this->createSchemaForModels($class);
$updateSql = $this->schemaTool->getUpdateSchemaSql([$class]);
$updateSql = $this->getUpdateSchemaSqlForModels($class);
$updateSql = array_filter($updateSql, static function ($sql) {
return str_contains($sql, 'DBAL483');

View File

@@ -6,10 +6,8 @@ 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 implode;
@@ -23,12 +21,6 @@ use const PHP_EOL;
*/
class DDC214Test extends OrmFunctionalTestCase
{
/** @psalm-var list<class-string> */
private $classes = [];
/** @var Tools\SchemaTool */
private $schemaTool = null;
protected function setUp(): void
{
parent::setUp();
@@ -38,8 +30,6 @@ class DDC214Test extends OrmFunctionalTestCase
if ($conn->getDriver()->getDatabasePlatform() instanceof SqlitePlatform) {
self::markTestSkipped('SQLite does not support ALTER TABLE statements.');
}
$this->schemaTool = new Tools\SchemaTool($this->_em);
}
/**
@@ -47,16 +37,14 @@ class DDC214Test extends OrmFunctionalTestCase
*/
public function testCmsAddressModel(): void
{
$this->classes = [
$this->assertCreatedSchemaNeedsNoUpdates(
Models\CMS\CmsUser::class,
Models\CMS\CmsPhonenumber::class,
Models\CMS\CmsAddress::class,
Models\CMS\CmsGroup::class,
Models\CMS\CmsArticle::class,
Models\CMS\CmsEmail::class,
];
$this->assertCreatedSchemaNeedsNoUpdates($this->classes);
Models\CMS\CmsEmail::class
);
}
/**
@@ -64,7 +52,7 @@ class DDC214Test extends OrmFunctionalTestCase
*/
public function testCompanyModel(): void
{
$this->classes = [
$this->assertCreatedSchemaNeedsNoUpdates(
Models\Company\CompanyPerson::class,
Models\Company\CompanyEmployee::class,
Models\Company\CompanyManager::class,
@@ -72,29 +60,21 @@ class DDC214Test extends OrmFunctionalTestCase
Models\Company\CompanyEvent::class,
Models\Company\CompanyAuction::class,
Models\Company\CompanyRaffle::class,
Models\Company\CompanyCar::class,
];
$this->assertCreatedSchemaNeedsNoUpdates($this->classes);
Models\Company\CompanyCar::class
);
}
public function assertCreatedSchemaNeedsNoUpdates($classes): void
/**
* @param class-string ...$classes
*/
public function assertCreatedSchemaNeedsNoUpdates(string ...$classes): void
{
$classMetadata = [];
foreach ($classes as $class) {
$classMetadata[] = $this->_em->getClassMetadata($class);
}
try {
$this->schemaTool->createSchema($classMetadata);
} catch (Exception $e) {
// was already created
}
$this->createSchemaForModels(...$classes);
$sm = $this->createSchemaManager();
$fromSchema = $sm->createSchema();
$toSchema = $this->schemaTool->getSchemaFromMetadata($classMetadata);
$toSchema = $this->getSchemaForModels(...$classes);
if (method_exists($sm, 'createComparator')) {
$comparator = $sm->createComparator();

View File

@@ -12,12 +12,10 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\Models;
use Doctrine\Tests\OrmFunctionalTestCase;
use function array_filter;
use function array_shift;
use function implode;
use function str_starts_with;
@@ -40,108 +38,15 @@ class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase
self::assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']);
}
public function testGetCreateSchemaSql(): void
{
$classes = [
$this->_em->getClassMetadata(Models\CMS\CmsAddress::class),
$this->_em->getClassMetadata(Models\CMS\CmsUser::class),
$this->_em->getClassMetadata(Models\CMS\CmsPhonenumber::class),
];
$tool = new SchemaTool($this->_em);
$sql = $tool->getCreateSchemaSql($classes);
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::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.');
}
public function testGetCreateSchemaSql2(): void
{
$classes = [$this->_em->getClassMetadata(Models\Generic\DecimalModel::class)];
$tool = new SchemaTool($this->_em);
$sql = $tool->getCreateSchemaSql($classes);
self::assertCount(2, $sql);
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
{
$classes = [$this->_em->getClassMetadata(Models\Generic\BooleanModel::class)];
$tool = new SchemaTool($this->_em);
$sql = $tool->getCreateSchemaSql($classes);
self::assertCount(2, $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
{
$classes = [
$this->_em->getClassMetadata(Models\CMS\CmsAddress::class),
$this->_em->getClassMetadata(Models\CMS\CmsUser::class),
$this->_em->getClassMetadata(Models\CMS\CmsPhonenumber::class),
];
$tool = new SchemaTool($this->_em);
$sql = $tool->getDropSchemaSQL($classes);
self::assertCount(17, $sql);
$dropSequenceSQLs = 0;
foreach ($sql as $stmt) {
if (str_starts_with($stmt, 'DROP SEQUENCE')) {
$dropSequenceSQLs++;
}
}
self::assertEquals(4, $dropSequenceSQLs, 'Expect 4 sequences to be dropped.');
}
/**
* @group DDC-1657
*/
public function testUpdateSchemaWithPostgreSQLSchema(): void
{
$classes = [
$this->_em->getClassMetadata(DDC1657Screen::class),
$this->_em->getClassMetadata(DDC1657Avatar::class),
];
$tool = new SchemaTool($this->_em);
$tool->createSchema($classes);
$sql = $tool->getUpdateSchemaSql($classes);
$sql = $this->getUpdateSchemaSqlForModels(
DDC1657Screen::class,
DDC1657Avatar::class
);
$sql = array_filter($sql, static function ($sql) {
return str_starts_with($sql, 'DROP SEQUENCE stonewood.');
});

View File

@@ -23,9 +23,7 @@ class SequenceEmulatedIdentityStrategyTest extends OrmFunctionalTestCase
'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);
}
}

View File

@@ -24,12 +24,10 @@ class DDC1080Test extends OrmFunctionalTestCase
{
public function testHydration(): void
{
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1080Foo::class),
$this->_em->getClassMetadata(DDC1080Bar::class),
$this->_em->getClassMetadata(DDC1080FooBar::class),
]
$this->createSchemaForModels(
DDC1080Foo::class,
DDC1080Bar::class,
DDC1080FooBar::class
);
$foo1 = new DDC1080Foo();

View File

@@ -1,82 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\Table;
use Doctrine\Tests\OrmFunctionalTestCase;
/**
* @group DDC-1151
*/
class DDC1151Test extends OrmFunctionalTestCase
{
public function testQuoteForeignKey(): void
{
$platform = $this->_em->getConnection()->getDatabasePlatform();
if (! $platform instanceof PostgreSQLPlatform) {
self::markTestSkipped('This test is useful for all databases, but designed only for postgresql.');
}
$sql = $this->_schemaTool->getCreateSchemaSql(
[
$this->_em->getClassMetadata(DDC1151User::class),
$this->_em->getClassMetadata(DDC1151Group::class),
]
);
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]);
}
}
/**
* @Entity
* @Table(name="`User`")
*/
class DDC1151User
{
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
public $id;
/**
* @psalm-var Collection<int, DDC1151Group>
* @ManyToMany(targetEntity="DDC1151Group")
*/
public $groups;
}
/**
* @Entity
* @Table(name="`Group`")
*/
class DDC1151Group
{
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
public $id;
}

View File

@@ -36,13 +36,11 @@ class DDC1163Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1163Product::class),
$this->_em->getClassMetadata(DDC1163SpecialProduct::class),
$this->_em->getClassMetadata(DDC1163ProxyHolder::class),
$this->_em->getClassMetadata(DDC1163Tag::class),
]
$this->createSchemaForModels(
DDC1163Product::class,
DDC1163SpecialProduct::class,
DDC1163ProxyHolder::class,
DDC1163Tag::class
);
}

View File

@@ -19,12 +19,10 @@ class DDC1181Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1181Hotel::class),
$this->_em->getClassMetadata(DDC1181Booking::class),
$this->_em->getClassMetadata(DDC1181Room::class),
]
$this->createSchemaForModels(
DDC1181Hotel::class,
DDC1181Booking::class,
DDC1181Room::class
);
}

View File

@@ -19,12 +19,10 @@ class DDC1193Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1193Company::class),
$this->_em->getClassMetadata(DDC1193Person::class),
$this->_em->getClassMetadata(DDC1193Account::class),
]
$this->createSchemaForModels(
DDC1193Company::class,
DDC1193Person::class,
DDC1193Account::class
);
}

View File

@@ -23,11 +23,9 @@ class DDC1225Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1225TestEntity1::class),
$this->_em->getClassMetadata(DDC1225TestEntity2::class),
]
$this->createSchemaForModels(
DDC1225TestEntity1::class,
DDC1225TestEntity2::class
);
}

View File

@@ -20,9 +20,7 @@ class DDC1250Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[$this->_em->getClassMetadata(DDC1250ClientHistory::class)]
);
$this->createSchemaForModels(DDC1250ClientHistory::class);
}
public function testIssue(): void

View File

@@ -22,11 +22,9 @@ class DDC1300Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1300Foo::class),
$this->_em->getClassMetadata(DDC1300FooLocale::class),
]
$this->createSchemaForModels(
DDC1300Foo::class,
DDC1300FooLocale::class
);
}

View File

@@ -1,57 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
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\OrmFunctionalTestCase;
/**
* @group DDC-1360
*/
class DDC1360Test extends OrmFunctionalTestCase
{
public function testSchemaDoubleQuotedCreate(): void
{
$platform = $this->_em->getConnection()->getDatabasePlatform();
if (! $platform instanceof PostgreSQLPlatform) {
self::markTestSkipped('PostgreSQL only test.');
}
$sql = $this->_schemaTool->getCreateSchemaSql(
[
$this->_em->getClassMetadata(DDC1360DoubleQuote::class),
]
);
self::assertEquals(
[
'CREATE SCHEMA user',
'CREATE TABLE "user"."user" (id INT NOT NULL, PRIMARY KEY(id))',
'CREATE SEQUENCE "user"."user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1',
],
$sql
);
}
}
/**
* @Entity
* @Table(name="`user`.`user`")
*/
class DDC1360DoubleQuote
{
/**
* @var int
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
public $id;
}

View File

@@ -13,7 +13,6 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function get_debug_type;
@@ -26,15 +25,10 @@ class DDC1383Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1383AbstractEntity::class),
$this->_em->getClassMetadata(DDC1383Entity::class),
]
);
} catch (Exception $ignored) {
}
$this->createSchemaForModels(
DDC1383AbstractEntity::class,
DDC1383Entity::class
);
}
public function testFailingCase(): void

View File

@@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1392
@@ -23,15 +22,7 @@ class DDC1392Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1392File::class),
$this->_em->getClassMetadata(DDC1392Picture::class),
]
);
} catch (Exception $ignored) {
}
$this->createSchemaForModels(DDC1392File::class, DDC1392Picture::class);
}
public function testFailingCase(): void

View File

@@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1400
@@ -23,16 +22,11 @@ class DDC1400Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1400Article::class),
$this->_em->getClassMetadata(DDC1400User::class),
$this->_em->getClassMetadata(DDC1400UserState::class),
]
$this->createSchemaForModels(
DDC1400Article::class,
DDC1400User::class,
DDC1400UserState::class
);
} catch (Exception $ignored) {
}
}
public function testFailingCase(): void

View File

@@ -25,17 +25,12 @@ class DDC1404Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1404ParentEntity::class),
$this->_em->getClassMetadata(DDC1404ChildEntity::class),
]
);
$this->createSchemaForModels(
DDC1404ParentEntity::class,
DDC1404ChildEntity::class
);
$this->loadFixtures();
} catch (Exception $exc) {
}
$this->loadFixtures();
}
public function testTicket(): void

View File

@@ -6,6 +6,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket;
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;
@@ -167,7 +168,7 @@ class DDC1430Order
/**
* @OneToMany(targetEntity="DDC1430OrderProduct", mappedBy="order", cascade={"persist", "remove"})
* @var ArrayCollection $products
* @var Collection $products
*/
private $products;

View File

@@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1436
@@ -22,14 +21,7 @@ class DDC1436Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1436Page::class),
]
);
} catch (Exception $ignored) {
}
$this->createSchemaForModels(DDC1436Page::class);
}
public function testIdentityMap(): void

View File

@@ -20,11 +20,9 @@ class DDC144Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC144FlowElement::class),
$this->_em->getClassMetadata(DDC144Operand::class),
]
$this->createSchemaForModels(
DDC144FlowElement::class,
DDC144Operand::class
);
}

View File

@@ -16,7 +16,6 @@ use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1452
@@ -28,15 +27,10 @@ class DDC1452Test extends OrmFunctionalTestCase
$this->useModelSet('cms');
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1452EntityA::class),
$this->_em->getClassMetadata(DDC1452EntityB::class),
]
);
} catch (Exception $ignored) {
}
$this->createSchemaForModels(
DDC1452EntityA::class,
DDC1452EntityB::class
);
}
public function testIssue(): void

View File

@@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function getrandmax;
use function random_int;
@@ -26,15 +25,7 @@ class DDC1454Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1454File::class),
$this->_em->getClassMetadata(DDC1454Picture::class),
]
);
} catch (Exception $ignored) {
}
$this->createSchemaForModels(DDC1454File::class, DDC1454Picture::class);
}
public function testFailingCase(): void

View File

@@ -16,11 +16,9 @@ class DDC1458Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(TestEntity::class),
$this->_em->getClassMetadata(TestAdditionalEntity::class),
]
$this->createSchemaForModels(
TestEntity::class,
TestAdditionalEntity::class
);
}

View File

@@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function assert;
@@ -27,16 +26,11 @@ class DDC1509Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1509AbstractFile::class),
$this->_em->getClassMetadata(DDC1509File::class),
$this->_em->getClassMetadata(DDC1509Picture::class),
]
);
} catch (Exception $ignored) {
}
$this->createSchemaForModels(
DDC1509AbstractFile::class,
DDC1509File::class,
DDC1509Picture::class
);
}
public function testFailingCase(): void

View File

@@ -13,7 +13,6 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1514
@@ -24,16 +23,11 @@ class DDC1514Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1514EntityA::class),
$this->_em->getClassMetadata(DDC1514EntityB::class),
$this->_em->getClassMetadata(DDC1514EntityC::class),
]
);
} catch (Exception $ignored) {
}
$this->createSchemaForModels(
DDC1514EntityA::class,
DDC1514EntityB::class,
DDC1514EntityC::class
);
}
public function testIssue(): void

View File

@@ -19,11 +19,9 @@ class DDC1515Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1515Foo::class),
$this->_em->getClassMetadata(DDC1515Bar::class),
]
$this->createSchemaForModels(
DDC1515Foo::class,
DDC1515Bar::class
);
}

View File

@@ -21,11 +21,7 @@ class DDC1526Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1526Menu::class),
]
);
$this->createSchemaForModels(DDC1526Menu::class);
}
public function testIssue(): void

View File

@@ -19,12 +19,10 @@ class DDC1548Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1548E1::class),
$this->_em->getClassMetadata(DDC1548E2::class),
$this->_em->getClassMetadata(DDC1548Rel::class),
]
$this->createSchemaForModels(
DDC1548E1::class,
DDC1548E2::class,
DDC1548Rel::class
);
}

View File

@@ -29,12 +29,10 @@ class DDC1595Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1595BaseInheritance::class),
$this->_em->getClassMetadata(DDC1595InheritedEntity1::class),
$this->_em->getClassMetadata(DDC1595InheritedEntity2::class),
]
$this->createSchemaForModels(
DDC1595BaseInheritance::class,
DDC1595InheritedEntity1::class,
DDC1595InheritedEntity2::class
);
}

View File

@@ -23,10 +23,7 @@ class DDC1690Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(DDC1690Parent::class),
$this->_em->getClassMetadata(DDC1690Child::class),
]);
$this->createSchemaForModels(DDC1690Parent::class, DDC1690Child::class);
}
public function testChangeTracking(): void

View File

@@ -14,7 +14,6 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Mapping\PostLoad;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1707
@@ -25,15 +24,10 @@ class DDC1707Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1509File::class),
$this->_em->getClassMetadata(DDC1509Picture::class),
]
);
} catch (Exception $ignored) {
}
$this->createSchemaForModels(
DDC1707Base::class,
DDC1707Child::class
);
}
public function testPostLoadOnChild(): void

View File

@@ -22,11 +22,9 @@ class DDC1787Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1787Foo::class),
$this->_em->getClassMetadata(DDC1787Bar::class),
]
$this->createSchemaForModels(
DDC1787Foo::class,
DDC1787Bar::class
);
}

View File

@@ -26,12 +26,7 @@ class DDC1925Test extends OrmFunctionalTestCase
{
public function testIssue(): void
{
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1925User::class),
$this->_em->getClassMetadata(DDC1925Product::class),
]
);
$this->createSchemaForModels(DDC1925User::class, DDC1925Product::class);
$user = new DDC1925User();
$user->setTitle('Test User');

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
@@ -14,8 +13,6 @@ use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\Table;
use Doctrine\Tests\OrmFunctionalTestCase;
use function assert;
/**
* @group DDC-192
*/
@@ -24,17 +21,19 @@ class DDC192Test extends OrmFunctionalTestCase
public function testSchemaCreation(): void
{
$classes = [
$this->_em->getClassMetadata(DDC192User::class),
$this->_em->getClassMetadata(DDC192Phonenumber::class),
DDC192User::class,
DDC192Phonenumber::class,
];
$this->_schemaTool->createSchema($classes);
$this->createSchemaForModels(...$classes);
$tables = $this->createSchemaManager()->listTableNames();
foreach ($classes as $class) {
assert($class instanceof ClassMetadata);
self::assertContains($class->getTableName(), $tables);
self::assertContains(
$this->_em->getClassMetadata($class)->getTableName(),
$tables
);
}
}
}

View File

@@ -21,11 +21,7 @@ class DDC1998Test extends OrmFunctionalTestCase
{
Type::addType('ddc1998', DDC1998Type::class);
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1998Entity::class),
]
);
$this->createSchemaForModels(DDC1998Entity::class);
$entity = new DDC1998Entity();
$entity->id = new DDC1998Id('foo');

View File

@@ -23,12 +23,10 @@ class DDC199Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC199ParentClass::class),
$this->_em->getClassMetadata(DDC199ChildClass::class),
$this->_em->getClassMetadata(DDC199RelatedClass::class),
]
$this->createSchemaForModels(
DDC199ParentClass::class,
DDC199ChildClass::class,
DDC199RelatedClass::class
);
}

View File

@@ -37,11 +37,9 @@ class DDC2012Test extends OrmFunctionalTestCase
DDC2012TsVectorType::$calls = [];
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2012Item::class),
$this->_em->getClassMetadata(DDC2012ItemPerson::class),
]
$this->createSchemaForModels(
DDC2012Item::class,
DDC2012ItemPerson::class
);
}

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-2084
@@ -16,15 +15,10 @@ class DDC2084Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2084\MyEntity1'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2084\MyEntity2'),
]
);
} catch (Exception $exc) {
}
$this->createSchemaForModels(
__NAMESPACE__ . '\DDC2084\MyEntity1',
__NAMESPACE__ . '\DDC2084\MyEntity2'
);
}
public function loadFixture(): DDC2084\MyEntity1

View File

@@ -24,11 +24,7 @@ class DDC2106Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2106Entity::class),
]
);
$this->createSchemaForModels(DDC2106Entity::class);
}
public function testDetachedEntityAsId(): void

View File

@@ -21,12 +21,7 @@ class DDC211Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC211User::class),
$this->_em->getClassMetadata(DDC211Group::class),
]
);
$this->createSchemaForModels(DDC211User::class, DDC211Group::class);
}
public function testIssue(): void

View File

@@ -18,7 +18,6 @@ use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\OrmFunctionalTestCase;
use function assert;
@@ -31,18 +30,14 @@ class DDC2138Test extends OrmFunctionalTestCase
*/
public function testForeignKeyOnSTIWithMultipleMapping(): void
{
$em = $this->_em;
$schemaTool = new SchemaTool($em);
$classes = [
$em->getClassMetadata(DDC2138User::class),
$em->getClassMetadata(DDC2138Structure::class),
$em->getClassMetadata(DDC2138UserFollowedObject::class),
$em->getClassMetadata(DDC2138UserFollowedStructure::class),
$em->getClassMetadata(DDC2138UserFollowedUser::class),
];
$schema = $schemaTool->getSchemaFromMetadata($classes);
$em = $this->_em;
$schema = $this->getSchemaForModels(
DDC2138User::class,
DDC2138Structure::class,
DDC2138UserFollowedObject::class,
DDC2138UserFollowedStructure::class,
DDC2138UserFollowedUser::class
);
self::assertTrue($schema->hasTable('users_followed_objects'), 'Table users_followed_objects should exist.');
$table = $schema->getTable('users_followed_objects');

View File

@@ -21,11 +21,7 @@ class DDC2175Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2175Entity::class),
]
);
$this->createSchemaForModels(DDC2175Entity::class);
}
public function testIssue(): void

View File

@@ -30,12 +30,7 @@ class DDC2214Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2214Foo::class),
$this->_em->getClassMetadata(DDC2214Bar::class),
]
);
$this->createSchemaForModels(DDC2214Foo::class, DDC2214Bar::class);
}
public function testIssue(): void

View File

@@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Tools\ToolsException;
use Doctrine\Persistence\NotifyPropertyChanged;
use Doctrine\Persistence\PropertyChangedListener;
use Doctrine\Tests\OrmFunctionalTestCase;
@@ -27,15 +26,10 @@ class DDC2230Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2230User::class),
$this->_em->getClassMetadata(DDC2230Address::class),
]
);
} catch (ToolsException $e) {
}
$this->createSchemaForModels(
DDC2230User::class,
DDC2230Address::class
);
}
public function testNotifyTrackingNotCalledOnUninitializedProxies(): void

View File

@@ -30,11 +30,7 @@ class DDC2231Test extends OrmFunctionalTestCase
}
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2231EntityY::class),
]
);
$this->createSchemaForModels(DDC2231EntityY::class);
}
public function testInjectObjectManagerInProxyIfInitializedInUow(): void

View File

@@ -40,13 +40,11 @@ class DDC2252Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2252User::class),
$this->_em->getClassMetadata(DDC2252Privilege::class),
$this->_em->getClassMetadata(DDC2252Membership::class),
$this->_em->getClassMetadata(DDC2252MerchantAccount::class),
]
$this->createSchemaForModels(
DDC2252User::class,
DDC2252Privilege::class,
DDC2252Membership::class,
DDC2252MerchantAccount::class
);
$this->loadFixtures();

View File

@@ -33,11 +33,9 @@ class DDC2256Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2256User::class),
$this->_em->getClassMetadata(DDC2256Group::class),
]
$this->createSchemaForModels(
DDC2256User::class,
DDC2256Group::class
);
}

View File

@@ -26,13 +26,11 @@ class DDC2306Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2306Zone::class),
$this->_em->getClassMetadata(DDC2306User::class),
$this->_em->getClassMetadata(DDC2306Address::class),
$this->_em->getClassMetadata(DDC2306UserAddress::class),
]
$this->createSchemaForModels(
DDC2306Zone::class,
DDC2306User::class,
DDC2306Address::class,
DDC2306UserAddress::class
);
}

View File

@@ -26,12 +26,10 @@ class DDC2346Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2346Foo::class),
$this->_em->getClassMetadata(DDC2346Bar::class),
$this->_em->getClassMetadata(DDC2346Baz::class),
]
$this->createSchemaForModels(
DDC2346Foo::class,
DDC2346Bar::class,
DDC2346Baz::class
);
}

View File

@@ -23,12 +23,7 @@ class DDC2350Test extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC2350User::class),
$this->_em->getClassMetadata(DDC2350Bug::class),
]
);
$this->createSchemaForModels(DDC2350User::class, DDC2350Bug::class);
}
public function testEagerCollectionsAreOnlyRetrievedOnce(): void

View File

@@ -21,12 +21,10 @@ class DDC237Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC237EntityX::class),
$this->_em->getClassMetadata(DDC237EntityY::class),
$this->_em->getClassMetadata(DDC237EntityZ::class),
]
$this->createSchemaForModels(
DDC237EntityX::class,
DDC237EntityY::class,
DDC237EntityZ::class
);
}

Some files were not shown because too many files have changed in this diff Show More