Compare commits

...

67 Commits

Author SHA1 Message Date
Mitch
4af1aa3177 ScalarColumnHydrator: prevent early-bail on falsy values (#9663)
* add failing test for issue #9230

* ScalarColumnHydrator: prevent early-bail on falsy values, fix #9230

Co-authored-by: Mickael GOETZ <contact@mickael-goetz.com>
2022-04-19 09:01:33 +00:00
Alexander M. Turek
f4d5283f70 Fix static analysis for Persistence 2.5 (#9648) 2022-04-10 23:31:12 +02:00
Grégoire Paris
976fe5bc0d Merge pull request #9639 from ruudk/patch-1
Fix composer install in contributing readme
2022-04-09 16:41:21 +02:00
Ruud Kamphuis
582b222b00 Fix composer install in contributing readme
People that contribute know how to use composer.
2022-04-09 15:29:45 +02:00
Grégoire Paris
1ffb9152f7 Merge pull request #9623 from BenoitDuffez/dont-use-depecated-ormexception
explicitly use the non-deprecated ORMException
2022-04-02 11:52:48 +02:00
Benoit Duffez
51faa6ddb7 explicitly use the non-deprecated ORMException 2022-04-01 13:23:05 -07:00
Alexander M. Turek
692c3e1b45 Remove "Description of" PHPDoc (#9611) 2022-03-28 13:47:30 +02:00
Alexander M. Turek
e410180c6e PHPStan 1.5.0 (#9607) 2022-03-28 10:37:03 +02:00
Grégoire Paris
4476b05d59 Merge pull request #9608 from greg0ire/remove-python-config
Remove Sphinx config
2022-03-26 17:15:36 +01:00
Grégoire Paris
343b0ae576 Remove Sphinx config
I do not think this file is still useful, since AFAIK we are not using
Sphinx anymore. Besides, this is the only Doctrine project I could find
that still has that file. It was last updated 6 years ago.
2022-03-26 12:07:22 +01:00
Grégoire Paris
de69f60c6a Merge pull request #9598 from greg0ire/fix-event-table
Use correct syntax for external links
2022-03-20 19:32:10 +01:00
Grégoire Paris
2a653b05a0 Use correct syntax for external links
There is no leading underscore, and the trailing underscore should not
be forgotten.
2022-03-20 19:13:19 +01:00
Jan Záruba
c6831c6b07 Update XmlExporter.php - Type problem in php8.x (#9589)
Please see PHP interface SimpleXMLElement::addAttribute(string $name, string $value = null, string $namespace = null): void .... 
The $value must be string or null.
2022-03-19 13:03:28 +01:00
Grégoire Paris
33da4d84eb Merge pull request #9590 from greg0ire/fix-build
Ignore deprecation from Persistence
2022-03-18 22:56:08 +01:00
Grégoire Paris
c1b373b931 Ignore deprecation from Persistence
The deprecation is already addressed in the next minor branch.
2022-03-18 19:19:15 +01:00
Maxime Veber
b6cff1aa1c Stands with Ukraine (#9567) 2022-03-18 10:32:03 +01:00
Grégoire Paris
d2206152bb Merge pull request #9585 from greg0ire/hunt-down-latest 2022-03-13 17:11:29 +01:00
Grégoire Paris
a34dc0a0e3 Use internal links when self-referencing
This should result in links with the current version of the docs.
2022-03-13 14:36:37 +01:00
Grégoire Paris
881a7b3b69 Link to docs for the stable version
When we do not know what version people intend to browse, it seems more
sensible to assume they want to see the docs for the stable version.
2022-03-13 14:35:15 +01:00
Alexander M. Turek
82bbb1dc4a Baseline Psalm errors caused by DBAL 3.3.3 (#9577) 2022-03-09 17:18:11 +01:00
flack
9c351e0444 Make sure MemcachedAdapter is supported before tring to use it (#9574) 2022-03-09 16:23:58 +01:00
Thomas Landauer
5ed5383338 Fixing :doc: link (#9569) 2022-03-08 22:31:56 +01:00
Thomas Landauer
eb1d54871b Adding PHP attributes (#9555)
Co-authored-by: Alexander M. Turek <me@derrabus.de>
Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com>
2022-03-08 01:40:01 +01:00
Grégoire Paris
e148c838b0 Merge pull request #9563 from greg0ire/address-sqllogger-deprecation
Remove reference to removed class
2022-03-03 22:27:51 +01:00
Grégoire Paris
c73df2a7b4 Remove reference to removed class
EchoSQLLogger is deprecated in DBAL 2, and removed in DBAL 3.
2022-03-03 22:12:04 +01:00
Jan Barášek
38682e93db Parser: SimpleArithmeticExpression should return ArithmeticTerm (#9557) 2022-03-03 00:25:27 +01:00
Alexander M. Turek
84df37de97 Update baselines for Lexer 1.2.3 (#9546) 2022-02-28 14:06:31 +01:00
Grégoire Paris
856c3143f8 Merge pull request #9537 from kiler129/fix-bug-9536
Make error message suggestion accurate
2022-02-22 20:08:49 +01:00
kiler129
79f73a23f3 Fix bug-#9536
Wrong validation message is displayed when an incorrect bidirectional
bi-directional mapping is set up. When the owning side is configured
correctly and the target side is missing the back reference, the ORM
suggests adding inverseBy instead of mappedBy, with the field name
missing. This commit fixes this problem.
2022-02-22 12:05:35 -06:00
Grégoire Paris
4af912f712 Merge pull request #9539 from greg0ire/use-stable-dbal
Drop minor version number
2022-02-22 18:01:26 +01:00
Grégoire Paris
65f48e0ecd Drop minor version number
We should make it explicit that we mean to test with whatever is the
latest 3.x
2022-02-22 17:25:21 +01:00
Matthias Pigulla
193c3abf0e Bring FilterCollection to a "clean" state after hash computation (#9523)
Co-authored-by: Alexander M. Turek <me@derrabus.de>
2022-02-20 13:09:05 +00:00
Grégoire Paris
5b8263e8fb Merge pull request #9526 from greg0ire/better-model-setup
Make creating test models more straightforward and revert to swallowing exceptions
2022-02-20 09:35:21 +01:00
Grégoire Paris
26e85b8c88 Make creating test models more straightforward
In https://github.com/doctrine/orm/pull/8962, I established that
swallowing exceptions while creating model was bad because it could hide
other helpful exceptions.
As it turns out however, swallowing exceptions is really the way to go
here, because of the performance implication of calling dropSchema(). It
is possible to catch a more precise exception as well, which should
preserve the benefits of not swallowing them.

It looks like I based my grep on the comment inside the catch and today,
I found many other occurrences of this pattern, without the easy to grep
comment.

I decided to fix them as well, but in a lazier way: one no longer has to
remember to call dropSchema in tearDown() now, it is automated.
2022-02-20 09:26:57 +01:00
Grégoire Paris
152c04c03d Merge pull request #9519 from lcobucci/fix-pagination-test
Trigger the desired code path
2022-02-16 09:24:32 +01:00
Luís Cobucci
12ab6fa43f Trigger the desired code path
Since v2.7.0 the ORM avoids using extra queries via the paginator
component when maximum results isn't set on the original query. With
that change, this test was not executing the code path that it was
expected to run.

This makes sure we trigger the forcing of custom DBAL types when
hydrating the identifiers, making sure we don't introduce bugs.

More info:
- Forcing DBAL type conversion: https://github.com/doctrine/orm/pull/7905
- Issue on optimisation: https://github.com/doctrine/orm/issues/7829
- PR on optimisation: https://github.com/doctrine/orm/pull/7863
- Minor BC-break docs: https://github.com/doctrine/orm/blob/2.11.x/UPGRADE.md#minor-bc-break-paginator-output-walkers-arent-be-called-anymore-on-sub-queries-for-queries-without-max-results
2022-02-15 22:59:09 +01:00
Yann Rabiller
e8e61cbbd5 Fix syntax typo in attributes reference (#9513)
Curly brackets are the annotation way of declaring array. Probably a
mistake while copy pasting some examples from annotations.
2022-02-15 14:32:33 +00:00
Tony Lemke
8f847cb5aa Constructor-Argument "options" has the same type as the associated property. (#9501) 2022-02-13 21:42:15 +01:00
David Maicher
599832cb81 Fix AbstractQuery::setParameter phpdoc (#9504)
* Fix AbstractQuery::setParameter phpdoc

* Fix AbstractQuery::setParameter phpdoc
2022-02-12 21:49:30 +01:00
Dmytro Hordinskyi
530f515556 Added "false" value to $columnPrefix type declaration. (#9493) 2022-02-09 09:40:16 +01:00
Alexander M. Turek
1c55025b12 PHPStan 1.4.6, Psalm 4.20.0 (#9491) 2022-02-09 00:42:34 +01:00
Steve
0900d4bc97 Fix #[DiscriminatorMap] params (#9487)
Fix `#[DiscriminatorMap]` params
2022-02-08 08:35:46 +00:00
Alexander M. Turek
be2518d784 Run tests with stricter error handling (#9482) 2022-02-07 22:08:34 +00:00
Alexander M. Turek
bdd8883d12 Run Postgres 14 and MariaDB 10.6 in CI (#9470) 2022-02-05 19:28:13 +01:00
Alexander M. Turek
536b65f02b PDO is not a required extension (#9457) 2022-02-01 14:13:50 +01:00
Alexander M. Turek
103c42cdb7 Check requirements for metadata drivers (#9452) 2022-02-01 13:48:03 +01:00
Grégoire Paris
cdaf7b5308 Remove trailing underscore (#9446)
It looks like there was confusion between the syntax for external links
and the syntax for internal links, which does not mention underscores.
See https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-doc
versus https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#external-links
2022-01-30 23:01:35 +00:00
Claudio Zizza
4b88ce787d Introduce __unserialize behaviour in docs (#9390)
* Introduce __unserialize behaviour in docs

* Mention deprecation of Serializable interface

* Add link to __unserialize method
2022-01-30 22:47:06 +01:00
Grégoire Paris
f9c3470a8d Adapt test logic to PHP and SQLite II (#9442)
In a88242ee6c, testDateSub() was modified
in order to satisfy different opinions to the question "What is now
minus one month", that has different answers for different pieces of
software on March 30th.

Today, we are January 30th, we need to do the same for testDateAdd().
Hopefully this is the last time we hear about this.
2022-01-30 17:48:10 +01:00
Grégoire Paris
c1b131b67e Merge pull request #9440 from sir-kain/php-8.1-ci
Added php 8.1 to CI
2022-01-30 09:55:04 +01:00
Grégoire Paris
16b82ea061 Use the identify generator strategy
It is a better default, and should fix tests for PostgreSQL
2022-01-29 11:33:13 +01:00
Waly
f8f370ace6 Added php 8.1 to CI 2022-01-28 22:55:25 +00:00
Alexander M. Turek
d5c69fb73f Psalm 4.19.0, PHPStan 1.4.3 (#9438) 2022-01-28 21:54:10 +00:00
Alexander M. Turek
93f9eb7af2 Ignore PHPUnit result cache everywhere (#9425) 2022-01-24 12:35:44 +01:00
HypeMC
6d5da83c68 Add support for PHP 8.1 enums in embedded classes (#9419) 2022-01-23 23:56:36 +01:00
jworman
5f01dd8d09 Added class-string typehint on $targetEntity (#9415) 2022-01-23 20:09:41 +01:00
Benjamin Cremer
b596e6a665 Allow DiscriminatorColumn with length=0 (#9410) 2022-01-21 10:27:29 +01:00
Alexander M. Turek
79d3cf5880 Move UnderscoreNamingStrategyTest to correct namespace (#9414) 2022-01-20 20:49:11 +01:00
Alexander M. Turek
d7b7c28ae5 Fix type on loadCacheEntry (#9398) 2022-01-18 22:49:52 +01:00
Alexander M. Turek
d6fd510c49 Update baselines for DBAL 3.3 (#9393) 2022-01-18 09:13:14 +01:00
olsavmic
a2a7d5bb01 Accessing private properties and methods from the same class is forbidden (#9311)
Resolves issue https://github.com/doctrine/common/issues/934

Update docs/en/cookbook/accessing-private-properties-of-the-same-class-from-different-instance.rst

Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com>

Update docs/en/cookbook/accessing-private-properties-of-the-same-class-from-different-instance.rst

Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com>

Fix review issues
2022-01-17 23:15:31 +01:00
Vadim Borodavko
223b2650c4 Expose enumType to DBAL to make native DB Enum possible (#9382) 2022-01-17 10:39:16 +01:00
Vadim Borodavko
01c1644d9c Allow using Enum from different namespace than Entity (#9384) 2022-01-16 13:08:30 +01:00
Sukhdev Mohan
3eff2d4b3f Corrected ORM version and added missing dependency (#9386)
* Corrected ORM version and added missing dependency

Noticed that the version wasn't updated, pointing to 2.11.0 instead of 2.10.2. 
Also when following this tutotial ran into missing dependency for "doctrine/annotation" so added that too.

* Tutorial: Bump DBAL, YAML and Cache

Co-authored-by: Alexander M. Turek <me@derrabus.de>
2022-01-16 02:28:30 +01:00
Alexander M. Turek
9ddf8b96f8 PHPStan 1.4.0 (#9385) 2022-01-16 01:22:41 +01:00
Benjamin Eberlei
3d00fa817a [GH-9380] Bugfix: Delegate ReflectionEnumProperty::getAttributes(). (#9381)
* [GH-9380] Bugfix: Delegate ReflectionEnumProperty::getAttributes().

* [GH-9380] Add test for retrieving attributes via enum property.

* [GH-9380] Add test for retrieving attributes via enum property.

* [GH-9380] Call parent ReflectionProperty ctor for best behavior.

* Update tests/Doctrine/Tests/ORM/Functional/EnumTest.php

Co-authored-by: Grégoire Paris <postmaster@greg0ire.fr>

Co-authored-by: Grégoire Paris <postmaster@greg0ire.fr>
2022-01-16 00:06:59 +01:00
Andrii Dembitskyi
c0a1404e4c Add detach as of list cascade-all operations (#9357) 2022-01-12 22:33:11 +01:00
145 changed files with 1176 additions and 1140 deletions

View File

@@ -30,7 +30,7 @@ jobs:
- php-version: "8.0"
dbal-version: "2.13"
- php-version: "8.1"
dbal-version: "3.2@dev"
dbal-version: "3@dev"
steps:
- name: "Checkout"
@@ -78,16 +78,16 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"
dbal-version:
- "default"
postgres-version:
- "9.6"
- "13"
- "14"
include:
- php-version: "8.0"
dbal-version: "2.13"
postgres-version: "13"
postgres-version: "14"
services:
postgres:
@@ -139,18 +139,18 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"
dbal-version:
- "default"
mariadb-version:
- "10.5"
- "10.6"
extension:
- "mysqli"
- "pdo_mysql"
include:
- php-version: "8.0"
dbal-version: "2.13"
mariadb-version: "10.5"
mariadb-version: "10.6"
extension: "pdo_mysql"
services:
@@ -205,7 +205,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"
dbal-version:
- "default"
mysql-version:

2
.gitignore vendored
View File

@@ -15,5 +15,5 @@ vendor/
/tests/Doctrine/Performance/history.db
/.phpcs-cache
composer.lock
/.phpunit.result.cache
.phpunit.result.cache
/*.phpunit.xml

View File

@@ -37,8 +37,7 @@ will have to run a composer installation in the project:
```sh
git clone git@github.com:doctrine/orm.git
cd orm
curl -sS https://getcomposer.org/installer | php --
./composer.phar install
composer install
```
To run the testsuite against another database, copy the ``phpunit.xml.dist``

View File

@@ -3,6 +3,8 @@
| [![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] |
[<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
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),
@@ -13,7 +15,7 @@ without requiring unnecessary code duplication.
## More resources:
* [Website](http://www.doctrine-project.org)
* [Documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/latest/index.html)
* [Documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/stable/index.html)
[3.0 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0.x

View File

@@ -10,8 +10,8 @@ we cannot protect you from SQL injection.
Please read the documentation chapter on Security in Doctrine DBAL and ORM to
understand the assumptions we make.
- [DBAL Security Page](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/security.html)
- [ORM Security Page](https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/security.html)
- [DBAL Security Page](https://www.doctrine-project.org/projects/doctrine-dbal/en/stable/reference/security.html)
- [ORM Security Page](https://www.doctrine-project.org/projects/doctrine-orm/en/stable/reference/security.html)
If you find a Security bug in Doctrine, please report it on Jira and change the
Security Level to "Security Issues". It will be visible to Doctrine Core

View File

@@ -289,8 +289,8 @@ If you would still like to perform batching operations over small `UnitOfWork`
instances, it is suggested to follow these paths instead:
* eagerly use `EntityManager#clear()` in conjunction with a specific second level
cache configuration (see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/second-level-cache.html)
* use an explicit change tracking policy (see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/change-tracking-policies.html)
cache configuration (see http://docs.doctrine-project.org/projects/doctrine-orm/en/stable/reference/second-level-cache.html)
* use an explicit change tracking policy (see http://docs.doctrine-project.org/projects/doctrine-orm/en/stable/reference/change-tracking-policies.html)
## Deprecated `YAML` mapping drivers.

View File

@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />
<var name="db_driver" value="mysqli"/>
<var name="db_host" value="127.0.0.1" />
<var name="db_port" value="3306"/>

View File

@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />
<var name="db_driver" value="pdo_mysql"/>
<var name="db_host" value="127.0.0.1" />
<var name="db_port" value="3306"/>

View File

@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />
<var name="db_driver" value="pdo_pgsql"/>
<var name="db_host" value="localhost" />
<var name="db_user" value="postgres" />

View File

@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />
<!-- use an in-memory sqlite database -->
<var name="db_driver" value="pdo_sqlite"/>
<var name="db_memory" value="true"/>

View File

@@ -23,7 +23,6 @@
"php": "^7.1 || ^8.0",
"composer-runtime-api": "^2",
"ext-ctype": "*",
"ext-pdo": "*",
"doctrine/cache": "^1.12.1 || ^2.1.1",
"doctrine/collections": "^1.5",
"doctrine/common": "^3.0.3",
@@ -43,12 +42,12 @@
"doctrine/annotations": "^1.13",
"doctrine/coding-standard": "^9.0",
"phpbench/phpbench": "^0.16.10 || ^1.0",
"phpstan/phpstan": "1.3.3",
"phpstan/phpstan": "~1.4.10 || 1.5.0",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
"squizlabs/php_codesniffer": "3.6.2",
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"vimeo/psalm": "4.18.1"
"vimeo/psalm": "4.22.0"
},
"conflict": {
"doctrine/annotations": "<1.13 || >= 2.0"

View File

@@ -1,201 +0,0 @@
# -*- coding: utf-8 -*-
#
# Doctrine 2 ORM documentation build configuration file, created by
# sphinx-quickstart on Fri Dec 3 18:10:24 2010.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os, datetime
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.append(os.path.abspath('_exts'))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['configurationblock']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Doctrine 2 ORM'
copyright = u'2010-%y, Doctrine Project Team'.format(datetime.date.today)
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2'
# The full version, including alpha/beta/rc tags.
release = '2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
language = 'en'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
show_authors = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'doctrine'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['_theme']
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'Doctrine2ORMdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Doctrine2ORM.tex', u'Doctrine 2 ORM Documentation',
u'Doctrine Project Team', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
primary_domain = "dcorm"
def linkcode_resolve(domain, info):
if domain == 'dcorm':
return 'http://'
return None

View File

@@ -0,0 +1,74 @@
Accessing private/protected properties/methods of the same class from different instance
========================================================================================
.. sectionauthor:: Michael Olsavsky (olsavmic)
As explained in the :doc:`restrictions for entity classes in the manual <../reference/architecture>`,
it is dangerous to access private/protected properties of different entity instance of the same class because of lazy loading.
The proxy instance that's injected instead of the real entity may not be initialized yet
and therefore not contain expected data which may result in unexpected behavior.
That's a limitation of current proxy implementation - only public methods automatically initialize proxies.
It is usually preferable to use a public interface to manipulate the object from outside the `$this`
context but it may not be convenient in some cases. The following example shows how to do it safely.
Safely accessing private properties from different instance of the same class
-----------------------------------------------------------------------------
To safely access private property of different instance of the same class, make sure to initialise
the proxy before use manually as follows:
.. code-block:: php
<?php
use Doctrine\Common\Proxy\Proxy;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class Entity
{
// ...
/**
* @ORM\ManyToOne(targetEntity="Entity")
* @ORM\JoinColumn(nullable=false)
*/
private self $parent;
/**
* @ORM\Column(type="string", nullable=false)
*/
private string $name;
// ...
public function doSomethingWithParent()
{
// Always initializing the proxy before use
if ($this->parent instanceof Proxy) {
$this->parent->__load();
}
// Accessing the `$this->parent->name` property without loading the proxy first
// may throw error in case the Proxy has not been initialized yet.
$this->parent->name;
}
public function doSomethingWithAnotherInstance(self $instance)
{
// Always initializing the proxy before use
if ($instance instanceof Proxy) {
$instance->__load();
}
// Accessing the `$instance->name` property without loading the proxy first
// may throw error in case the Proxy has not been initialized yet.
$instance->name;
}
// ...
}

View File

@@ -131,8 +131,8 @@ generation of a DateDiff FunctionNode somewhere in the AST of the
dql statement.
The ``ArithmeticPrimary`` method call is the most common
denominator of valid EBNF tokens taken from the
`DQL EBNF grammar <https://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#ebnf>`_
denominator of valid EBNF tokens taken from the :ref:`DQL EBNF grammar
<dql_ebnf_grammar>`
that matches our requirements for valid input into the DateDiff Dql
function. Picking the right tokens for your methods is a tricky
business, but the EBNF grammar is pretty helpful finding it, as is

View File

@@ -3,8 +3,8 @@ Implementing Wakeup or Clone
.. sectionauthor:: Roman Borschel (roman@code-factory.org)
As explained in the
`restrictions for entity classes in the manual <https://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/architecture.html#entities>`_,
As explained in the :ref:`restrictions for entity classes in the manual
<terminology_entities>`,
it is usually not allowed for an entity to implement ``__wakeup``
or ``__clone``, because Doctrine makes special use of them.
However, it is quite easy to make use of these methods in a safe

View File

@@ -195,10 +195,7 @@ SQL Logger (***Optional***)
Gets or sets the logger to use for logging all SQL statements
executed by Doctrine. The logger class must implement the
``Doctrine\DBAL\Logging\SQLLogger`` interface. A simple default
implementation that logs to the standard output using ``echo`` and
``var_dump`` can be found at
``Doctrine\DBAL\Logging\EchoSQLLogger``.
deprecated ``Doctrine\DBAL\Logging\SQLLogger`` interface.
Auto-generating Proxy Classes (***OPTIONAL***)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -66,6 +66,8 @@ The root namespace of the ORM package is ``Doctrine\ORM``.
Terminology
-----------
.. _terminology_entities:
Entities
~~~~~~~~
@@ -82,9 +84,13 @@ be any regular PHP class observing the following restrictions:
:doc:`do so safely <../cookbook/implementing-wakeup-or-clone>`.
- An entity class must not implement ``__wakeup`` or
:doc:`do so safely <../cookbook/implementing-wakeup-or-clone>`.
Also consider implementing
`Serializable <https://php.net/manual/en/class.serializable.php>`_
instead.
You can also consider implementing
`Serializable <https://php.net/manual/en/class.serializable.php>`_,
but be aware that it is deprecated since PHP 8.1. We do not recommend its usage.
- PHP 7.4 introduces :doc:`the new magic method <https://php.net/manual/en/language.oop5.magic.php#object.unserialize>`
``__unserialize``, which changes the execution priority between
``__wakeup`` and itself when used. This can cause unexpected behaviour in
an Entity.
- Any two entity classes in a class hierarchy that inherit
directly or indirectly from one another must not have a mapped
property with the same name. That is, if B inherits from A then B
@@ -93,6 +99,7 @@ be any regular PHP class observing the following restrictions:
- An entity cannot make use of func_get_args() to implement variable parameters.
Generated proxies do not support this for performance reasons and your code might
actually fail to work when violating this restriction.
- Entity cannot access private/protected properties/methods of another entity of the same class or :doc:`do so safely <../cookbook/accessing-private-properties-of-the-same-class-from-different-instance>`.
Entities support inheritance, polymorphic associations, and
polymorphic queries. Both abstract and concrete classes can be
@@ -161,7 +168,8 @@ possible for ``__sleep`` to return names of private properties in
parent classes. On the other hand it is not a solution for proxy
objects to implement ``Serializable`` because Serializable does not
work well with any potential cyclic object references (at least we
did not find a way yet, if you did, please contact us).
did not find a way yet, if you did, please contact us). The
``Serializable`` interface is also deprecated beginning with PHP 8.1.
The EntityManager
~~~~~~~~~~~~~~~~~

View File

@@ -570,7 +570,7 @@ Example with partial indexes:
<?php
use Doctrine\ORM\Mapping\Index;
#[Index(name: "search_idx", columns: {"category"},
#[Index(name: "search_idx", columns: ["category"],
options: [
"where": "((category IS NOT NULL))"
]
@@ -628,7 +628,7 @@ Examples:
#[Entity]
#[InheritanceType("SINGLE_TABLE")]
#[DiscriminatorColumn(name: "discr", type: "string")]
#[DiscriminatorMap({"person" = "Person", "employee" = "Employee"})]
#[DiscriminatorMap(["person" => "Person", "employee" => "Employee"])]
class Person
{
// ...
@@ -637,7 +637,7 @@ Examples:
#[Entity]
#[InheritanceType("JOINED")]
#[DiscriminatorColumn(name: "discr", type: "string")]
#[DiscriminatorMap({"person" = "Person", "employee" = "Employee"})]
#[DiscriminatorMap(["person" => "Person", "employee" => "Employee"])]
class Person
{
// ...

View File

@@ -14,17 +14,11 @@ After working through this guide you should know:
Mapping of associations will be covered in the next chapter on
:doc:`Association Mapping <association-mapping>`.
Guide Assumptions
-----------------
You should have already :doc:`installed and configure <configuration>`
Doctrine.
Creating Classes for the Database
---------------------------------
Every PHP object that you want to save in the database using Doctrine
is called an "Entity". The term "Entity" describes objects
is called an *Entity*. The term "Entity" describes objects
that have an identity over many independent requests. This identity is
usually achieved by assigning a unique identifier to an entity.
In this tutorial the following ``Message`` PHP class will serve as the
@@ -50,11 +44,11 @@ that describes your entity.
Doctrine provides several different ways to specify object-relational
mapping metadata:
- :doc:`Docblock Annotations <annotations-reference>`
- :doc:`Attributes <attributes-reference>`
- :doc:`Docblock Annotations <annotations-reference>`
- :doc:`XML <xml-mapping>`
- :doc:`YAML <yaml-mapping>`
- :doc:`PHP code <php-mapping>`
- :doc:`YAML <yaml-mapping>` (deprecated and will be removed in ``doctrine/orm`` 3.0.)
This manual will usually show mapping metadata via docblock annotations, though
many examples also show the equivalent configuration in YAML and XML.
@@ -62,8 +56,8 @@ many examples also show the equivalent configuration in YAML and XML.
.. note::
All metadata drivers perform equally. Once the metadata of a class has been
read from the source (annotations, xml or yaml) it is stored in an instance
of the ``Doctrine\ORM\Mapping\ClassMetadata`` class and these instances are
read from the source (attributes, annotations, XML, etc.) it is stored in an instance
of the ``Doctrine\ORM\Mapping\ClassMetadata`` class which are
stored in the metadata cache. If you're not using a metadata cache (not
recommended!) then the XML driver is the fastest.
@@ -71,9 +65,22 @@ Marking our ``Message`` class as an entity for Doctrine is straightforward:
.. configuration-block::
.. code-block:: php
.. code-block:: attribute
<?php
use Doctrine\ORM\Mapping\Entity;
#[Entity]
class Message
{
// ...
}
.. code-block:: annotation
<?php
use Doctrine\ORM\Mapping\Entity;
/** @Entity */
class Message
{
@@ -100,9 +107,25 @@ You can change this by configuring information about the table:
.. configuration-block::
.. code-block:: php
.. code-block:: attribute
<?php
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
#[Entity]
#[Table(name: 'message')]
class Message
{
// ...
}
.. code-block:: annotation
<?php
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
/**
* @Entity
* @Table(name="message")
@@ -132,19 +155,38 @@ Now the class ``Message`` will be saved and fetched from the table ``message``.
Property Mapping
----------------
The next step after marking a PHP class as an entity is mapping its properties
to columns in a table.
The next step is mapping its properties to columns in the table.
To configure a property use the ``@Column`` docblock annotation. The ``type``
To configure a property use the ``Column`` docblock annotation. The ``type``
attribute specifies the :ref:`Doctrine Mapping Type <reference-mapping-types>`
to use for the field. If the type is not specified, ``string`` is used as the
default.
.. configuration-block::
.. code-block:: php
.. code-block:: attribute
<?php
use Doctrine\ORM\Mapping\Column;
use Doctrine\DBAL\Types\Types;
#[Entity]
class Message
{
#[Column(type: Types::INTEGER)]
private $id;
#[Column(length: 140)]
private $text;
#[Column(name: 'posted_at', type: Types::DATETIME)]
private $postedAt;
}
.. code-block:: annotation
<?php
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Column;
/** @Entity */
class Message
{
@@ -180,42 +222,34 @@ default.
column: posted_at
When we don't explicitly specify a column name via the ``name`` option, Doctrine
assumes the field name is also the column name. This means that:
assumes the field name is also the column name. So in this example:
* the ``id`` property will map to the column ``id`` using the type ``integer``;
* the ``text`` property will map to the column ``text`` with the default mapping type ``string``;
* the ``postedAt`` property will map to the ``posted_at`` column with the ``datetime`` type.
The Column annotation has some more attributes. Here is a complete
list:
Here is a complete list of ``Column``s attributes (all optional):
- ``type``: (optional, defaults to 'string') The mapping type to
use for the column.
- ``name``: (optional, defaults to field name) The name of the
column in the database.
- ``length``: (optional, default 255) The length of the column in
the database. (Applies only if a string-valued column is used).
- ``unique``: (optional, default FALSE) Whether the column is a
unique key.
- ``nullable``: (optional, default FALSE) Whether the database
column is nullable.
- ``insertable``: (optional, default TRUE) Whether the database
column should be inserted.
- ``updatable``: (optional, default TRUE) Whether the database
column should be updated.
- ``enumType``: (optional, requires PHP 8.1 and ORM 2.11) The PHP enum type
name to convert the database value into.
- ``precision``: (optional, default 0) The precision for a decimal
(exact numeric) column (applies only for decimal column),
- ``type`` (default: 'string'): The mapping type to use for the column.
- ``name`` (default: name of property): The name of the column in the database.
- ``length`` (default: 255): The length of the column in the database.
Applies only if a string-valued column is used.
- ``unique`` (default: ``false``): Whether the column is a unique key.
- ``nullable`` (default: ``false``): Whether the column is nullable.
- ``insertable`` (default: ``true``): Whether the column should be inserted.
- ``updatable`` (default: ``true``): Whether the column should be updated.
- ``enumType`` (requires PHP 8.1 and ``doctrine/orm`` 2.11): The PHP enum class name to convert the database value into.
- ``precision`` (default: 0): The precision for a decimal (exact numeric) column
(applies only for decimal column),
which is the maximum number of digits that are stored for the values.
- ``scale``: (optional, default 0) The scale for a decimal (exact
- ``scale`` (default: 0): The scale for a decimal (exact
numeric) column (applies only for decimal column), which represents
the number of digits to the right of the decimal point and must
not be greater than *precision*.
- ``columnDefinition``: (optional) Allows to define a custom
not be greater than ``precision``.
- ``columnDefinition``: Allows to define a custom
DDL snippet that is used to create the column. Warning: This normally
confuses the SchemaTool to always detect the column as changed.
- ``options``: (optional) Key-value pairs of options that get passed
confuses the :doc:`SchemaTool <tools>` to always detect the column as changed.
- ``options``: Key-value pairs of options that get passed
to the underlying database platform when generating DDL statements.
.. _reference-php-mapping-types:
@@ -223,21 +257,32 @@ list:
PHP Types Mapping
_________________
Since version 2.9 Doctrine can determine usable defaults from property types
on entity classes. When property type is nullable this has no effect on
``nullable`` Column attribute at the moment for backwards compatibility
reasons.
.. versionadded:: 2.9
Additionally, Doctrine will map PHP types to ``type`` attribute as follows:
The column types can be inferred automatically from PHP's property types.
However, when the property type is nullable this has no effect on the ``nullable`` Column attribute.
- ``DateInterval``: ``dateinterval``
- ``DateTime``: ``datetime``
- ``DateTimeImmutable``: ``datetime_immutable``
- ``array``: ``json``
- ``bool``: ``boolean``
- ``float``: ``float``
- ``int``: ``integer``
- ``string`` or any other type: ``string``
These are the "automatic" mapping rules:
+-----------------------+-------------------------------+
| PHP property type | Doctrine column type |
+=======================+===============================+
| ``DateInterval`` | ``Types::DATEINTERVAL`` |
+-----------------------+-------------------------------+
| ``DateTime`` | ``Types::DATETIME_MUTABLE`` |
+-----------------------+-------------------------------+
| ``DateTimeImmutable`` | ``Types::DATETIME_IMMUTABLE`` |
+-----------------------+-------------------------------+
| ``array`` | ``Types::JSON`` |
+-----------------------+-------------------------------+
| ``bool`` | ``Types::BOOLEAN`` |
+-----------------------+-------------------------------+
| ``float`` | ``Types::FLOAT`` |
+-----------------------+-------------------------------+
| ``int`` | ``Types::INTEGER`` |
+-----------------------+-------------------------------+
| Any other type | ``Types::STRING`` |
+-----------------------+-------------------------------+
As of version 2.11 Doctrine can also automatically map typed properties using a
PHP 8.1 enum to set the right ``type`` and ``enumType``.

View File

@@ -95,7 +95,7 @@ If you want to configure Doctrine in more detail, take a look at the :doc:`Advan
.. note::
You can learn more about the database connection configuration in the
`Doctrine DBAL connection configuration reference <https://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html>`_.
`Doctrine DBAL connection configuration reference <https://docs.doctrine-project.org/projects/doctrine-dbal/en/stable/reference/configuration.html>`_.
Setting up the Commandline Tool
-------------------------------

View File

@@ -1531,6 +1531,8 @@ Given that there are 10 users and corresponding addresses in the database the ex
a one-by-one basis once they are accessed.
.. _dql_ebnf_grammar:
EBNF
----

View File

@@ -142,33 +142,33 @@ Events Overview
| Event | Dispatched by | Lifecycle | Passed |
| | | Callback | Argument |
+=================================================================+=======================+===========+=====================================+
| :ref:`preRemove<reference-events-pre-remove>` | ``$em->remove()`` | Yes | `_LifecycleEventArgs`_ |
| :ref:`preRemove<reference-events-pre-remove>` | ``$em->remove()`` | Yes | `LifecycleEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`postRemove<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
| :ref:`postRemove<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `LifecycleEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`prePersist<reference-events-pre-persist>` | ``$em->persist()`` | Yes | `_LifecycleEventArgs`_ |
| :ref:`prePersist<reference-events-pre-persist>` | ``$em->persist()`` | Yes | `LifecycleEventArgs`_ |
| | on *initial* persist | | |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`postPersist<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
| :ref:`postPersist<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `LifecycleEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`preUpdate<reference-events-pre-update>` | ``$em->flush()`` | Yes | `_PreUpdateEventArgs`_ |
| :ref:`preUpdate<reference-events-pre-update>` | ``$em->flush()`` | Yes | `PreUpdateEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`postUpdate<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
| :ref:`postUpdate<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `LifecycleEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`postLoad<reference-events-post-load>` | Loading from database | Yes | `_LifecycleEventArgs`_ |
| :ref:`postLoad<reference-events-post-load>` | Loading from database | Yes | `LifecycleEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`loadClassMetadata<reference-events-load-class-metadata>` | Loading of mapping | No | `_LoadClassMetadataEventArgs` |
| :ref:`loadClassMetadata<reference-events-load-class-metadata>` | Loading of mapping | No | `LoadClassMetadataEventArgs`_ |
| | metadata | | |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| ``onClassMetadataNotFound`` | ``MappingException`` | No | `_OnClassMetadataNotFoundEventArgs` |
| ``onClassMetadataNotFound`` | ``MappingException`` | No | `OnClassMetadataNotFoundEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`preFlush<reference-events-pre-flush>` | ``$em->flush()`` | Yes | `_PreFlushEventArgs`_ |
| :ref:`preFlush<reference-events-pre-flush>` | ``$em->flush()`` | Yes | `PreFlushEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`onFlush<reference-events-on-flush>` | ``$em->flush()`` | No | `_OnFlushEventArgs` |
| :ref:`onFlush<reference-events-on-flush>` | ``$em->flush()`` | No | `OnFlushEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`postFlush<reference-events-post-flush>` | ``$em->flush()`` | No | `_PostFlushEventArgs` |
| :ref:`postFlush<reference-events-post-flush>` | ``$em->flush()`` | No | `PostFlushEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
| :ref:`onClear<reference-events-on-clear>` | ``$em->clear()`` | No | `_OnClearEventArgs` |
| :ref:`onClear<reference-events-on-clear>` | ``$em->clear()`` | No | `OnClearEventArgs`_ |
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
Naming convention

View File

@@ -13,7 +13,7 @@ as you want, or just pick a preferred one.
The ``QueryBuilder`` is not an abstraction of DQL, but merely a tool to dynamically build it.
You should still use plain DQL when you can, as it is simpler and more readable.
More about this in the :doc:`FAQ <faq>`_.
More about this in the :doc:`FAQ <faq>`.
Constructing a new QueryBuilder object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -694,6 +694,7 @@ specified by their respective tags:
- ``<cascade-merge />``
- ``<cascade-remove />``
- ``<cascade-refresh />``
- ``<cascade-detach />``
Join Column Element
~~~~~~~~~~~~~~~~~~~

View File

@@ -81,10 +81,11 @@ that directory with the following contents:
{
"require": {
"doctrine/orm": "^2.10.2",
"doctrine/dbal": "^3.1.1",
"symfony/yaml": "2.*",
"symfony/cache": "^5.3"
"doctrine/orm": "^2.11.0",
"doctrine/dbal": "^3.2",
"doctrine/annotations": "1.13.2",
"symfony/yaml": "^5.4",
"symfony/cache": "^5.4"
},
"autoload": {
"psr-0": {"": "src/"}

View File

@@ -371,11 +371,11 @@ abstract class AbstractQuery
/**
* Sets a query parameter.
*
* @param string|int $key The parameter position or name.
* @param mixed $value The parameter value.
* @param string|null $type The parameter type. If specified, the given value will be run through
* the type conversion of this type. This is usually not needed for
* strings and numeric types.
* @param string|int $key The parameter position or name.
* @param mixed $value The parameter value.
* @param string|int|null $type The parameter type. If specified, the given value will be run through
* the type conversion of this type. This is usually not needed for
* strings and numeric types.
*
* @return $this
*/

View File

@@ -24,7 +24,7 @@ interface EntityHydrator
* @param ClassMetadata $metadata The entity metadata.
* @param EntityCacheKey $key The entity cache key.
* @param EntityCacheEntry $entry The entity cache entry.
* @param object $entity The entity to load the cache into. If not specified, a new entity is created.
* @param object|null $entity The entity to load the cache into. If not specified, a new entity is created.
*
* @return object|null
*/

View File

@@ -39,11 +39,13 @@ use Doctrine\ORM\Repository\DefaultRepositoryFactory;
use Doctrine\ORM\Repository\RepositoryFactory;
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Persistence\ObjectRepository;
use LogicException;
use Psr\Cache\CacheItemPoolInterface;
use ReflectionClass;
use function class_exists;
use function method_exists;
use function sprintf;
use function strtolower;
use function trim;
@@ -162,6 +164,14 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/
public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true)
{
if (! class_exists(AnnotationReader::class)) {
throw new LogicException(sprintf(
'The annotation metadata driver cannot be enabled because the "doctrine/annotations" library'
. ' is not installed. Please run "composer require doctrine/annotations" or choose a different'
. ' metadata driver.'
));
}
AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
if ($useSimpleAnnotationReader) {

View File

@@ -17,6 +17,7 @@ use Doctrine\ORM\Exception\InvalidHydrationMode;
use Doctrine\ORM\Exception\MismatchedEventManager;
use Doctrine\ORM\Exception\MissingIdentifierField;
use Doctrine\ORM\Exception\MissingMappingDriverImplementation;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Exception\UnrecognizedIdentifierFields;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataFactory;
@@ -59,7 +60,7 @@ use function sprintf;
* $entityManager = EntityManager::create($dbParams, $config);
*
* For more information see
* {@link http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html}
* {@link http://docs.doctrine-project.org/projects/doctrine-orm/en/stable/reference/configuration.html}
*
* You should never attempt to inherit from the EntityManager: Inheritance
* is not a valid extension point for the EntityManager. Instead you
@@ -778,7 +779,7 @@ use function sprintf;
* @return ObjectRepository|EntityRepository The repository class.
* @psalm-return EntityRepository<T>
*
* @template T
* @template T of object
*/
public function getRepository($entityName)
{

View File

@@ -9,6 +9,7 @@ use DateTimeInterface;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
use Doctrine\ORM\Proxy\ProxyFactory;
use Doctrine\ORM\Query\Expr;
@@ -31,7 +32,7 @@ interface EntityManagerInterface extends ObjectManager
*
* @psalm-return EntityRepository<T>
*
* @template T
* @template T of object
*/
public function getRepository($className);

View File

@@ -30,7 +30,7 @@ use function substr;
* This class is designed for inheritance and users can subclass this class to
* write their own repositories with business-specific methods to locate entities.
*
* @template T
* @template T of object
* @template-implements Selectable<int,T>
* @template-implements ObjectRepository<T>
*/

View File

@@ -7,6 +7,7 @@ namespace Doctrine\ORM\Internal\Hydration;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\ORM\Exception\MultipleSelectorsFoundException;
use function array_column;
use function count;
/**
@@ -26,12 +27,8 @@ final class ScalarColumnHydrator extends AbstractHydrator
throw MultipleSelectorsFoundException::create($this->resultSetMapping()->fieldMappings);
}
$result = [];
$result = $this->statement()->fetchAllNumeric();
while ($row = $this->statement()->fetchOne()) {
$result[] = $row;
}
return $result;
return array_column($result, 0);
}
}

View File

@@ -59,9 +59,9 @@ class ClassMetadataBuilder
/**
* Adds and embedded class
*
* @param string $fieldName
* @param string $class
* @param string|null $columnPrefix
* @param string $fieldName
* @param string $class
* @param string|false|null $columnPrefix
*
* @return $this
*/

View File

@@ -1056,9 +1056,19 @@ class ClassMetadataInfo implements ClassMetadata
foreach ($this->fieldMappings as $field => $mapping) {
if (isset($mapping['declaredField']) && isset($parentReflFields[$mapping['declaredField']])) {
$childProperty = $this->getAccessibleProperty($reflService, $mapping['originalClass'], $mapping['originalField']);
assert($childProperty !== null);
if (isset($mapping['enumType'])) {
$childProperty = new ReflectionEnumProperty(
$childProperty,
$mapping['enumType']
);
}
$this->reflFields[$field] = new ReflectionEmbeddedProperty(
$parentReflFields[$mapping['declaredField']],
$this->getAccessibleProperty($reflService, $mapping['originalClass'], $mapping['originalField']),
$childProperty,
$mapping['originalClass']
);
continue;
@@ -1517,7 +1527,7 @@ class ClassMetadataInfo implements ClassMetadata
! isset($mapping['type'])
&& ($type instanceof ReflectionNamedType)
) {
if (PHP_VERSION_ID >= 80100 && ! $type->isBuiltin() && enum_exists($type->getName(), false)) {
if (PHP_VERSION_ID >= 80100 && ! $type->isBuiltin() && enum_exists($type->getName())) {
$mapping['enumType'] = $type->getName();
$reflection = new ReflectionEnum($type->getName());

View File

@@ -15,13 +15,13 @@ use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
#[Attribute(Attribute::TARGET_CLASS)]
final class DiscriminatorColumn implements Annotation
{
/** @var string */
/** @var string|null */
public $name;
/** @var string */
/** @var string|null */
public $type;
/** @var int */
/** @var int|null */
public $length;
/**

View File

@@ -281,7 +281,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
[
'name' => $discrColumnAnnot->name,
'type' => $discrColumnAnnot->type ?: 'string',
'length' => $discrColumnAnnot->length ?: 255,
'length' => $discrColumnAnnot->length ?? 255,
'columnDefinition' => $discrColumnAnnot->columnDefinition,
]
);

View File

@@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\Driver\AnnotationDriver;
use LogicException;
use ReflectionClass;
use ReflectionMethod;
use ReflectionProperty;
@@ -20,6 +21,9 @@ use function class_exists;
use function constant;
use function defined;
use function get_class;
use function sprintf;
use const PHP_VERSION_ID;
class AttributeDriver extends AnnotationDriver
{
@@ -35,6 +39,13 @@ class AttributeDriver extends AnnotationDriver
*/
public function __construct(array $paths)
{
if (PHP_VERSION_ID < 80000) {
throw new LogicException(sprintf(
'The attribute metadata driver cannot be enabled on PHP 7. Please upgrade to PHP 8 or choose a different'
. ' metadata driver.'
));
}
parent::__construct(new AttributeReader(), $paths);
}

View File

@@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\Driver\FileDriver;
use InvalidArgumentException;
use LogicException;
use SimpleXMLElement;
use function assert;
@@ -18,6 +19,7 @@ use function constant;
use function count;
use function defined;
use function explode;
use function extension_loaded;
use function file_get_contents;
use function in_array;
use function simplexml_load_string;
@@ -39,6 +41,13 @@ class XmlDriver extends FileDriver
*/
public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENSION)
{
if (! extension_loaded('simplexml')) {
throw new LogicException(sprintf(
'The XML metadata driver cannot be enabled because the SimpleXML PHP extension is missing.'
. ' Please configure PHP with SimpleXML or choose a different metadata driver.'
));
}
parent::__construct($locator, $fileExtension);
}

View File

@@ -11,9 +11,11 @@ use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\Driver\FileDriver;
use InvalidArgumentException;
use LogicException;
use Symfony\Component\Yaml\Yaml;
use function array_map;
use function class_exists;
use function constant;
use function defined;
use function explode;
@@ -45,6 +47,14 @@ class YamlDriver extends FileDriver
'YAML mapping driver is deprecated and will be removed in Doctrine ORM 3.0, please migrate to attribute or XML driver.'
);
if (! class_exists(Yaml::class)) {
throw new LogicException(sprintf(
'The YAML metadata driver cannot be enabled because the "symfony/yaml" library'
. ' is not installed. Please run "composer require symfony/yaml" or choose a different'
. ' metadata driver.'
));
}
parent::__construct($locator, $fileExtension);
}

View File

@@ -31,10 +31,10 @@ final class Index implements Annotation
public $options;
/**
* @param array<string>|null $columns
* @param array<string>|null $fields
* @param array<string>|null $flags
* @param array<string>|null $options
* @param array<string>|null $columns
* @param array<string>|null $fields
* @param array<string>|null $flags
* @param array<string,mixed>|null $options
*/
public function __construct(
?array $columns = null,

View File

@@ -16,7 +16,7 @@ use Doctrine\Deprecations\Deprecation;
#[Attribute(Attribute::TARGET_PROPERTY)]
final class ManyToMany implements Annotation
{
/** @var string|null */
/** @var class-string|null */
public $targetEntity;
/** @var string|null */
@@ -43,7 +43,8 @@ final class ManyToMany implements Annotation
public $indexBy;
/**
* @param string[]|null $cascade
* @param class-string|null $targetEntity
* @param string[]|null $cascade
*/
public function __construct(
?string $targetEntity = null,

View File

@@ -15,7 +15,7 @@ use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
#[Attribute(Attribute::TARGET_PROPERTY)]
final class ManyToOne implements Annotation
{
/** @var string|null */
/** @var class-string|null */
public $targetEntity;
/** @var string[]|null */
@@ -33,7 +33,8 @@ final class ManyToOne implements Annotation
public $inversedBy;
/**
* @param string[]|null $cascade
* @param class-string|null $targetEntity
* @param string[]|null $cascade
*/
public function __construct(
?string $targetEntity = null,

View File

@@ -18,7 +18,7 @@ final class OneToMany implements Annotation
/** @var string */
public $mappedBy;
/** @var string */
/** @var class-string|null */
public $targetEntity;
/** @var array<string> */
@@ -39,7 +39,8 @@ final class OneToMany implements Annotation
public $indexBy;
/**
* @param string[]|null $cascade
* @param class-string|null $targetEntity
* @param string[]|null $cascade
*/
public function __construct(
?string $mappedBy = null,

View File

@@ -15,7 +15,7 @@ use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
#[Attribute(Attribute::TARGET_PROPERTY)]
final class OneToOne implements Annotation
{
/** @var string|null */
/** @var class-string|null */
public $targetEntity;
/** @var string|null */
@@ -39,6 +39,7 @@ final class OneToOne implements Annotation
public $orphanRemoval = false;
/**
* @param class-string|null $targetEntity
* @param array<string>|null $cascade
*/
public function __construct(

View File

@@ -29,6 +29,11 @@ class ReflectionEnumProperty extends ReflectionProperty
{
$this->originalReflectionProperty = $originalReflectionProperty;
$this->enumType = $enumType;
parent::__construct(
$originalReflectionProperty->getDeclaringClass()->getName(),
$originalReflectionProperty->getName()
);
}
/**

View File

@@ -481,6 +481,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
/**
* {@inheritdoc}
*/
#[ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->get($offset);

View File

@@ -4,11 +4,6 @@ declare(strict_types=1);
namespace Doctrine\ORM\Query\AST;
/**
* Description of AggregateExpression.
*
* @link www.doctrine-project.org
*/
class AggregateExpression extends Node
{
/** @var string */

View File

@@ -10,11 +10,6 @@ use function is_numeric;
use function strlen;
use function substr;
/**
* Description of InputParameter.
*
* @link www.doctrine-project.org
*/
class InputParameter extends Node
{
/** @var bool */

View File

@@ -97,8 +97,7 @@ class FilterCollection
// Keep the enabled filters sorted for the hash
ksort($this->enabledFilters);
// Now the filter collection is dirty
$this->filtersState = self::FILTERS_STATE_DIRTY;
$this->setFiltersStateDirty();
}
return $this->enabledFilters[$name];
@@ -120,8 +119,7 @@ class FilterCollection
unset($this->enabledFilters[$name]);
// Now the filter collection is dirty
$this->filtersState = self::FILTERS_STATE_DIRTY;
$this->setFiltersStateDirty();
return $filter;
}
@@ -194,6 +192,9 @@ class FilterCollection
$filterHash .= $name . $filter;
}
$this->filterHash = $filterHash;
$this->filtersState = self::FILTERS_STATE_CLEAN;
return $filterHash;
}

View File

@@ -2809,7 +2809,7 @@ class Parser
/**
* SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}*
*
* @return SimpleArithmeticExpression
* @return SimpleArithmeticExpression|ArithmeticTerm
*/
public function SimpleArithmeticExpression()
{

View File

@@ -8,11 +8,6 @@ use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Query\AST\PathExpression;
use Exception;
/**
* Description of QueryException.
*
* @link www.doctrine-project.org
*/
class QueryException extends ORMException
{
/**

View File

@@ -73,7 +73,7 @@ class XmlExporter extends AbstractExporter
$discriminatorColumnXml->addAttribute('type', $metadata->discriminatorColumn['type']);
if (isset($metadata->discriminatorColumn['length'])) {
$discriminatorColumnXml->addAttribute('length', $metadata->discriminatorColumn['length']);
$discriminatorColumnXml->addAttribute('length', (string) $metadata->discriminatorColumn['length']);
}
}
@@ -339,7 +339,7 @@ class XmlExporter extends AbstractExporter
}
if (isset($inverseJoinColumn['nullable'])) {
$inverseJoinColumnXml->addAttribute('nullable', $inverseJoinColumn['nullable']);
$inverseJoinColumnXml->addAttribute('nullable', $inverseJoinColumn['nullable'] ? 'true' : 'false');
}
if (isset($inverseJoinColumn['orderBy'])) {
@@ -365,7 +365,7 @@ class XmlExporter extends AbstractExporter
}
if (isset($joinColumn['nullable'])) {
$joinColumnXml->addAttribute('nullable', $joinColumn['nullable']);
$joinColumnXml->addAttribute('nullable', $joinColumn['nullable'] ? 'true' : 'false');
}
}
}

View File

@@ -781,12 +781,18 @@ class SchemaTool
*/
private function gatherColumnOptions(array $mapping): array
{
if (! isset($mapping['options'])) {
$mappingOptions = $mapping['options'] ?? [];
if (isset($mapping['enumType'])) {
$mappingOptions['enumType'] = $mapping['enumType'];
}
if (empty($mappingOptions)) {
return [];
}
$options = array_intersect_key($mapping['options'], array_flip(self::KNOWN_COLUMN_OPTIONS));
$options['customSchemaOptions'] = array_diff_key($mapping['options'], $options);
$options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS));
$options['customSchemaOptions'] = array_diff_key($mappingOptions, $options);
return $options;
}

View File

@@ -134,9 +134,9 @@ class SchemaValidator
'field ' . $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' which does not exist.';
} elseif ($targetMetadata->associationMappings[$assoc['inversedBy']]['mappedBy'] === null) {
$ce[] = 'The field ' . $class->name . '#' . $fieldName . ' is on the owning side of a ' .
'bi-directional relationship, but the specified mappedBy association on the target-entity ' .
$assoc['targetEntity'] . '#' . $assoc['mappedBy'] . ' does not contain the required ' .
"'inversedBy' attribute.";
'bi-directional relationship, but the specified inversedBy association on the target-entity ' .
$assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' does not contain the required ' .
"'mappedBy=\"" . $fieldName . "\"' attribute.";
} elseif ($targetMetadata->associationMappings[$assoc['inversedBy']]['mappedBy'] !== $fieldName) {
$ce[] = 'The mappings ' . $class->name . '#' . $fieldName . ' and ' .
$assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' are ' .

View File

@@ -197,7 +197,7 @@ class Setup
$cache = class_exists(ArrayCache::class) ? new ArrayCache() : new ArrayAdapter();
} elseif (extension_loaded('apcu')) {
$cache = class_exists(ApcuCache::class) ? new ApcuCache() : new ApcuAdapter();
} elseif (extension_loaded('memcached')) {
} elseif (extension_loaded('memcached') && (class_exists(MemcachedCache::class) || MemcachedAdapter::isSupported())) {
$memcached = new Memcached();
$memcached->addServer('127.0.0.1', 11211);

View File

@@ -19,6 +19,7 @@ use Doctrine\ORM\Event\OnFlushEventArgs;
use Doctrine\ORM\Event\PostFlushEventArgs;
use Doctrine\ORM\Event\PreFlushEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Exception\UnexpectedAssociationValue;
use Doctrine\ORM\Id\AssignedGenerator;
use Doctrine\ORM\Internal\CommitOrderCalculator;
@@ -103,7 +104,7 @@ class UnitOfWork implements PropertyChangedListener
* Hint used to collect all primary keys of associated entities during hydration
* and execute it in a dedicated query afterwards
*
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#temporarily-change-fetch-mode-in-dql
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/stable/reference/dql-doctrine-query-language.html#temporarily-change-fetch-mode-in-dql
*/
public const HINT_DEFEREAGERLOAD = 'deferEagerLoad';

View File

@@ -269,9 +269,11 @@
<rule ref="Generic.WhiteSpace.ScopeIndent.Incorrect">
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/3474 -->
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/Suit.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/Unit.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/Suit.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/Models/Enums/Unit.php</exclude-pattern>
</rule>
</ruleset>

View File

@@ -1,5 +1,10 @@
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
@@ -130,36 +135,6 @@ parameters:
count: 1
path: lib/Doctrine/ORM/EntityManager.php
-
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:find\\(\\) should return T\\|null but returns object\\.$#"
count: 1
path: lib/Doctrine/ORM/EntityManager.php
-
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:find\\(\\) should return T\\|null but returns object\\|null\\.$#"
count: 3
path: lib/Doctrine/ORM/EntityManager.php
-
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getPartialReference\\(\\) should return T\\|null but returns object\\.$#"
count: 1
path: lib/Doctrine/ORM/EntityManager.php
-
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getPartialReference\\(\\) should return T\\|null but returns object\\|null\\.$#"
count: 1
path: lib/Doctrine/ORM/EntityManager.php
-
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getReference\\(\\) should return T\\|null but returns Doctrine\\\\Common\\\\Proxy\\\\Proxy\\.$#"
count: 1
path: lib/Doctrine/ORM/EntityManager.php
-
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getReference\\(\\) should return T\\|null but returns object\\|null\\.$#"
count: 1
path: lib/Doctrine/ORM/EntityManager.php
-
message: "#^Result of && is always false\\.$#"
count: 1
@@ -175,16 +150,6 @@ parameters:
count: 1
path: lib/Doctrine/ORM/EntityManagerInterface.php
-
message: "#^Method Doctrine\\\\ORM\\\\EntityRepository\\:\\:find\\(\\) should return T\\|null but returns object\\|null\\.$#"
count: 1
path: lib/Doctrine/ORM/EntityRepository.php
-
message: "#^Method Doctrine\\\\ORM\\\\EntityRepository\\:\\:findOneBy\\(\\) should return T\\|null but returns object\\|null\\.$#"
count: 1
path: lib/Doctrine/ORM/EntityRepository.php
-
message: "#^Method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:find\\(\\) invoked with 4 parameters, 2 required\\.$#"
count: 1
@@ -270,11 +235,6 @@ parameters:
count: 1
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
-
message: "#^Array \\(array\\<class\\-string, object\\>\\) does not accept key string\\.$#"
count: 1
path: lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php
-
message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:mapEmbedded\\(\\)\\.$#"
count: 1
@@ -705,11 +665,6 @@ parameters:
count: 1
path: lib/Doctrine/ORM/PersistentCollection.php
-
message: "#^Method Doctrine\\\\ORM\\\\PersistentCollection\\:\\:slice\\(\\) should return array\\<TKey of \\(int\\|string\\), T\\> but returns array\\.$#"
count: 2
path: lib/Doctrine/ORM/PersistentCollection.php
-
message: "#^Right side of && is always true\\.$#"
count: 2
@@ -725,11 +680,6 @@ parameters:
count: 1
path: lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php
-
message: "#^Array \\(array\\<class\\-string, string\\>\\) does not accept key string\\.$#"
count: 1
path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
-
message: "#^Parameter \\#3 \\$hints of method Doctrine\\\\ORM\\\\Internal\\\\Hydration\\\\AbstractHydrator\\:\\:hydrateAll\\(\\) expects array\\<string, string\\>, array\\<string, Doctrine\\\\ORM\\\\PersistentCollection\\|true\\> given\\.$#"
count: 1
@@ -930,11 +880,6 @@ parameters:
count: 1
path: lib/Doctrine/ORM/Query/Expr/Select.php
-
message: "#^Property Doctrine\\\\ORM\\\\Query\\\\FilterCollection\\:\\:\\$filterHash is never written, only read\\.$#"
count: 1
path: lib/Doctrine/ORM/Query/FilterCollection.php
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 3
@@ -946,12 +891,7 @@ parameters:
path: lib/Doctrine/ORM/Query/Parser.php
-
message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:ArithmeticTerm\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticTerm but returns Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticFactor\\|string\\.$#"
count: 1
path: lib/Doctrine/ORM/Query/Parser.php
-
message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:SimpleArithmeticExpression\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression but returns Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticTerm\\|string\\.$#"
message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:ArithmeticTerm\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticTerm but returns Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticFactor\\|int\\|string\\.$#"
count: 1
path: lib/Doctrine/ORM/Query/Parser.php
@@ -1000,11 +940,6 @@ parameters:
count: 1
path: lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
-
message: "#^Array \\(array\\<string, array\\<int, string\\>\\|string\\>\\) does not accept key int\\.$#"
count: 1
path: lib/Doctrine/ORM/Query/SqlWalker.php
-
message: "#^Call to function is_string\\(\\) with Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node will always evaluate to false\\.$#"
count: 2
@@ -1745,6 +1680,26 @@ parameters:
count: 2
path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
-
message: "#^Offset 'indexes' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\<string, mixed\\>, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
-
message: "#^Offset 'options' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\<string, mixed\\>, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
-
message: "#^Offset 'schema' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\<string, mixed\\>, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
-
message: "#^Offset 'uniqueConstraints' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\<string, mixed\\>, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
-
message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\<object\\>\\:\\:\\$lifecycleCallbacks \\(array\\<string, array\\<int, string\\>\\>\\) in isset\\(\\) is not nullable\\.$#"
count: 1
@@ -1864,3 +1819,4 @@ parameters:
message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#"
count: 1
path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php

View File

@@ -16,6 +16,7 @@
colors="true"
verbose="false"
failOnRisky="true"
convertDeprecationsToExceptions="true"
bootstrap="./tests/Doctrine/Tests/TestInit.php"
>
<testsuites>
@@ -32,6 +33,7 @@
</groups>
<php>
<ini name="error_reporting" value="-1" />
<!-- "Real" test database -->
<var name="db_driver" value="pdo_sqlite"/>
<var name="db_memory" value="true"/>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.18.1@dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb">
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
<file src="lib/Doctrine/ORM/AbstractQuery.php">
<DeprecatedClass occurrences="1">
<code>IterableResult</code>
@@ -703,8 +703,9 @@
<DeprecatedConstant occurrences="1">
<code>self::GENERATOR_TYPE_UUID</code>
</DeprecatedConstant>
<DeprecatedMethod occurrences="1">
<DeprecatedMethod occurrences="2">
<code>canEmulateSchemas</code>
<code>canRequireSQLConversion</code>
</DeprecatedMethod>
<DeprecatedProperty occurrences="4">
<code>$this-&gt;columnNames</code>
@@ -762,7 +763,7 @@
<code>$fieldName</code>
<code>$fieldName</code>
</ParamNameMismatch>
<PossiblyNullArgument occurrences="9">
<PossiblyNullArgument occurrences="8">
<code>$class</code>
<code>$className</code>
<code>$entityResult['entityClass']</code>
@@ -771,7 +772,6 @@
<code>$parentReflFields[$embeddedClass['declaredField']]</code>
<code>$parentReflFields[$mapping['declaredField']]</code>
<code>$queryMapping['resultClass']</code>
<code>$this-&gt;getAccessibleProperty($reflService, $mapping['originalClass'], $mapping['originalField'])</code>
</PossiblyNullArgument>
<PossiblyNullPropertyFetch occurrences="2">
<code>$embeddable-&gt;reflClass-&gt;name</code>
@@ -861,11 +861,8 @@
</MissingClosureParamType>
</file>
<file src="lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php">
<PossiblyNullPropertyAssignmentValue occurrences="4">
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>$columnDefinition</code>
<code>$length</code>
<code>$name</code>
<code>$type</code>
</PossiblyNullPropertyAssignmentValue>
</file>
<file src="lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php">
@@ -1244,11 +1241,10 @@
</MissingConstructor>
</file>
<file src="lib/Doctrine/ORM/Mapping/OneToMany.php">
<PossiblyNullPropertyAssignmentValue occurrences="4">
<PossiblyNullPropertyAssignmentValue occurrences="3">
<code>$cascade</code>
<code>$indexBy</code>
<code>$mappedBy</code>
<code>$targetEntity</code>
</PossiblyNullPropertyAssignmentValue>
</file>
<file src="lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php">
@@ -1463,6 +1459,14 @@
<ImplementedReturnTypeMismatch occurrences="1">
<code>int|null</code>
</ImplementedReturnTypeMismatch>
<InvalidReturnStatement occurrences="2">
<code>$numDeleted</code>
<code>$this-&gt;conn-&gt;executeStatement($statement, $parameters)</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="2">
<code>int</code>
<code>int</code>
</InvalidReturnType>
<PossiblyNullArgument occurrences="14">
<code>$collection-&gt;getOwner()</code>
<code>$collection-&gt;getOwner()</code>
@@ -1744,6 +1748,9 @@
</ParamNameMismatch>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php">
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$parser-&gt;SimpleArithmeticExpression()</code>
</PossiblyInvalidPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="1">
<code>$simpleArithmeticExpression</code>
</PropertyNotSetInConstructor>
@@ -1837,15 +1844,15 @@
</ParamNameMismatch>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php">
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$parser-&gt;getLexer()-&gt;token['value']</code>
</PossiblyInvalidPropertyAssignmentValue>
<PossiblyNullArrayAccess occurrences="1">
<code>$parser-&gt;getLexer()-&gt;token['value']</code>
</PossiblyNullArrayAccess>
<PossiblyNullArrayOffset occurrences="1">
<code>$class-&gt;associationMappings</code>
</PossiblyNullArrayOffset>
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>$parser-&gt;getLexer()-&gt;token['value']</code>
</PossiblyNullPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="2">
<code>$fieldMapping</code>
<code>$pathExpression</code>
@@ -1866,6 +1873,9 @@
<PossiblyInvalidArgument occurrences="1">
<code>$this-&gt;simpleArithmeticExpression</code>
</PossiblyInvalidArgument>
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$parser-&gt;SimpleArithmeticExpression()</code>
</PossiblyInvalidPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="2">
<code>$firstStringPrimary</code>
<code>$secondStringPrimary</code>
@@ -1890,6 +1900,10 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php">
<PossiblyInvalidPropertyAssignmentValue occurrences="2">
<code>$parser-&gt;SimpleArithmeticExpression()</code>
<code>$parser-&gt;SimpleArithmeticExpression()</code>
</PossiblyInvalidPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="2">
<code>$firstSimpleArithmeticExpression</code>
<code>$secondSimpleArithmeticExpression</code>
@@ -1904,11 +1918,18 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php">
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$parser-&gt;SimpleArithmeticExpression()</code>
</PossiblyInvalidPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="1">
<code>$simpleArithmeticExpression</code>
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php">
<PossiblyInvalidPropertyAssignmentValue occurrences="2">
<code>$parser-&gt;SimpleArithmeticExpression()</code>
<code>$parser-&gt;SimpleArithmeticExpression()</code>
</PossiblyInvalidPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="2">
<code>$firstSimpleArithmeticExpression</code>
<code>$stringPrimary</code>
@@ -1920,16 +1941,18 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php">
<PossiblyNullArgument occurrences="1">
<PossiblyInvalidArgument occurrences="3">
<code>$value</code>
</PossiblyNullArgument>
<code>$value</code>
<code>$value</code>
</PossiblyInvalidArgument>
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$lexer-&gt;token['value']</code>
</PossiblyInvalidPropertyAssignmentValue>
<PossiblyNullArrayAccess occurrences="2">
<code>$lexer-&gt;lookahead['value']</code>
<code>$lexer-&gt;token['value']</code>
</PossiblyNullArrayAccess>
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>$lexer-&gt;token['value']</code>
</PossiblyNullPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="4">
<code>$both</code>
<code>$leading</code>
@@ -2184,6 +2207,12 @@
</PossiblyNullPropertyAssignmentValue>
</file>
<file src="lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php">
<InvalidReturnStatement occurrences="1">
<code>$numDeleted</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>int</code>
</InvalidReturnType>
<PossiblyInvalidIterator occurrences="1">
<code>$this-&gt;_sqlStatements</code>
</PossiblyInvalidIterator>
@@ -2196,6 +2225,12 @@
</UninitializedProperty>
</file>
<file src="lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php">
<InvalidReturnStatement occurrences="1">
<code>$numUpdated</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>int</code>
</InvalidReturnType>
<PossiblyInvalidIterator occurrences="1">
<code>$this-&gt;_sqlStatements</code>
</PossiblyInvalidIterator>
@@ -2212,6 +2247,12 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php">
<InvalidReturnStatement occurrences="1">
<code>$conn-&gt;executeStatement($this-&gt;_sqlStatements, $params, $types)</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>int</code>
</InvalidReturnType>
<PossiblyInvalidArgument occurrences="1">
<code>$this-&gt;_sqlStatements</code>
</PossiblyInvalidArgument>
@@ -2309,17 +2350,16 @@
<InvalidArgument occurrences="1">
<code>$lookaheadType</code>
</InvalidArgument>
<InvalidNullableReturnType occurrences="6">
<InvalidNullableReturnType occurrences="1">
<code>SelectStatement|UpdateStatement|DeleteStatement</code>
<code>string</code>
<code>string</code>
<code>string</code>
<code>string</code>
<code>string</code>
</InvalidNullableReturnType>
<InvalidReturnStatement occurrences="11">
<InvalidReturnStatement occurrences="17">
<code>$aliasIdentVariable</code>
<code>$factors[0]</code>
<code>$identVariable</code>
<code>$primary</code>
<code>$resultVariable</code>
<code>$resultVariable</code>
<code>$terms[0]</code>
<code>$this-&gt;CollectionMemberExpression()</code>
<code>$this-&gt;ComparisonExpression()</code>
@@ -2329,23 +2369,44 @@
<code>$this-&gt;InstanceOfExpression()</code>
<code>$this-&gt;LikeExpression()</code>
<code>$this-&gt;NullComparisonExpression()</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="4">
<InvalidReturnType occurrences="9">
<code>AST\BetweenExpression|</code>
<code>ArithmeticFactor</code>
<code>ArithmeticTerm</code>
<code>SimpleArithmeticExpression</code>
<code>SimpleArithmeticExpression|ArithmeticTerm</code>
<code>string</code>
<code>string</code>
<code>string</code>
<code>string</code>
<code>string</code>
</InvalidReturnType>
<InvalidScalarArgument occurrences="3">
<InvalidScalarArgument occurrences="13">
<code>$field</code>
<code>$field</code>
<code>$functionName</code>
<code>$functionName</code>
<code>$functionName</code>
<code>$this-&gt;lexer-&gt;getLiteral($token)</code>
<code>$this-&gt;lexer-&gt;getLiteral($token)</code>
<code>$this-&gt;lexer-&gt;getLiteral($token)</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
</InvalidScalarArgument>
<LessSpecificReturnStatement occurrences="3">
<LessSpecificReturnStatement occurrences="4">
<code>$function</code>
<code>$function</code>
<code>$function</code>
<code>$token</code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType occurrences="1">
<code>array{value: string, type: int|null|string, position: int}|null</code>
</MoreSpecificReturnType>
<NullableReturnStatement occurrences="9">
<code>$aliasIdentVariable</code>
<code>$factors[0]</code>
@@ -2360,41 +2421,35 @@
<PossiblyFalseArgument occurrences="1">
<code>strrpos($fromClassName, '\\')</code>
</PossiblyFalseArgument>
<PossiblyInvalidArgument occurrences="6">
<PossiblyInvalidArgument occurrences="14">
<code>$AST</code>
<code>$conditionalExpression</code>
<code>$expr</code>
<code>$pathExp</code>
<code>$stringExpr</code>
<code>$this-&gt;ConditionalExpression()</code>
<code>$this-&gt;ConditionalExpression()</code>
<code>$this-&gt;lexer-&gt;lookahead['value']</code>
<code>$this-&gt;lexer-&gt;lookahead['value']</code>
<code>$this-&gt;lexer-&gt;lookahead['value']</code>
<code>$this-&gt;lexer-&gt;lookahead['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$token['value']</code>
<code>$token['value']</code>
</PossiblyInvalidArgument>
<PossiblyInvalidPropertyAssignmentValue occurrences="2">
<PossiblyInvalidPropertyAssignmentValue occurrences="4">
<code>$this-&gt;ConditionalExpression()</code>
<code>$this-&gt;ConditionalExpression()</code>
<code>$this-&gt;SimpleArithmeticExpression()</code>
<code>$value</code>
</PossiblyInvalidPropertyAssignmentValue>
<PossiblyNullArgument occurrences="22">
<PossiblyNullArgument occurrences="6">
<code>$aliasIdentVariable</code>
<code>$dql</code>
<code>$field</code>
<code>$fromClassName</code>
<code>$functionName</code>
<code>$functionName</code>
<code>$functionName</code>
<code>$resultVariable</code>
<code>$this-&gt;lexer-&gt;lookahead['value']</code>
<code>$this-&gt;lexer-&gt;lookahead['value']</code>
<code>$this-&gt;lexer-&gt;lookahead['value']</code>
<code>$this-&gt;lexer-&gt;lookahead['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;query-&gt;getDQL()</code>
<code>$token['value']</code>
<code>$token['value']</code>
<code>$token['value']</code>
</PossiblyNullArgument>
<PossiblyNullArrayAccess occurrences="74">
<code>$glimpse['type']</code>
@@ -2472,9 +2527,6 @@
<code>$token['value']</code>
<code>$token['value']</code>
</PossiblyNullArrayAccess>
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>$value</code>
</PossiblyNullPropertyAssignmentValue>
<PossiblyNullReference occurrences="1">
<code>getNumberOfRequiredParameters</code>
</PossiblyNullReference>
@@ -2507,9 +2559,9 @@
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/QueryExpressionVisitor.php">
<RedundantCondition occurrences="1">
<RedundantConditionGivenDocblockType occurrences="1">
<code>Comparison::EQ</code>
</RedundantCondition>
</RedundantConditionGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Query/ResultSetMapping.php">
<PropertyTypeCoercion occurrences="3">
@@ -3236,8 +3288,9 @@
</RedundantConditionGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php">
<ArgumentTypeCoercion occurrences="1">
<ArgumentTypeCoercion occurrences="2">
<code>$metadata-&gt;changeTrackingPolicy</code>
<code>$simpleXml-&gt;asXML()</code>
</ArgumentTypeCoercion>
<DeprecatedClass occurrences="1">
<code>AbstractExporter</code>

View File

@@ -30,6 +30,8 @@
<referencedClass name="Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand"/>
<!-- Remove on 2.12.x -->
<referencedClass name="Doctrine\Persistence\Mapping\Driver\AnnotationDriver"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedMethod>
@@ -90,18 +92,6 @@
<file name="lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php"/>
</errorLevel>
</MissingDependency>
<ParadoxicalCondition>
<errorLevel type="suppress">
<!-- See https://github.com/vimeo/psalm/issues/3381 -->
<file name="lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php"/>
</errorLevel>
</ParadoxicalCondition>
<NullArgument>
<errorLevel type="suppress">
<!-- See https://github.com/vimeo/psalm/issues/5920 -->
<file name="lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php"/>
</errorLevel>
</NullArgument>
<RedundantCastGivenDocblockType>
<errorLevel type="suppress">
<!-- Can be removed once the "getMaxResults" methods of those classes have native parameter types -->

View File

@@ -64,7 +64,12 @@ class DriverResultMock implements Result, ResultStatement
public function fetchAllNumeric(): array
{
throw new BadMethodCallException('Not implemented');
$values = [];
while (($row = $this->fetchNumeric()) !== false) {
$values[] = $row;
}
return $values;
}
public function fetchAllAssociative(): array

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace Doctrine\Tests\Models\Enums;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Embedded;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
#[Entity]
class Product
{
#[Id, GeneratedValue, Column(type: 'integer')]
public int $id;
#[Embedded(class: Quantity::class)]
public Quantity $quantity;
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Doctrine\Tests\Models\Enums;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Embeddable;
#[Embeddable]
class Quantity
{
#[Column(type: 'integer')]
public int $value;
#[Column(type: 'string', enumType: Unit::class)]
public Unit $unit;
}

View File

@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace Doctrine\Tests\Models\Enums;
enum Unit: string
{
case Gram = 'g';
case Meter = 'm';
}

View File

@@ -13,7 +13,7 @@ use Doctrine\ORM\Mapping\Table;
#[Entity, Table(name: 'author')]
class Author
{
#[Column, Id, GeneratedValue]
#[Column, Id, GeneratedValue(strategy: 'IDENTITY')]
private readonly int $id;
#[Column]

View File

@@ -17,7 +17,7 @@ use Doctrine\ORM\Mapping\Table;
#[Entity, Table(name: 'book')]
class Book
{
#[Column, Id, GeneratedValue]
#[Column, Id, GeneratedValue(strategy: 'IDENTITY')]
private readonly int $id;
#[Column]

View File

@@ -15,7 +15,7 @@ use Doctrine\ORM\Mapping\Table;
#[Entity, Table(name: 'simple_book')]
class SimpleBook
{
#[Column, Id, GeneratedValue]
#[Column, Id, GeneratedValue(strategy: 'IDENTITY')]
private readonly int $id;
#[Column]

View File

@@ -32,25 +32,13 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(Phrase::class),
$this->_em->getClassMetadata(PhraseType::class),
$this->_em->getClassMetadata(Definition::class),
$this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata(Type::class),
]);
}
protected function tearDown(): void
{
parent::tearDown();
$this->_schemaTool->dropSchema([
$this->_em->getClassMetadata(Phrase::class),
$this->_em->getClassMetadata(PhraseType::class),
$this->_em->getClassMetadata(Definition::class),
$this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata(Type::class),
]);
$this->createSchemaForModels(
Phrase::class,
PhraseType::class,
Definition::class,
Lemma::class,
Type::class
);
}
public function testIssue(): void

View File

@@ -113,7 +113,6 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
public function testBasicOneToOne(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$user = new CmsUser();
$user->name = 'Roman';
$user->username = 'romanb';
@@ -658,8 +657,6 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->_em->persist($article);
$this->_em->persist($user);
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->_em->flush();
$this->_em->clear();
@@ -686,8 +683,6 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$user->username = 'gblanco';
$user->status = 'developer';
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->_em->persist($user);
$this->_em->flush();
$this->_em->clear();
@@ -721,8 +716,6 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
});
$this->_em->clear();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$userRef = $this->_em->getReference(CmsUser::class, $user->getId());
$address2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsAddress a where a.user = :user')
->setParameter('user', $userRef)

View File

@@ -24,23 +24,9 @@ class CascadeRemoveOrderTest extends OrmFunctionalTestCase
{
parent::setUp();
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(CascadeRemoveOrderEntityO::class),
$this->_em->getClassMetadata(CascadeRemoveOrderEntityG::class),
]
);
}
protected function tearDown(): void
{
parent::tearDown();
$this->_schemaTool->dropSchema(
[
$this->_em->getClassMetadata(CascadeRemoveOrderEntityO::class),
$this->_em->getClassMetadata(CascadeRemoveOrderEntityG::class),
]
$this->createSchemaForModels(
CascadeRemoveOrderEntityO::class,
CascadeRemoveOrderEntityG::class
);
}

View File

@@ -30,23 +30,12 @@ class ClassTableInheritanceSecondTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(CTIParent::class),
$this->_em->getClassMetadata(CTIChild::class),
$this->_em->getClassMetadata(CTIRelated::class),
$this->_em->getClassMetadata(CTIRelated2::class),
]);
}
protected function tearDown(): void
{
parent::tearDown();
$this->_schemaTool->dropSchema([
$this->_em->getClassMetadata(CTIParent::class),
$this->_em->getClassMetadata(CTIChild::class),
$this->_em->getClassMetadata(CTIRelated::class),
$this->_em->getClassMetadata(CTIRelated2::class),
]);
$this->createSchemaForModels(
CTIParent::class,
CTIChild::class,
CTIRelated::class,
CTIRelated2::class
);
}
public function testOneToOneAssocToBaseTypeBidirectional(): void
@@ -76,7 +65,6 @@ class ClassTableInheritanceSecondTest extends OrmFunctionalTestCase
public function testManyToManyToCTIHierarchy(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
$mmrel = new CTIRelated2();
$child = new CTIChild();
$child->setData('child');

View File

@@ -23,19 +23,10 @@ class DefaultValuesTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(DefaultValueUser::class),
$this->_em->getClassMetadata(DefaultValueAddress::class),
]);
}
protected function tearDown(): void
{
$this->_schemaTool->dropSchema([
$this->_em->getClassMetadata(DefaultValueUser::class),
$this->_em->getClassMetadata(DefaultValueAddress::class),
]);
parent::tearDown();
$this->createSchemaForModels(
DefaultValueUser::class,
DefaultValueAddress::class
);
}
/**

View File

@@ -4,12 +4,16 @@ declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\Models\Enums\Card;
use Doctrine\Tests\Models\Enums\Product;
use Doctrine\Tests\Models\Enums\Quantity;
use Doctrine\Tests\Models\Enums\Suit;
use Doctrine\Tests\Models\Enums\TypedCard;
use Doctrine\Tests\Models\Enums\Unit;
use Doctrine\Tests\OrmFunctionalTestCase;
use function dirname;
@@ -22,11 +26,11 @@ class EnumTest extends OrmFunctionalTestCase
{
public function setUp(): void
{
parent::setUp();
$this->_em = $this->getEntityManager(null, new AttributeDriver([dirname(__DIR__, 2) . '/Models/Enums']));
$this->_schemaTool = new SchemaTool($this->_em);
parent::setUp();
if ($this->isSecondLevelCacheEnabled) {
$this->markTestSkipped();
}
@@ -101,4 +105,34 @@ EXCEPTION
TypedCard::class => [TypedCard::class],
];
}
public function testItAllowsReadingAttributes(): void
{
$metadata = $this->_em->getClassMetadata(Card::class);
$property = $metadata->getReflectionProperty('suit');
$attributes = $property->getAttributes();
$this->assertCount(1, $attributes);
$this->assertEquals(Column::class, $attributes[0]->getName());
}
public function testEnumMappingWithEmbeddable(): void
{
$this->setUpEntitySchema([Product::class]);
$product = new Product();
$product->quantity = new Quantity();
$product->quantity->value = 10;
$product->quantity->unit = Unit::Gram;
$this->_em->persist($product);
$this->_em->flush();
$this->_em->clear();
$fetchedProduct = $this->_em->find(Product::class, $product->id);
$this->assertInstanceOf(Unit::class, $fetchedProduct->quantity->unit);
$this->assertEquals(Unit::Gram, $fetchedProduct->quantity->unit);
}
}

View File

@@ -25,7 +25,6 @@ class FlushEventTest extends OrmFunctionalTestCase
public function testPersistNewEntitiesOnPreFlush(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->_em->getEventManager()->addEventListener(Events::onFlush, new OnFlushListener());
$user = new CmsUser();

View File

@@ -41,23 +41,12 @@ class LifecycleCallbackTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(LifecycleCallbackEventArgEntity::class),
$this->_em->getClassMetadata(LifecycleCallbackTestEntity::class),
$this->_em->getClassMetadata(LifecycleCallbackTestUser::class),
$this->_em->getClassMetadata(LifecycleCallbackCascader::class),
]);
}
protected function tearDown(): void
{
$this->_schemaTool->dropSchema([
$this->_em->getClassMetadata(LifecycleCallbackEventArgEntity::class),
$this->_em->getClassMetadata(LifecycleCallbackTestEntity::class),
$this->_em->getClassMetadata(LifecycleCallbackTestUser::class),
$this->_em->getClassMetadata(LifecycleCallbackCascader::class),
]);
parent::tearDown();
$this->createSchemaForModels(
LifecycleCallbackEventArgEntity::class,
LifecycleCallbackTestEntity::class,
LifecycleCallbackTestUser::class,
LifecycleCallbackCascader::class
);
}
public function testPreSavePostSaveCallbacksAreInvoked(): void
@@ -171,8 +160,6 @@ class LifecycleCallbackTest extends OrmFunctionalTestCase
*/
public function testCascadedEntitiesCallsPrePersist(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$e1 = new LifecycleCallbackTestEntity();
$e2 = new LifecycleCallbackTestEntity();

View File

@@ -35,22 +35,12 @@ class OptimisticTest extends OrmFunctionalTestCase
private function createSchema(): void
{
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(OptimisticJoinedParent::class),
$this->_em->getClassMetadata(OptimisticJoinedChild::class),
$this->_em->getClassMetadata(OptimisticStandard::class),
$this->_em->getClassMetadata(OptimisticTimestamp::class),
]);
}
private function dropSchema(): void
{
$this->_schemaTool->dropSchema([
$this->_em->getClassMetadata(OptimisticJoinedParent::class),
$this->_em->getClassMetadata(OptimisticJoinedChild::class),
$this->_em->getClassMetadata(OptimisticStandard::class),
$this->_em->getClassMetadata(OptimisticTimestamp::class),
]);
$this->createSchemaForModels(
OptimisticJoinedParent::class,
OptimisticJoinedChild::class,
OptimisticStandard::class,
OptimisticTimestamp::class
);
}
public function testJoinedChildInsertSetsInitialVersionValue(): OptimisticJoinedChild
@@ -93,8 +83,6 @@ class OptimisticTest extends OrmFunctionalTestCase
} catch (OptimisticLockException $e) {
self::assertSame($test, $e->getEntity());
}
$this->dropSchema();
}
public function testJoinedParentInsertSetsInitialVersionValue(): OptimisticJoinedParent
@@ -136,8 +124,6 @@ class OptimisticTest extends OrmFunctionalTestCase
} catch (OptimisticLockException $e) {
self::assertSame($test, $e->getEntity());
}
$this->dropSchema();
}
public function testMultipleFlushesDoIncrementalUpdates(): void
@@ -155,8 +141,6 @@ class OptimisticTest extends OrmFunctionalTestCase
self::assertIsInt($test->getVersion());
self::assertEquals($i + 1, $test->getVersion());
}
$this->dropSchema();
}
public function testStandardInsertSetsInitialVersionValue(): OptimisticStandard
@@ -200,8 +184,6 @@ class OptimisticTest extends OrmFunctionalTestCase
} catch (OptimisticLockException $e) {
self::assertSame($test, $e->getEntity());
}
$this->dropSchema();
}
public function testLockWorksWithProxy(): void
@@ -219,7 +201,6 @@ class OptimisticTest extends OrmFunctionalTestCase
$this->_em->lock($proxy, LockMode::OPTIMISTIC, 1);
$this->addToAssertionCount(1);
$this->dropSchema();
}
public function testOptimisticTimestampSetsDefaultValue(): OptimisticTimestamp
@@ -300,8 +281,6 @@ class OptimisticTest extends OrmFunctionalTestCase
self::assertNotNull($caughtException, 'No OptimisticLockingException was thrown');
self::assertSame($test, $caughtException->getEntity());
$this->dropSchema();
}
}

View File

@@ -79,7 +79,6 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
public function testEagerLoadFromInverseSideAndLazyLoadFromOwningSide(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->createLoadingFixture();
$categories = $this->findCategories();
$this->assertLazyLoadFromOwningSide($categories);
@@ -87,7 +86,6 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
public function testEagerLoadFromOwningSideAndLazyLoadFromInverseSide(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->createLoadingFixture();
$products = $this->findProducts();
$this->assertLazyLoadFromInverseSide($products);

View File

@@ -133,7 +133,6 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
public function testLazyLoadsObjectsOnTheInverseSide2(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->createFixture();
$query = $this->_em->createQuery('select f,p from Doctrine\Tests\Models\ECommerce\ECommerceFeature f join f.product p');

View File

@@ -15,9 +15,7 @@ use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function count;
use function get_class;
@@ -30,19 +28,13 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$schemaTool = new SchemaTool($this->_em);
try {
$schemaTool->createSchema(
[
$this->_em->getClassMetadata(Train::class),
$this->_em->getClassMetadata(TrainDriver::class),
$this->_em->getClassMetadata(TrainOwner::class),
$this->_em->getClassMetadata(Waggon::class),
$this->_em->getClassMetadata(TrainOrder::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(
Train::class,
TrainDriver::class,
TrainOwner::class,
Waggon::class,
TrainOrder::class
);
}
/**

View File

@@ -670,6 +670,7 @@ class PaginationTest extends OrmFunctionalTestCase
$dql = 'SELECT p FROM Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent p';
$query = $this->_em->createQuery($dql);
$query->setMaxResults(1);
$paginator = new Paginator($query, true);
$paginator->setUseOutputWalkers(false);

View File

@@ -14,22 +14,16 @@ use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
class PersistentCollectionTest extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(PersistentCollectionHolder::class),
$this->_em->getClassMetadata(PersistentCollectionContent::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(
PersistentCollectionHolder::class,
PersistentCollectionContent::class
);
PersistentObject::setObjectManager($this->_em);
}

View File

@@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* Test that Doctrine ORM correctly works with the ObjectManagerAware and PersistentObject
@@ -25,14 +24,7 @@ class PersistentObjectTest extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(PersistentEntity::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(PersistentEntity::class);
PersistentObject::setObjectManager($this->_em);
}

View File

@@ -13,7 +13,6 @@ use Doctrine\Tests\Models\CMS\CmsTag;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase;
use Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser as CmsUserProxy;
use Exception;
use function assert;
@@ -34,20 +33,15 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(CmsUser::class),
$this->_em->getClassMetadata(CmsTag::class),
$this->_em->getClassMetadata(CmsPhonenumber::class),
$this->_em->getClassMetadata(CmsArticle::class),
$this->_em->getClassMetadata(CmsAddress::class),
$this->_em->getClassMetadata(CmsEmail::class),
$this->_em->getClassMetadata(CmsGroup::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(
CmsUser::class,
CmsTag::class,
CmsPhonenumber::class,
CmsArticle::class,
CmsAddress::class,
CmsEmail::class,
CmsGroup::class
);
$this->user = new CmsUser();
$this->user->username = 'ocramius';

View File

@@ -15,23 +15,7 @@ class QueryBuilderParenthesisTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(QueryBuilderParenthesisEntity::class),
]
);
}
protected function tearDown(): void
{
parent::tearDown();
$this->_schemaTool->dropSchema(
[
$this->_em->getClassMetadata(QueryBuilderParenthesisEntity::class),
]
);
$this->createSchemaForModels(QueryBuilderParenthesisEntity::class);
}
public function testParenthesisOnSingleLine(): void

View File

@@ -312,8 +312,18 @@ class QueryDqlFunctionTest extends OrmFunctionalTestCase
self::assertArrayHasKey('now', $result);
self::assertArrayHasKey('add', $result);
$now = new DateTimeImmutable($result['now']);
$inOneUnit = $now->modify(sprintf('+%d %s', $amount, $unit));
if (
$unit === 'month'
&& $inOneUnit->format('m') === $now->modify('+2 month')->format('m')
&& ! $this->_em->getConnection()->getDatabasePlatform() instanceof SqlitePlatform
) {
$inOneUnit = new DateTimeImmutable('last day of next month');
}
self::assertEqualsWithDelta(
(new DateTimeImmutable($result['now']))->modify(sprintf('+%d %s', $amount, $unit)),
$inOneUnit,
new DateTimeImmutable($result['add']),
$delta
);

View File

@@ -522,7 +522,6 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->persist($article);
$this->_em->flush();
$this->_em->clear();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$q = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a where a.topic = :topic and a.user = :user')
->setParameter('user', $this->_em->getReference(CmsUser::class, $author->id))
->setParameter('topic', 'dr. dolittle');

View File

@@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Query;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function get_class;
@@ -25,14 +24,7 @@ class ReadOnlyTest extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(ReadOnlyEntity::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(ReadOnlyEntity::class);
}
public function testReadOnlyEntityNeverChangeTracked(): void

View File

@@ -519,7 +519,6 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testToOneFilter(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->loadFixtureData();
$query = $this->_em->createQuery('select ux, ua from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.address ua');

View File

@@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\SequenceGenerator;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* Description of SequenceGeneratorTest
@@ -25,14 +24,7 @@ class SequenceGeneratorTest extends OrmFunctionalTestCase
self::markTestSkipped('Only working for Databases that support sequences.');
}
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(SequenceEntity::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(SequenceEntity::class);
}
public function testHighAllocationSizeSequence(): void

View File

@@ -13,7 +13,6 @@ use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1113
@@ -25,17 +24,12 @@ class DDC1113Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1113Engine::class),
$this->_em->getClassMetadata(DDC1113Vehicle::class),
$this->_em->getClassMetadata(DDC1113Car::class),
$this->_em->getClassMetadata(DDC1113Bus::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(
DDC1113Engine::class,
DDC1113Vehicle::class,
DDC1113Car::class,
DDC1113Bus::class
);
}
public function testIssue(): void

View File

@@ -29,7 +29,6 @@ class DDC1163Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1163Product::class),

View File

@@ -18,7 +18,6 @@ class DDC1193Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1193Company::class),

View File

@@ -12,23 +12,17 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
class DDC1209Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1209One::class),
$this->_em->getClassMetadata(DDC1209Two::class),
$this->_em->getClassMetadata(DDC1209Three::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(
DDC1209One::class,
DDC1209Two::class,
DDC1209Three::class
);
}
/**

View File

@@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1228
@@ -21,15 +20,7 @@ class DDC1228Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1228User::class),
$this->_em->getClassMetadata(DDC1228Profile::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(DDC1228User::class, DDC1228Profile::class);
}
public function testOneToOnePersist(): void

View File

@@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1238
@@ -19,14 +18,7 @@ class DDC1238Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1238User::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(DDC1238User::class);
}
public function testIssue(): void

View File

@@ -6,6 +6,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
@@ -14,7 +15,6 @@ use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
/**
* @group DDC-1335
@@ -24,15 +24,10 @@ class DDC1335Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
$this->createSchemaForModels(DDC1335User::class, DDC1335Phone::class);
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1335User::class),
$this->_em->getClassMetadata(DDC1335Phone::class),
]
);
$this->loadFixture();
} catch (Exception $e) {
} catch (UniqueConstraintViolationException $e) {
}
}

View File

@@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function get_class;
@@ -25,15 +24,10 @@ class DDC1461Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1461TwitterAccount::class),
$this->_em->getClassMetadata(DDC1461User::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(
DDC1461TwitterAccount::class,
DDC1461User::class
);
}
public function testChangeDetectionDeferredExplicit(): void

View File

@@ -16,7 +16,6 @@ use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\PostLoad;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function get_class;
use function get_debug_type;
@@ -32,16 +31,11 @@ class DDC1655Test extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1655Foo::class),
$this->_em->getClassMetadata(DDC1655Bar::class),
$this->_em->getClassMetadata(DDC1655Baz::class),
]
);
} catch (Exception $e) {
}
$this->createSchemaForModels(
DDC1655Foo::class,
DDC1655Bar::class,
DDC1655Baz::class
);
}
public function testPostLoadOneToManyInheritance(): void

View File

@@ -38,8 +38,6 @@ class DDC168Test extends OrmFunctionalTestCase
*/
public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFieldsArray(): void
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$spouse = new CompanyEmployee();
$spouse->setName('Blub');
$spouse->setDepartment('Accounting');

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