Skip to content

Commit ac19b21

Browse files
committed
Merge branch '3.5.x' into 3.6.x
* 3.5.x: Add a CI job that fails on deprecations (doctrine#12188) use the empty string instead of null as an array offset (doctrine#12181) do not call setAccessible() on PHP >= 8.1 (doctrine#12182) Fix docs on final entities (doctrine#12176) Remove Database and Model First chapters that said little of value. Switch to IgnoreDeprecations docs: consistent PostgreSQL's name case docs: generation strategies differences between DBAL 3 and 4 Check extra condition to decide if a test was skipped Use PHPUnit 11 when possible Migrate away from annotations in tests Migrate away from assertStringNotMatchesFormat() Migrate to willReturn() Migrate away from getMockForAbstractClass() Fix `IN`/`NOT IN` expression handling and support enums when matching on to-many-collections
2 parents a7a14cf + c6db9fe commit ac19b21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+548
-303
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,24 @@ jobs:
115115
ENABLE_SECOND_LEVEL_CACHE: 0
116116
ENABLE_NATIVE_LAZY_OBJECTS: ${{ matrix.native_lazy }}
117117

118-
- name: "Run PHPUnit with Second Level Cache"
119-
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --exclude-group performance,non-cacheable,locking_functional --coverage-clover=coverage-cache.xml"
118+
- name: "Run PHPUnit with Second Level Cache and PHPUnit 10"
119+
run: |
120+
vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml \
121+
--exclude-group=performance,non-cacheable,locking_functional \
122+
--coverage-clover=coverage-cache.xml
123+
if: "${{ matrix.php-version == '8.1' }}"
124+
env:
125+
ENABLE_SECOND_LEVEL_CACHE: 1
126+
ENABLE_NATIVE_LAZY_OBJECTS: ${{ matrix.native_lazy }}
127+
128+
- name: "Run PHPUnit with Second Level Cache and PHPUnit 11+"
129+
run: |
130+
vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml \
131+
--exclude-group=performance \
132+
--exclude-group=non-cacheable \
133+
--exclude-group=locking_functional \
134+
--coverage-clover=coverage-cache.xml
135+
if: "${{ matrix.php-version != '8.1' }}"
120136
env:
121137
ENABLE_SECOND_LEVEL_CACHE: 1
122138
ENABLE_NATIVE_LAZY_OBJECTS: ${{ matrix.native_lazy }}
@@ -128,6 +144,40 @@ jobs:
128144
path: "coverage*.xml"
129145

130146

147+
phpunit-deprecations:
148+
name: "PHPUnit (fail on deprecations)"
149+
runs-on: "ubuntu-24.04"
150+
151+
steps:
152+
- name: "Checkout"
153+
uses: "actions/checkout@v5"
154+
with:
155+
fetch-depth: 2
156+
157+
- name: "Install PHP"
158+
uses: "shivammathur/setup-php@v2"
159+
with:
160+
php-version: "8.5"
161+
extensions: "apcu, pdo, sqlite3"
162+
coverage: "pcov"
163+
ini-values: "zend.assertions=1, apc.enable_cli=1"
164+
165+
- name: "Allow dev dependencies"
166+
run: composer config minimum-stability dev
167+
168+
- name: "Install dependencies with Composer"
169+
uses: "ramsey/composer-install@v3"
170+
with:
171+
composer-options: "--ignore-platform-req=php+"
172+
dependency-versions: "highest"
173+
174+
- name: "Run PHPUnit"
175+
run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite3.xml --fail-on-deprecation"
176+
env:
177+
ENABLE_SECOND_LEVEL_CACHE: 0
178+
ENABLE_NATIVE_LAZY_OBJECTS: 1
179+
180+
131181
phpunit-postgres:
132182
name: "PHPUnit with PostgreSQL"
133183
runs-on: "ubuntu-22.04"
@@ -339,8 +389,22 @@ jobs:
339389
env:
340390
ENABLE_SECOND_LEVEL_CACHE: 0
341391

342-
- name: "Run PHPUnit with Second Level Cache"
343-
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --exclude-group performance,non-cacheable,locking_functional --coverage-clover=coverage-no-cache.xml"
392+
- name: "Run PHPUnit with Second Level Cache and PHPUnit 10"
393+
run: |
394+
vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml \
395+
--exclude-group=performance,non-cacheable,locking_functional \
396+
--coverage-clover=coverage-no-cache.xml"
397+
if: "${{ matrix.php-version == '8.1' }}"
398+
env:
399+
ENABLE_SECOND_LEVEL_CACHE: 1
400+
- name: "Run PHPUnit with Second Level Cache and PHPUnit 11+"
401+
run: |
402+
vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml \
403+
--exclude-group=performance \
404+
--exclude-group=non-cacheable \
405+
--exclude-group=locking_functional \
406+
--coverage-clover=coverage-no-cache.xml
407+
if: "${{ matrix.php-version != '8.1' }}"
344408
env:
345409
ENABLE_SECOND_LEVEL_CACHE: 1
346410

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"phpstan/extension-installer": "^1.4",
4444
"phpstan/phpstan": "2.1.22",
4545
"phpstan/phpstan-deprecation-rules": "^2",
46-
"phpunit/phpunit": "^10.4.0",
46+
"phpunit/phpunit": "^10.5.0 || ^11.5",
4747
"psr/log": "^1 || ^2 || ^3",
4848
"squizlabs/php_codesniffer": "3.13.2",
4949
"symfony/cache": "^5.4 || ^6.2 || ^7.0 || ^8.0"

docs/en/reference/advanced-configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Configuration Options
7676
The following sections describe all the configuration options
7777
available on a ``Doctrine\ORM\Configuration`` instance.
7878

79+
.. _reference-native-lazy-objects:
80+
7981
Native Lazy Objects (**OPTIONAL**)
8082
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8183

docs/en/reference/architecture.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ Entities
7979
An entity is a lightweight, persistent domain object. An entity can
8080
be any regular PHP class observing the following restrictions:
8181

82-
- An entity class must not be final nor read-only but
83-
it may contain final methods or read-only properties.
82+
- An entity class can be final or read-only when
83+
you use :ref:`native lazy objects <reference-native-lazy-objects>`.
84+
It may contain final methods or read-only properties too.
8485
- Any two entity classes in a class hierarchy that inherit
8586
directly or indirectly from one another must not have a mapped
8687
property with the same name. That is, if B inherits from A then B

docs/en/reference/basic-mapping.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,17 +389,19 @@ Here is the list of possible generation strategies:
389389

390390
- ``AUTO`` (default): Tells Doctrine to pick the strategy that is
391391
preferred by the used database platform. The preferred strategies
392-
are ``IDENTITY`` for MySQL, SQLite, MsSQL and SQL Anywhere and, for
393-
historical reasons, ``SEQUENCE`` for Oracle and PostgreSQL. This
394-
strategy provides full portability.
392+
are ``IDENTITY`` for MySQL, SQLite, MsSQL, SQL Anywhere and
393+
PostgreSQL (on DBAL 4) and, for historical reasons, ``SEQUENCE``
394+
for Oracle and PostgreSQL (on DBAL 3). This strategy provides
395+
full portability.
395396
- ``IDENTITY``: Tells Doctrine to use special identity columns in
396397
the database that generate a value on insertion of a row. This
397398
strategy does currently not provide full portability and is
398399
supported by the following platforms: MySQL/SQLite/SQL Anywhere
399-
(``AUTO_INCREMENT``), MSSQL (``IDENTITY``) and PostgreSQL (``SERIAL``).
400+
(``AUTO_INCREMENT``), MSSQL (``IDENTITY``) and PostgreSQL (``SERIAL``
401+
on DBAL 3, ``GENERATED BY DEFAULT AS IDENTITY`` on DBAL 4).
400402
- ``SEQUENCE``: Tells Doctrine to use a database sequence for ID
401403
generation. This strategy does currently not provide full
402-
portability. Sequences are supported by Oracle, PostgreSql and
404+
portability. Sequences are supported by Oracle, PostgreSQL and
403405
SQL Anywhere.
404406
- ``NONE``: Tells Doctrine that the identifiers are assigned (and
405407
thus generated) by your code. The assignment must take place before

docs/en/sidebar.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
:depth: 3
66

77
tutorials/getting-started
8-
tutorials/getting-started-database
9-
tutorials/getting-started-models
108
tutorials/working-with-indexed-associations
119
tutorials/extra-lazy-associations
1210
tutorials/composite-primary-keys

docs/en/tutorials/getting-started-database.rst

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/en/tutorials/getting-started-models.rst

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/en/tutorials/getting-started.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ An entity contains persistable properties. A persistable property
4949
is an instance variable of the entity that is saved into and retrieved from the database
5050
by Doctrine's data mapping capabilities.
5151

52-
An entity class must not be final nor read-only, although
53-
it can contain final methods or read-only properties.
52+
An entity class can be final or read-only when you use
53+
:ref:`native lazy objects <reference-native-lazy-objects>`.
54+
It may contain final methods or read-only properties too.
5455

5556
An Example Model: Bug Tracker
5657
-----------------------------
@@ -534,7 +535,7 @@ the ``id`` tag. It has a ``generator`` tag nested inside, which
534535
specifies that the primary key generation mechanism should automatically
535536
use the database platform's native id generation strategy (for
536537
example, AUTO INCREMENT in the case of MySql, or Sequences in the
537-
case of PostgreSql and Oracle).
538+
case of PostgreSQL and Oracle).
538539

539540
Now that we have defined our first entity and its metadata,
540541
let's update the database schema:
@@ -1287,7 +1288,7 @@ The console output of this script is then:
12871288
result set to retrieve entities from the database. DQL boils down to a
12881289
Native SQL statement and a ``ResultSetMapping`` instance itself. Using
12891290
Native SQL you could even use stored procedures for data retrieval, or
1290-
make use of advanced non-portable database queries like PostgreSql's
1291+
make use of advanced non-portable database queries like PostgreSQL's
12911292
recursive queries.
12921293

12931294

phpstan-baseline.neon

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,14 +2023,8 @@ parameters:
20232023
path: src/Persisters/Entity/BasicEntityPersister.php
20242024

20252025
-
2026-
message: '#^Access to an undefined property Doctrine\\ORM\\Mapping\\ManyToManyOwningSideMapping\|Doctrine\\ORM\\Mapping\\ManyToOneAssociationMapping\|Doctrine\\ORM\\Mapping\\OneToOneOwningSideMapping\:\:\$relationToTargetKeyColumns\.$#'
2027-
identifier: property.notFound
2028-
count: 1
2029-
path: src/Persisters/Entity/BasicEntityPersister.php
2030-
2031-
-
2032-
message: '#^Access to an undefined property Doctrine\\ORM\\Mapping\\ManyToManyOwningSideMapping\|Doctrine\\ORM\\Mapping\\ManyToOneAssociationMapping\|Doctrine\\ORM\\Mapping\\OneToOneOwningSideMapping\:\:\$sourceToTargetKeyColumns\.$#'
2033-
identifier: property.notFound
2026+
message: '#^Access to property \$value on an unknown class Doctrine\\ORM\\Persisters\\Entity\\BackedEnum\.$#'
2027+
identifier: class.notFound
20342028
count: 1
20352029
path: src/Persisters/Entity/BasicEntityPersister.php
20362030

@@ -2041,20 +2035,14 @@ parameters:
20412035
path: src/Persisters/Entity/BasicEntityPersister.php
20422036

20432037
-
2044-
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:__construct\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
2045-
identifier: missingType.generics
2046-
count: 1
2047-
path: src/Persisters/Entity/BasicEntityPersister.php
2048-
2049-
-
2050-
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:expandCriteriaParameters\(\) should return array\{list\<mixed\>, list\<Doctrine\\DBAL\\ArrayParameterType\:\:ASCII\|Doctrine\\DBAL\\ArrayParameterType\:\:BINARY\|Doctrine\\DBAL\\ArrayParameterType\:\:INTEGER\|Doctrine\\DBAL\\ArrayParameterType\:\:STRING\|Doctrine\\DBAL\\ParameterType\:\:ASCII\|Doctrine\\DBAL\\ParameterType\:\:BINARY\|Doctrine\\DBAL\\ParameterType\:\:BOOLEAN\|Doctrine\\DBAL\\ParameterType\:\:INTEGER\|Doctrine\\DBAL\\ParameterType\:\:LARGE_OBJECT\|Doctrine\\DBAL\\ParameterType\:\:NULL\|Doctrine\\DBAL\\ParameterType\:\:STRING\|string\>\} but returns array\{array\<mixed\>, list\<Doctrine\\DBAL\\ArrayParameterType\:\:ASCII\|Doctrine\\DBAL\\ArrayParameterType\:\:BINARY\|Doctrine\\DBAL\\ArrayParameterType\:\:INTEGER\|Doctrine\\DBAL\\ArrayParameterType\:\:STRING\|Doctrine\\DBAL\\ParameterType\:\:ASCII\|Doctrine\\DBAL\\ParameterType\:\:BINARY\|Doctrine\\DBAL\\ParameterType\:\:BOOLEAN\|Doctrine\\DBAL\\ParameterType\:\:INTEGER\|Doctrine\\DBAL\\ParameterType\:\:LARGE_OBJECT\|Doctrine\\DBAL\\ParameterType\:\:NULL\|Doctrine\\DBAL\\ParameterType\:\:STRING\|string\>\}\.$#'
2051-
identifier: return.type
2038+
message: '#^Class Doctrine\\ORM\\Persisters\\Entity\\BackedEnum not found\.$#'
2039+
identifier: class.notFound
20522040
count: 1
20532041
path: src/Persisters/Entity/BasicEntityPersister.php
20542042

20552043
-
2056-
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:expandParameters\(\) should return array\{list\<mixed\>, list\<Doctrine\\DBAL\\ArrayParameterType\:\:ASCII\|Doctrine\\DBAL\\ArrayParameterType\:\:BINARY\|Doctrine\\DBAL\\ArrayParameterType\:\:INTEGER\|Doctrine\\DBAL\\ArrayParameterType\:\:STRING\|Doctrine\\DBAL\\ParameterType\:\:ASCII\|Doctrine\\DBAL\\ParameterType\:\:BINARY\|Doctrine\\DBAL\\ParameterType\:\:BOOLEAN\|Doctrine\\DBAL\\ParameterType\:\:INTEGER\|Doctrine\\DBAL\\ParameterType\:\:LARGE_OBJECT\|Doctrine\\DBAL\\ParameterType\:\:NULL\|Doctrine\\DBAL\\ParameterType\:\:STRING\|string\>\} but returns array\{array\<mixed\>, list\<Doctrine\\DBAL\\ArrayParameterType\:\:ASCII\|Doctrine\\DBAL\\ArrayParameterType\:\:BINARY\|Doctrine\\DBAL\\ArrayParameterType\:\:INTEGER\|Doctrine\\DBAL\\ArrayParameterType\:\:STRING\|Doctrine\\DBAL\\ParameterType\:\:ASCII\|Doctrine\\DBAL\\ParameterType\:\:BINARY\|Doctrine\\DBAL\\ParameterType\:\:BOOLEAN\|Doctrine\\DBAL\\ParameterType\:\:INTEGER\|Doctrine\\DBAL\\ParameterType\:\:LARGE_OBJECT\|Doctrine\\DBAL\\ParameterType\:\:NULL\|Doctrine\\DBAL\\ParameterType\:\:STRING\|string\>\}\.$#'
2057-
identifier: return.type
2044+
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:__construct\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
2045+
identifier: missingType.generics
20582046
count: 1
20592047
path: src/Persisters/Entity/BasicEntityPersister.php
20602048

@@ -2094,12 +2082,6 @@ parameters:
20942082
count: 1
20952083
path: src/Persisters/Entity/BasicEntityPersister.php
20962084

2097-
-
2098-
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getIndividualValue\(\) should return list\<mixed\> but returns array\<mixed\>\.$#'
2099-
identifier: return.type
2100-
count: 1
2101-
path: src/Persisters/Entity/BasicEntityPersister.php
2102-
21032085
-
21042086
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getSelectColumnAssociationSQL\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
21052087
identifier: missingType.generics
@@ -2112,18 +2094,6 @@ parameters:
21122094
count: 1
21132095
path: src/Persisters/Entity/BasicEntityPersister.php
21142096

2115-
-
2116-
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getTypes\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
2117-
identifier: missingType.generics
2118-
count: 1
2119-
path: src/Persisters/Entity/BasicEntityPersister.php
2120-
2121-
-
2122-
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getTypes\(\) should return list\<Doctrine\\DBAL\\ArrayParameterType\:\:ASCII\|Doctrine\\DBAL\\ArrayParameterType\:\:BINARY\|Doctrine\\DBAL\\ArrayParameterType\:\:INTEGER\|Doctrine\\DBAL\\ArrayParameterType\:\:STRING\|Doctrine\\DBAL\\ParameterType\:\:ASCII\|Doctrine\\DBAL\\ParameterType\:\:BINARY\|Doctrine\\DBAL\\ParameterType\:\:BOOLEAN\|Doctrine\\DBAL\\ParameterType\:\:INTEGER\|Doctrine\\DBAL\\ParameterType\:\:LARGE_OBJECT\|Doctrine\\DBAL\\ParameterType\:\:NULL\|Doctrine\\DBAL\\ParameterType\:\:STRING\|string\> but returns list\<Doctrine\\DBAL\\ArrayParameterType\:\:ASCII\|Doctrine\\DBAL\\ArrayParameterType\:\:BINARY\|Doctrine\\DBAL\\ArrayParameterType\:\:INTEGER\|Doctrine\\DBAL\\ArrayParameterType\:\:STRING\|int\>\.$#'
2123-
identifier: return.type
2124-
count: 1
2125-
path: src/Persisters/Entity/BasicEntityPersister.php
2126-
21272097
-
21282098
message: '#^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:loadCollectionFromStatement\(\) has parameter \$coll with generic class Doctrine\\ORM\\PersistentCollection but does not specify its types\: TKey, T$#'
21292099
identifier: missingType.generics
@@ -3603,6 +3573,18 @@ parameters:
36033573
count: 1
36043574
path: src/Utility/PersisterHelper.php
36053575

3576+
-
3577+
message: '#^Access to an undefined property Doctrine\\ORM\\Mapping\\ManyToManyOwningSideMapping\|Doctrine\\ORM\\Mapping\\ManyToOneAssociationMapping\|Doctrine\\ORM\\Mapping\\OneToOneOwningSideMapping\:\:\$relationToTargetKeyColumns\.$#'
3578+
identifier: property.notFound
3579+
count: 1
3580+
path: src/Utility/PersisterHelper.php
3581+
3582+
-
3583+
message: '#^Access to an undefined property Doctrine\\ORM\\Mapping\\ManyToManyOwningSideMapping\|Doctrine\\ORM\\Mapping\\ManyToOneAssociationMapping\|Doctrine\\ORM\\Mapping\\OneToOneOwningSideMapping\:\:\$sourceToTargetKeyColumns\.$#'
3584+
identifier: property.notFound
3585+
count: 1
3586+
path: src/Utility/PersisterHelper.php
3587+
36063588
-
36073589
message: '#^Method Doctrine\\ORM\\Utility\\PersisterHelper\:\:getTypeOfColumn\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
36083590
identifier: missingType.generics
@@ -3614,3 +3596,15 @@ parameters:
36143596
identifier: missingType.generics
36153597
count: 1
36163598
path: src/Utility/PersisterHelper.php
3599+
3600+
-
3601+
message: '#^Method Doctrine\\ORM\\Utility\\PersisterHelper\:\:inferParameterTypes\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
3602+
identifier: missingType.generics
3603+
count: 1
3604+
path: src/Utility/PersisterHelper.php
3605+
3606+
-
3607+
message: '#^Method Doctrine\\ORM\\Utility\\PersisterHelper\:\:inferParameterTypes\(\) should return list\<Doctrine\\DBAL\\ArrayParameterType\:\:ASCII\|Doctrine\\DBAL\\ArrayParameterType\:\:BINARY\|Doctrine\\DBAL\\ArrayParameterType\:\:INTEGER\|Doctrine\\DBAL\\ArrayParameterType\:\:STRING\|Doctrine\\DBAL\\ParameterType\:\:ASCII\|Doctrine\\DBAL\\ParameterType\:\:BINARY\|Doctrine\\DBAL\\ParameterType\:\:BOOLEAN\|Doctrine\\DBAL\\ParameterType\:\:INTEGER\|Doctrine\\DBAL\\ParameterType\:\:LARGE_OBJECT\|Doctrine\\DBAL\\ParameterType\:\:NULL\|Doctrine\\DBAL\\ParameterType\:\:STRING\|string\> but returns list\<Doctrine\\DBAL\\ArrayParameterType\:\:ASCII\|Doctrine\\DBAL\\ArrayParameterType\:\:BINARY\|Doctrine\\DBAL\\ArrayParameterType\:\:INTEGER\|Doctrine\\DBAL\\ArrayParameterType\:\:STRING\|int\>\.$#'
3608+
identifier: return.type
3609+
count: 1
3610+
path: src/Utility/PersisterHelper.php

0 commit comments

Comments
 (0)