mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Compare commits
243 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19912de927 | ||
|
|
737cca5b78 | ||
|
|
9e999ea1ff | ||
|
|
6755bb0c7b | ||
|
|
c2a49327a7 | ||
|
|
9bd7242376 | ||
|
|
fff085b63f | ||
|
|
5ad5b11ae1 | ||
|
|
c12fd2cb94 | ||
|
|
44d5d4a779 | ||
|
|
e3cabade99 | ||
|
|
9402f9e0f7 | ||
|
|
4feaa470af | ||
|
|
4a9101f383 | ||
|
|
f91da5b950 | ||
|
|
66f654d4e2 | ||
|
|
53b51ae40e | ||
|
|
95b0f5c328 | ||
|
|
a5c80a4c75 | ||
|
|
6fd26a3933 | ||
|
|
8ef9253999 | ||
|
|
0ed0be089c | ||
|
|
8fb1043e96 | ||
|
|
fd041fbe80 | ||
|
|
eadf96c879 | ||
|
|
0d770c89d6 | ||
|
|
4bda5147f3 | ||
|
|
38c6569645 | ||
|
|
7c0eebe90a | ||
|
|
8784f2bce9 | ||
|
|
fbcac42ebd | ||
|
|
619302dc9a | ||
|
|
82e2c981da | ||
|
|
8422a41423 | ||
|
|
58ad1d9678 | ||
|
|
346c49832c | ||
|
|
f140651ff0 | ||
|
|
bb5b2a3300 | ||
|
|
ba11851ac4 | ||
|
|
4fbce94999 | ||
|
|
486e406236 | ||
|
|
7d1b24f3b1 | ||
|
|
43ce0bef78 | ||
|
|
d9aa6ef6dc | ||
|
|
ff3ccff36a | ||
|
|
9e2bfa8169 | ||
|
|
3ca9529c32 | ||
|
|
439b4dacf4 | ||
|
|
182469b346 | ||
|
|
e47398ecc5 | ||
|
|
9e884ccf1f | ||
|
|
982d6060a3 | ||
|
|
013f850c76 | ||
|
|
ef4508e52f | ||
|
|
f53350934f | ||
|
|
4ff909044e | ||
|
|
32682aa14d | ||
|
|
bd20df1043 | ||
|
|
2ec2030ab2 | ||
|
|
8ed6c2234a | ||
|
|
ff612b9678 | ||
|
|
ee0d7197dd | ||
|
|
39d2136f46 | ||
|
|
bea454eefc | ||
|
|
14f2572e4e | ||
|
|
c2c500077b | ||
|
|
6281c2b79f | ||
|
|
bac1c17eab | ||
|
|
b6137c8911 | ||
|
|
51be1b1d52 | ||
|
|
488a5dd3bf | ||
|
|
896c65504d | ||
|
|
16a8f10fd2 | ||
|
|
d80a831157 | ||
|
|
52660297ab | ||
|
|
58287bb731 | ||
|
|
bc37f75b41 | ||
|
|
8a25b264f7 | ||
|
|
0e48b19cd3 | ||
|
|
109042e5af | ||
|
|
08328adc6c | ||
|
|
65806884b0 | ||
|
|
ad80e8281a | ||
|
|
0c0c61c51b | ||
|
|
cc28fed9f5 | ||
|
|
2245149588 | ||
|
|
b13564c6c0 | ||
|
|
91709c1275 | ||
|
|
d18126aac5 | ||
|
|
b7fd8241cf | ||
|
|
2432939e4f | ||
|
|
1bf4603422 | ||
|
|
25d5bc5b46 | ||
|
|
6cde337777 | ||
|
|
74ef28295a | ||
|
|
168ac31084 | ||
|
|
fe4a2e83cf | ||
|
|
8ac6a13ca0 | ||
|
|
2707b09a07 | ||
|
|
121158f92c | ||
|
|
51ad860a25 | ||
|
|
9bd51aaeb6 | ||
|
|
c37b115450 | ||
|
|
19129e9f8a | ||
|
|
7d01f19667 | ||
|
|
c1bb2ccf4b | ||
|
|
e3d7c6076c | ||
|
|
40f299f1eb | ||
|
|
d0e9177121 | ||
|
|
68af854f46 | ||
|
|
77467cd824 | ||
|
|
802f20b8e7 | ||
|
|
96d13ac62a | ||
|
|
2ea6a1a5fb | ||
|
|
83851a9716 | ||
|
|
066ec1ac81 | ||
|
|
68744489f0 | ||
|
|
cc2ad1993c | ||
|
|
e4d46c4276 | ||
|
|
858a1adc3b | ||
|
|
3b499132d9 | ||
|
|
39153fd88a | ||
|
|
bdc9679e37 | ||
|
|
87a8ee21c9 | ||
|
|
59c8bc09ab | ||
|
|
3a7d7c9f57 | ||
|
|
06eca40134 | ||
|
|
23b35e9554 | ||
|
|
e063926cbd | ||
|
|
4a01a76a17 | ||
|
|
93c2dd9d4b | ||
|
|
75bc22980e | ||
|
|
9696c3434d | ||
|
|
bf3e082c00 | ||
|
|
d31aabb40c | ||
|
|
d66884403f | ||
|
|
552eae37a3 | ||
|
|
ee4b03aa78 | ||
|
|
eb49f66926 | ||
|
|
73e30df52b | ||
|
|
c5291b4de8 | ||
|
|
831d86548c | ||
|
|
f26b3b9cf9 | ||
|
|
9ab84f7478 | ||
|
|
e6bb4ef20e | ||
|
|
8b6a58fa0e | ||
|
|
94986af284 | ||
|
|
ad5c8e4bdc | ||
|
|
c363f55ad1 | ||
|
|
c973a62272 | ||
|
|
8d3446015a | ||
|
|
4e335f4044 | ||
|
|
bb36d49b38 | ||
|
|
2b81a8e260 | ||
|
|
7d3b3f28e9 | ||
|
|
cbec236e8b | ||
|
|
306963fe79 | ||
|
|
fb4578406f | ||
|
|
bdc41e2b5e | ||
|
|
90376a6431 | ||
|
|
b725908c83 | ||
|
|
b274893486 | ||
|
|
8709fb38b0 | ||
|
|
e9e60f2fbc | ||
|
|
5f3c1dbab8 | ||
|
|
6090141e0b | ||
|
|
e4a6c041b5 | ||
|
|
be307edba8 | ||
|
|
c54c557e02 | ||
|
|
46d0865339 | ||
|
|
1a5a4c674a | ||
|
|
95795c87a8 | ||
|
|
083f642cfa | ||
|
|
db6e702088 | ||
|
|
716da7e538 | ||
|
|
5ccbc201bf | ||
|
|
d15624f72f | ||
|
|
9d1a4973ae | ||
|
|
bcdc5bdaf4 | ||
|
|
40a0964f06 | ||
|
|
08a9e60ed0 | ||
|
|
3e3c023c95 | ||
|
|
5e6d5c06a9 | ||
|
|
1622b7877d | ||
|
|
80aae2796d | ||
|
|
528ef40fc4 | ||
|
|
4b4b9b7b6f | ||
|
|
ae842259f5 | ||
|
|
820a0da4c1 | ||
|
|
fcd02b1ee2 | ||
|
|
a3e3a3bbf3 | ||
|
|
abcad6fa45 | ||
|
|
1b6cf58a1a | ||
|
|
6501890ab5 | ||
|
|
e399d21fb3 | ||
|
|
16f355f0cc | ||
|
|
94d45a036f | ||
|
|
9acca2252f | ||
|
|
a809a71aa6 | ||
|
|
bd4449c462 | ||
|
|
e3e96745cc | ||
|
|
12e0cefba1 | ||
|
|
21221f73cc | ||
|
|
ab5e9e393b | ||
|
|
e62571c8f4 | ||
|
|
98f9de2af6 | ||
|
|
52a6a21387 | ||
|
|
83c81f6c41 | ||
|
|
4fc8629414 | ||
|
|
791667a9e4 | ||
|
|
feb27f00c1 | ||
|
|
abd9186d00 | ||
|
|
719d007a81 | ||
|
|
08d3f72755 | ||
|
|
779781173a | ||
|
|
76c4539ffa | ||
|
|
0f8d193512 | ||
|
|
cc314d0fb7 | ||
|
|
c9c493b2fe | ||
|
|
e6eef1a97d | ||
|
|
8d4718f875 | ||
|
|
c0dfba2ef3 | ||
|
|
0efac09141 | ||
|
|
efb6cebd41 | ||
|
|
e4769d3191 | ||
|
|
cf408ad9ae | ||
|
|
7c29078051 | ||
|
|
b59189ab48 | ||
|
|
401a0c4fe9 | ||
|
|
dba9d72b2d | ||
|
|
fe0647053a | ||
|
|
7b3db4a037 | ||
|
|
e5e3166747 | ||
|
|
afbf293c94 | ||
|
|
1d218bae30 | ||
|
|
7baef1e120 | ||
|
|
5049b615c5 | ||
|
|
40fbbf4429 | ||
|
|
6f98147d09 | ||
|
|
cfadb5499d | ||
|
|
9ce9ae2818 | ||
|
|
fdb9d44538 | ||
|
|
a9fcaf1d18 |
@@ -6,22 +6,52 @@
|
||||
"docsSlug": "doctrine-orm",
|
||||
"versions": [
|
||||
{
|
||||
"name": "3.0",
|
||||
"branchName": "3.0.x",
|
||||
"name": "4.0",
|
||||
"branchName": "4.0.x",
|
||||
"slug": "latest",
|
||||
"upcoming": true
|
||||
},
|
||||
{
|
||||
"name": "3.2",
|
||||
"branchName": "3.2.x",
|
||||
"slug": "3.2",
|
||||
"upcoming": true
|
||||
},
|
||||
{
|
||||
"name": "3.1",
|
||||
"branchName": "3.1.x",
|
||||
"slug": "3.1",
|
||||
"current": true
|
||||
},
|
||||
{
|
||||
"name": "3.0",
|
||||
"branchName": "3.0.x",
|
||||
"slug": "3.0",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "2.20",
|
||||
"branchName": "2.20.x",
|
||||
"slug": "2.20",
|
||||
"upcoming": true
|
||||
},
|
||||
{
|
||||
"name": "2.19",
|
||||
"branchName": "2.19.x",
|
||||
"slug": "2.19",
|
||||
"maintained": true
|
||||
},
|
||||
{
|
||||
"name": "2.18",
|
||||
"branchName": "2.18.x",
|
||||
"slug": "2.18",
|
||||
"upcoming": true
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "2.17",
|
||||
"branchName": "2.17.x",
|
||||
"slug": "2.17",
|
||||
"current": true
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "2.16",
|
||||
|
||||
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -19,5 +19,3 @@ phpstan-baseline.neon export-ignore
|
||||
phpstan-dbal2.neon export-ignore
|
||||
phpstan-params.neon export-ignore
|
||||
phpstan-persistence2.neon export-ignore
|
||||
psalm.xml export-ignore
|
||||
psalm-baseline.xml export-ignore
|
||||
|
||||
2
.github/workflows/coding-standards.yml
vendored
2
.github/workflows/coding-standards.yml
vendored
@@ -24,4 +24,4 @@ on:
|
||||
|
||||
jobs:
|
||||
coding-standards:
|
||||
uses: "doctrine/.github/.github/workflows/coding-standards.yml@3.0.0"
|
||||
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.2.1"
|
||||
|
||||
44
.github/workflows/continuous-integration.yml
vendored
44
.github/workflows/continuous-integration.yml
vendored
@@ -40,6 +40,7 @@ jobs:
|
||||
- "8.1"
|
||||
- "8.2"
|
||||
- "8.3"
|
||||
- "8.4"
|
||||
dbal-version:
|
||||
- "default"
|
||||
extension:
|
||||
@@ -80,7 +81,7 @@ jobs:
|
||||
if: "${{ matrix.dbal-version != 'default' }}"
|
||||
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v2"
|
||||
uses: "ramsey/composer-install@v3"
|
||||
with:
|
||||
composer-options: "--ignore-platform-req=php+"
|
||||
|
||||
@@ -97,9 +98,9 @@ jobs:
|
||||
ORM_PROXY_IMPLEMENTATION: "${{ matrix.proxy }}"
|
||||
|
||||
- name: "Upload coverage file"
|
||||
uses: "actions/upload-artifact@v3"
|
||||
uses: "actions/upload-artifact@v4"
|
||||
with:
|
||||
name: "phpunit-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage"
|
||||
name: "phpunit-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-${{ matrix.proxy }}-coverage"
|
||||
path: "coverage*.xml"
|
||||
|
||||
|
||||
@@ -113,11 +114,12 @@ jobs:
|
||||
php-version:
|
||||
- "8.2"
|
||||
- "8.3"
|
||||
- "8.4"
|
||||
dbal-version:
|
||||
- "default"
|
||||
- "3@dev"
|
||||
postgres-version:
|
||||
- "15"
|
||||
- "17"
|
||||
extension:
|
||||
- pdo_pgsql
|
||||
- pgsql
|
||||
@@ -162,7 +164,7 @@ jobs:
|
||||
if: "${{ matrix.dbal-version != 'default' }}"
|
||||
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v2"
|
||||
uses: "ramsey/composer-install@v3"
|
||||
with:
|
||||
composer-options: "--ignore-platform-req=php+"
|
||||
|
||||
@@ -170,9 +172,9 @@ jobs:
|
||||
run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_pgsql.xml --coverage-clover=coverage.xml"
|
||||
|
||||
- name: "Upload coverage file"
|
||||
uses: "actions/upload-artifact@v3"
|
||||
uses: "actions/upload-artifact@v4"
|
||||
with:
|
||||
name: "${{ github.job }}-${{ matrix.postgres-version }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage"
|
||||
name: "${{ github.job }}-${{ matrix.postgres-version }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-${{ matrix.extension }}-coverage"
|
||||
path: "coverage.xml"
|
||||
|
||||
|
||||
@@ -186,11 +188,12 @@ jobs:
|
||||
php-version:
|
||||
- "8.2"
|
||||
- "8.3"
|
||||
- "8.4"
|
||||
dbal-version:
|
||||
- "default"
|
||||
- "3@dev"
|
||||
mariadb-version:
|
||||
- "10.9"
|
||||
- "11.4"
|
||||
extension:
|
||||
- "mysqli"
|
||||
- "pdo_mysql"
|
||||
@@ -204,11 +207,11 @@ jobs:
|
||||
mariadb:
|
||||
image: "mariadb:${{ matrix.mariadb-version }}"
|
||||
env:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
||||
MYSQL_DATABASE: "doctrine_tests"
|
||||
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
|
||||
MARIADB_DATABASE: "doctrine_tests"
|
||||
|
||||
options: >-
|
||||
--health-cmd "mysqladmin ping --silent"
|
||||
--health-cmd "healthcheck.sh --connect --innodb_initialized"
|
||||
|
||||
ports:
|
||||
- "3306:3306"
|
||||
@@ -232,7 +235,7 @@ jobs:
|
||||
extensions: "${{ matrix.extension }}"
|
||||
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v2"
|
||||
uses: "ramsey/composer-install@v3"
|
||||
with:
|
||||
composer-options: "--ignore-platform-req=php+"
|
||||
|
||||
@@ -240,7 +243,7 @@ jobs:
|
||||
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"
|
||||
|
||||
- name: "Upload coverage file"
|
||||
uses: "actions/upload-artifact@v3"
|
||||
uses: "actions/upload-artifact@v4"
|
||||
with:
|
||||
name: "${{ github.job }}-${{ matrix.mariadb-version }}-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage"
|
||||
path: "coverage.xml"
|
||||
@@ -256,6 +259,7 @@ jobs:
|
||||
php-version:
|
||||
- "8.2"
|
||||
- "8.3"
|
||||
- "8.4"
|
||||
dbal-version:
|
||||
- "default"
|
||||
- "3@dev"
|
||||
@@ -302,7 +306,7 @@ jobs:
|
||||
if: "${{ matrix.dbal-version != 'default' }}"
|
||||
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v2"
|
||||
uses: "ramsey/composer-install@v3"
|
||||
with:
|
||||
composer-options: "--ignore-platform-req=php+"
|
||||
|
||||
@@ -317,7 +321,7 @@ jobs:
|
||||
ENABLE_SECOND_LEVEL_CACHE: 1
|
||||
|
||||
- name: "Upload coverage files"
|
||||
uses: "actions/upload-artifact@v3"
|
||||
uses: "actions/upload-artifact@v4"
|
||||
with:
|
||||
name: "${{ github.job }}-${{ matrix.mysql-version }}-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage"
|
||||
path: "coverage*.xml"
|
||||
@@ -348,7 +352,7 @@ jobs:
|
||||
ini-values: "zend.assertions=1, apc.enable_cli=1"
|
||||
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v2"
|
||||
uses: "ramsey/composer-install@v3"
|
||||
with:
|
||||
dependency-versions: "${{ matrix.deps }}"
|
||||
|
||||
@@ -359,6 +363,8 @@ jobs:
|
||||
upload_coverage:
|
||||
name: "Upload coverage to Codecov"
|
||||
runs-on: "ubuntu-22.04"
|
||||
# Only run on PRs from forks
|
||||
if: "github.event.pull_request.head.repo.full_name != github.repository"
|
||||
needs:
|
||||
- "phpunit-smoke-check"
|
||||
- "phpunit-postgres"
|
||||
@@ -372,11 +378,13 @@ jobs:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: "Download coverage files"
|
||||
uses: "actions/download-artifact@v3"
|
||||
uses: "actions/download-artifact@v4"
|
||||
with:
|
||||
path: "reports"
|
||||
|
||||
- name: "Upload to Codecov"
|
||||
uses: "codecov/codecov-action@v3"
|
||||
uses: "codecov/codecov-action@v5"
|
||||
with:
|
||||
directory: reports
|
||||
env:
|
||||
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
|
||||
|
||||
42
.github/workflows/documentation.yml
vendored
42
.github/workflows/documentation.yml
vendored
@@ -5,44 +5,16 @@ on:
|
||||
branches:
|
||||
- "*.x"
|
||||
paths:
|
||||
- .github/workflows/documentation.yml
|
||||
- docs/**
|
||||
- ".github/workflows/documentation.yml"
|
||||
- "docs/**"
|
||||
push:
|
||||
branches:
|
||||
- "*.x"
|
||||
paths:
|
||||
- .github/workflows/documentation.yml
|
||||
- docs/**
|
||||
- ".github/workflows/documentation.yml"
|
||||
- "docs/**"
|
||||
|
||||
jobs:
|
||||
validate-with-guides:
|
||||
name: "Validate documentation with phpDocumentor/guides"
|
||||
runs-on: "ubuntu-22.04"
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: "actions/checkout@v4"
|
||||
|
||||
- name: "Install PHP"
|
||||
uses: "shivammathur/setup-php@v2"
|
||||
with:
|
||||
coverage: "none"
|
||||
php-version: "8.2"
|
||||
|
||||
- name: "Remove existing composer file"
|
||||
run: "rm composer.json"
|
||||
|
||||
- name: "Require phpdocumentor/guides-cli"
|
||||
run: "composer require --dev phpdocumentor/guides-cli --no-update"
|
||||
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v2"
|
||||
with:
|
||||
dependency-versions: "highest"
|
||||
|
||||
- name: "Add dummy title to the sidebar"
|
||||
run: |
|
||||
printf '%s\n%s\n\n%s\n' "Dummy title" "===========" "$(cat docs/en/sidebar.rst)" > docs/en/sidebar.rst
|
||||
|
||||
- name: "Run guides-cli"
|
||||
run: "vendor/bin/guides -vvv --no-progress docs/en 2>&1 | grep -v 'Unknown directive' | ( ! grep WARNING )"
|
||||
documentation:
|
||||
name: "Documentation"
|
||||
uses: "doctrine/.github/.github/workflows/documentation.yml@7.2.1"
|
||||
|
||||
11
.github/workflows/phpbench.yml
vendored
11
.github/workflows/phpbench.yml
vendored
@@ -47,15 +47,8 @@ jobs:
|
||||
coverage: "pcov"
|
||||
ini-values: "zend.assertions=1, apc.enable_cli=1"
|
||||
|
||||
- name: "Cache dependencies installed with composer"
|
||||
uses: "actions/cache@v3"
|
||||
with:
|
||||
path: "~/.composer/cache"
|
||||
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
|
||||
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
|
||||
|
||||
- name: "Install dependencies with composer"
|
||||
run: "composer update --no-interaction --no-progress"
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v3"
|
||||
|
||||
- name: "Run PHPBench"
|
||||
run: "vendor/bin/phpbench run --report=default"
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@3.0.0"
|
||||
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@7.2.1"
|
||||
secrets:
|
||||
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
|
||||
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
|
||||
|
||||
38
.github/workflows/static-analysis.yml
vendored
38
.github/workflows/static-analysis.yml
vendored
@@ -9,8 +9,7 @@ on:
|
||||
- composer.*
|
||||
- src/**
|
||||
- phpstan*
|
||||
- psalm*
|
||||
- tests/Doctrine/StaticAnalysis/**
|
||||
- tests/StaticAnalysis/**
|
||||
push:
|
||||
branches:
|
||||
- "*.x"
|
||||
@@ -19,8 +18,7 @@ on:
|
||||
- composer.*
|
||||
- src/**
|
||||
- phpstan*
|
||||
- psalm*
|
||||
- tests/Doctrine/StaticAnalysis/**
|
||||
- tests/StaticAnalysis/**
|
||||
|
||||
jobs:
|
||||
static-analysis-phpstan:
|
||||
@@ -48,7 +46,7 @@ jobs:
|
||||
uses: "shivammathur/setup-php@v2"
|
||||
with:
|
||||
coverage: "none"
|
||||
php-version: "8.2"
|
||||
php-version: "8.4"
|
||||
|
||||
- name: "Require specific DBAL version"
|
||||
run: "composer require doctrine/dbal ^${{ matrix.dbal-version }} --no-update"
|
||||
@@ -58,7 +56,7 @@ jobs:
|
||||
run: "composer require doctrine/persistence ^$([ ${{ matrix.persistence-version }} = default ] && echo '3.1' || echo ${{ matrix.persistence-version }}) --no-update"
|
||||
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v2"
|
||||
uses: "ramsey/composer-install@v3"
|
||||
with:
|
||||
dependency-versions: "highest"
|
||||
|
||||
@@ -73,31 +71,3 @@ jobs:
|
||||
- name: "Run a static analysis with phpstan/phpstan"
|
||||
run: "vendor/bin/phpstan analyse -c phpstan-persistence2.neon"
|
||||
if: "${{ matrix.dbal-version == 'default' && matrix.persistence-version != 'default'}}"
|
||||
|
||||
static-analysis-psalm:
|
||||
name: "Static Analysis with Psalm"
|
||||
runs-on: "ubuntu-22.04"
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: "actions/checkout@v4"
|
||||
|
||||
- name: "Install PHP"
|
||||
uses: "shivammathur/setup-php@v2"
|
||||
with:
|
||||
coverage: "none"
|
||||
php-version: "8.2"
|
||||
|
||||
- name: "Require specific persistence version"
|
||||
run: "composer require doctrine/persistence ^3.1 --no-update"
|
||||
|
||||
- name: "Install dependencies with Composer"
|
||||
uses: "ramsey/composer-install@v2"
|
||||
with:
|
||||
dependency-versions: "highest"
|
||||
|
||||
- name: "Run a static analysis with vimeo/psalm"
|
||||
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)"
|
||||
|
||||
40
README.md
40
README.md
@@ -1,7 +1,7 @@
|
||||
| [3.0.x][3.0] | [2.18.x][2.18] | [2.17.x][2.17] |
|
||||
|:----------------:|:----------------:|:----------:|
|
||||
| [![Build status][3.0 image]][3.0] | [![Build status][2.18 image]][2.18] | [![Build status][2.17 image]][2.17] |
|
||||
| [![Coverage Status][3.0 coverage image]][3.0 coverage]| [![Coverage Status][2.18 coverage image]][2.18 coverage] | [![Coverage Status][2.17 coverage image]][2.17 coverage] |
|
||||
| [4.0.x][4.0] | [3.4.x][3.4] | [3.3.x][3.3] | [2.21.x][2.21] | [2.20.x][2.20] |
|
||||
|:------------------------------------------------------:|:------------------------------------------------------:|:------------------------------------------------------:|:--------------------------------------------------------:|:--------------------------------------------------------:|
|
||||
| [![Build status][4.0 image]][4.0] | [![Build status][3.4 image]][3.4] | [![Build status][3.3 image]][3.3] | [![Build status][2.21 image]][2.21] | [![Build status][2.20 image]][2.20] |
|
||||
| [![Coverage Status][4.0 coverage image]][4.0 coverage] | [![Coverage Status][3.4 coverage image]][3.4 coverage] | [![Coverage Status][3.3 coverage image]][3.3 coverage] | [![Coverage Status][2.21 coverage image]][2.21 coverage] | [![Coverage Status][2.20 coverage image]][2.20 coverage] |
|
||||
|
||||
[<h1 align="center">🇺🇦 UKRAINE NEEDS YOUR HELP NOW!</h1>](https://www.doctrine-project.org/stop-war.html)
|
||||
|
||||
@@ -18,15 +18,23 @@ without requiring unnecessary code duplication.
|
||||
* [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
|
||||
[3.0]: https://github.com/doctrine/orm/tree/3.0.x
|
||||
[3.0 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.0.x/graph/badge.svg
|
||||
[3.0 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.0.x
|
||||
[2.18 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.18.x
|
||||
[2.18]: https://github.com/doctrine/orm/tree/2.18.x
|
||||
[2.18 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.18.x/graph/badge.svg
|
||||
[2.18 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.18.x
|
||||
[2.17 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.17.x
|
||||
[2.17]: https://github.com/doctrine/orm/tree/2.17.x
|
||||
[2.17 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.17.x/graph/badge.svg
|
||||
[2.17 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.17.x
|
||||
[4.0 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0.x
|
||||
[4.0]: https://github.com/doctrine/orm/tree/4.0.x
|
||||
[4.0 coverage image]: https://codecov.io/gh/doctrine/orm/branch/4.0.x/graph/badge.svg
|
||||
[4.0 coverage]: https://codecov.io/gh/doctrine/orm/branch/4.0.x
|
||||
[3.4 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.4.x
|
||||
[3.4]: https://github.com/doctrine/orm/tree/3.4.x
|
||||
[3.4 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.4.x/graph/badge.svg
|
||||
[3.4 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.4.x
|
||||
[3.3 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.3.x
|
||||
[3.3]: https://github.com/doctrine/orm/tree/3.3.x
|
||||
[3.3 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.3.x/graph/badge.svg
|
||||
[3.3 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.3.x
|
||||
[2.21 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.21.x
|
||||
[2.21]: https://github.com/doctrine/orm/tree/2.21.x
|
||||
[2.21 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.21.x/graph/badge.svg
|
||||
[2.21 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.21.x
|
||||
[2.20 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.20.x
|
||||
[2.20]: https://github.com/doctrine/orm/tree/2.20.x
|
||||
[2.20 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.20.x/graph/badge.svg
|
||||
[2.20 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.20.x
|
||||
|
||||
53
UPGRADE.md
53
UPGRADE.md
@@ -1,3 +1,56 @@
|
||||
# Upgrade to 2.20
|
||||
|
||||
## Add `Doctrine\ORM\Query\OutputWalker` interface, deprecate `Doctrine\ORM\Query\SqlWalker::getExecutor()`
|
||||
|
||||
Output walkers should implement the new `\Doctrine\ORM\Query\OutputWalker` interface and create
|
||||
`Doctrine\ORM\Query\Exec\SqlFinalizer` instances instead of `Doctrine\ORM\Query\Exec\AbstractSqlExecutor`s.
|
||||
The output walker must not base its workings on the query `firstResult`/`maxResult` values, so that the
|
||||
`SqlFinalizer` can be kept in the query cache and used regardless of the actual `firstResult`/`maxResult` values.
|
||||
Any operation dependent on `firstResult`/`maxResult` should take place within the `SqlFinalizer::createExecutor()`
|
||||
method. Details can be found at https://github.com/doctrine/orm/pull/11188.
|
||||
|
||||
## Explictly forbid property hooks
|
||||
|
||||
Property hooks are not supported yet by Doctrine ORM. Until support is added,
|
||||
they are explicitly forbidden because the support would result in a breaking
|
||||
change in behavior.
|
||||
|
||||
Progress on this is tracked at https://github.com/doctrine/orm/issues/11624 .
|
||||
|
||||
## PARTIAL DQL syntax is undeprecated
|
||||
|
||||
Use of the PARTIAL keyword is not deprecated anymore in DQL, because we will be
|
||||
able to support PARTIAL objects with PHP 8.4 Lazy Objects and
|
||||
Symfony/VarExporter in a better way. When we decided to remove this feature
|
||||
these two abstractions did not exist yet.
|
||||
|
||||
WARNING: If you want to upgrade to 3.x and still use PARTIAL keyword in DQL
|
||||
with array or object hydrators, then you have to directly migrate to ORM 3.3.x or higher.
|
||||
PARTIAL keyword in DQL is not available in 3.0, 3.1 and 3.2 of ORM.
|
||||
|
||||
## Deprecate `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()`
|
||||
|
||||
Use the `\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER` query hint to set the output walker
|
||||
class instead of setting it through the `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()` method
|
||||
on the parser instance.
|
||||
|
||||
# Upgrade to 2.19
|
||||
|
||||
## Deprecate calling `ClassMetadata::getAssociationMappedByTargetField()` with the owning side of an association
|
||||
|
||||
Calling
|
||||
`Doctrine\ORM\Mapping\ClassMetadata::getAssociationMappedByTargetField()` with
|
||||
the owning side of an association returns `null`, which is undocumented, and
|
||||
wrong according to the phpdoc of the parent method.
|
||||
|
||||
If you do not know whether you are on the owning or inverse side of an association,
|
||||
you can use `Doctrine\ORM\Mapping\ClassMetadata::isAssociationInverseSide()`
|
||||
to find out.
|
||||
|
||||
## Deprecate `Doctrine\ORM\Query\Lexer::T_*` constants
|
||||
|
||||
Use `Doctrine\ORM\Query\TokenType::T_*` instead.
|
||||
|
||||
# Upgrade to 2.17
|
||||
|
||||
## Deprecate annotations classes for named queries
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"phpstan/extension-installer": true
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
@@ -42,14 +43,15 @@
|
||||
"doctrine/annotations": "^1.13 || ^2",
|
||||
"doctrine/coding-standard": "^9.0.2 || ^12.0",
|
||||
"phpbench/phpbench": "^0.16.10 || ^1.0",
|
||||
"phpstan/phpstan": "~1.4.10 || 1.10.35",
|
||||
"phpstan/extension-installer": "~1.1.0 || ^1.4",
|
||||
"phpstan/phpstan": "~1.4.10 || 2.0.3",
|
||||
"phpstan/phpstan-deprecation-rules": "^1 || ^2",
|
||||
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6",
|
||||
"psr/log": "^1 || ^2 || ^3",
|
||||
"squizlabs/php_codesniffer": "3.7.2",
|
||||
"symfony/cache": "^4.4 || ^5.4 || ^6.4 || ^7.0",
|
||||
"symfony/var-exporter": "^4.4 || ^5.4 || ^6.2 || ^7.0",
|
||||
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
|
||||
"vimeo/psalm": "4.30.0 || 5.16.0"
|
||||
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/annotations": "<1.13 || >= 3.0"
|
||||
|
||||
4
docs/.gitignore
vendored
4
docs/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
en/_exts/configurationblock.pyc
|
||||
build
|
||||
en/_build
|
||||
.idea
|
||||
3
docs/.gitmodules
vendored
3
docs/.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "en/_theme"]
|
||||
path = en/_theme
|
||||
url = https://github.com/doctrine/doctrine-sphinx-theme.git
|
||||
@@ -1,93 +0,0 @@
|
||||
#Copyright (c) 2010 Fabien Potencier
|
||||
#
|
||||
#Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
#of this software and associated documentation files (the "Software"), to deal
|
||||
#in the Software without restriction, including without limitation the rights
|
||||
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
#copies of the Software, and to permit persons to whom the Software is furnished
|
||||
#to do so, subject to the following conditions:
|
||||
#
|
||||
#The above copyright notice and this permission notice shall be included in all
|
||||
#copies or substantial portions of the Software.
|
||||
#
|
||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
#THE SOFTWARE.
|
||||
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
from docutils import nodes
|
||||
from string import upper
|
||||
|
||||
class configurationblock(nodes.General, nodes.Element):
|
||||
pass
|
||||
|
||||
class ConfigurationBlock(Directive):
|
||||
has_content = True
|
||||
required_arguments = 0
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
option_spec = {}
|
||||
formats = {
|
||||
'html': 'HTML',
|
||||
'xml': 'XML',
|
||||
'php': 'PHP',
|
||||
'yaml': 'YAML',
|
||||
'jinja': 'Twig',
|
||||
'html+jinja': 'Twig',
|
||||
'jinja+html': 'Twig',
|
||||
'php+html': 'PHP',
|
||||
'html+php': 'PHP',
|
||||
'ini': 'INI',
|
||||
'php-annotations': 'Annotations',
|
||||
}
|
||||
|
||||
def run(self):
|
||||
env = self.state.document.settings.env
|
||||
|
||||
node = nodes.Element()
|
||||
node.document = self.state.document
|
||||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
|
||||
entries = []
|
||||
for i, child in enumerate(node):
|
||||
if isinstance(child, nodes.literal_block):
|
||||
# add a title (the language name) before each block
|
||||
#targetid = "configuration-block-%d" % env.new_serialno('configuration-block')
|
||||
#targetnode = nodes.target('', '', ids=[targetid])
|
||||
#targetnode.append(child)
|
||||
|
||||
innernode = nodes.emphasis(self.formats[child['language']], self.formats[child['language']])
|
||||
|
||||
para = nodes.paragraph()
|
||||
para += [innernode, child]
|
||||
|
||||
entry = nodes.list_item('')
|
||||
entry.append(para)
|
||||
entries.append(entry)
|
||||
|
||||
resultnode = configurationblock()
|
||||
resultnode.append(nodes.bullet_list('', *entries))
|
||||
|
||||
return [resultnode]
|
||||
|
||||
def visit_configurationblock_html(self, node):
|
||||
self.body.append(self.starttag(node, 'div', CLASS='configuration-block'))
|
||||
|
||||
def depart_configurationblock_html(self, node):
|
||||
self.body.append('</div>\n')
|
||||
|
||||
def visit_configurationblock_latex(self, node):
|
||||
pass
|
||||
|
||||
def depart_configurationblock_latex(self, node):
|
||||
pass
|
||||
|
||||
def setup(app):
|
||||
app.add_node(configurationblock,
|
||||
html=(visit_configurationblock_html, depart_configurationblock_html),
|
||||
latex=(visit_configurationblock_latex, depart_configurationblock_latex))
|
||||
app.add_directive('configuration-block', ConfigurationBlock)
|
||||
Submodule docs/en/_theme deleted from 6f1bc8bead
@@ -99,12 +99,12 @@ discuss it step by step:
|
||||
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER); // (2)
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS); // (3)
|
||||
$parser->match(TokenType::T_IDENTIFIER); // (2)
|
||||
$parser->match(TokenType::T_OPEN_PARENTHESIS); // (3)
|
||||
$this->firstDateExpression = $parser->ArithmeticPrimary(); // (4)
|
||||
$parser->match(Lexer::T_COMMA); // (5)
|
||||
$parser->match(TokenType::T_COMMA); // (5)
|
||||
$this->secondDateExpression = $parser->ArithmeticPrimary(); // (6)
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS); // (3)
|
||||
$parser->match(TokenType::T_CLOSE_PARENTHESIS); // (3)
|
||||
}
|
||||
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
@@ -183,23 +183,23 @@ I'll skip the blah and show the code for this function:
|
||||
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
$parser->match(TokenType::T_IDENTIFIER);
|
||||
$parser->match(TokenType::T_OPEN_PARENTHESIS);
|
||||
|
||||
$this->firstDateExpression = $parser->ArithmeticPrimary();
|
||||
|
||||
$parser->match(Lexer::T_COMMA);
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(TokenType::T_COMMA);
|
||||
$parser->match(TokenType::T_IDENTIFIER);
|
||||
|
||||
$this->intervalExpression = $parser->ArithmeticPrimary();
|
||||
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(TokenType::T_IDENTIFIER);
|
||||
|
||||
/** @var Lexer $lexer */
|
||||
$lexer = $parser->getLexer();
|
||||
$this->unit = $lexer->token['value'];
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Implementing ArrayAccess for Domain Objects
|
||||
===========================================
|
||||
|
||||
.. sectionauthor:: Roman Borschel (roman@code-factory.org)
|
||||
.. sectionauthor:: Roman Borschel <roman@code-factory.org>
|
||||
|
||||
This recipe will show you how to implement ArrayAccess for your
|
||||
domain objects in order to allow more uniform access, for example
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Implementing the Notify ChangeTracking Policy
|
||||
=============================================
|
||||
|
||||
.. sectionauthor:: Roman Borschel (roman@code-factory.org)
|
||||
.. sectionauthor:: Roman Borschel <roman@code-factory.org>
|
||||
|
||||
The NOTIFY change-tracking policy is the most effective
|
||||
change-tracking policy provided by Doctrine but it requires some
|
||||
|
||||
@@ -11,7 +11,7 @@ What we offer are hooks to execute any kind of validation.
|
||||
.. note::
|
||||
|
||||
You don't need to validate your entities in the lifecycle
|
||||
events. Its only one of many options. Of course you can also
|
||||
events. It is only one of many options. Of course you can also
|
||||
perform validations in value setters or any other method of your
|
||||
entities that are used in your code.
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ Tutorials
|
||||
Changelogs
|
||||
----------
|
||||
|
||||
* `Upgrade <https://github.com/doctrine/doctrine2/blob/master/UPGRADE.md>`_
|
||||
* `Upgrade <https://github.com/doctrine/orm/blob/HEAD/UPGRADE.md>`_
|
||||
|
||||
Cookbook
|
||||
--------
|
||||
|
||||
113
docs/en/make.bat
113
docs/en/make.bat
@@ -1,113 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
set SPHINXBUILD=sphinx-build
|
||||
set BUILDDIR=_build
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||
if NOT "%PAPER%" == "" (
|
||||
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
if "%1" == "help" (
|
||||
:help
|
||||
echo.Please use `make ^<target^>` where ^<target^> is one of
|
||||
echo. html to make standalone HTML files
|
||||
echo. dirhtml to make HTML files named index.html in directories
|
||||
echo. pickle to make pickle files
|
||||
echo. json to make JSON files
|
||||
echo. htmlhelp to make HTML files and a HTML help project
|
||||
echo. qthelp to make HTML files and a qthelp project
|
||||
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
||||
echo. changes to make an overview over all changed/added/deprecated items
|
||||
echo. linkcheck to check all external links for integrity
|
||||
echo. doctest to run all doctests embedded in the documentation if enabled
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "clean" (
|
||||
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
||||
del /q /s %BUILDDIR%\*
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "html" (
|
||||
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "dirhtml" (
|
||||
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pickle" (
|
||||
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
||||
echo.
|
||||
echo.Build finished; now you can process the pickle files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "json" (
|
||||
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
||||
echo.
|
||||
echo.Build finished; now you can process the JSON files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "htmlhelp" (
|
||||
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||
echo.
|
||||
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "qthelp" (
|
||||
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
||||
echo.
|
||||
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Doctrine2ORM.qhcp
|
||||
echo.To view the help file:
|
||||
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Doctrine2ORM.ghc
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latex" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
echo.
|
||||
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "changes" (
|
||||
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
||||
echo.
|
||||
echo.The overview file is in %BUILDDIR%/changes.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "linkcheck" (
|
||||
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
||||
echo.
|
||||
echo.Link check complete; look for any errors in the above output ^
|
||||
or in %BUILDDIR%/linkcheck/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "doctest" (
|
||||
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
||||
echo.
|
||||
echo.Testing of doctests in the sources finished, look at the ^
|
||||
results in %BUILDDIR%/doctest/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
:end
|
||||
@@ -1300,8 +1300,8 @@ This is essentially the same as the following, more verbose, mapping:
|
||||
* @var Collection<int, Group>
|
||||
*/
|
||||
#[JoinTable(name: 'User_Group')]
|
||||
#[JoinColumn(name: 'User_id', referencedColumnName: 'id')]
|
||||
#[InverseJoinColumn(name: 'Group_id', referencedColumnName: 'id')]
|
||||
#[JoinColumn(name: 'user_id', referencedColumnName: 'id')]
|
||||
#[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')]
|
||||
#[ManyToMany(targetEntity: Group::class)]
|
||||
private Collection $groups;
|
||||
// ...
|
||||
@@ -1333,10 +1333,10 @@ This is essentially the same as the following, more verbose, mapping:
|
||||
<many-to-many field="groups" target-entity="Group">
|
||||
<join-table name="User_Group">
|
||||
<join-columns>
|
||||
<join-column id="User_id" referenced-column-name="id" />
|
||||
<join-column id="user_id" referenced-column-name="id" />
|
||||
</join-columns>
|
||||
<inverse-join-columns>
|
||||
<join-column id="Group_id" referenced-column-name="id" />
|
||||
<join-column id="group_id" referenced-column-name="id" />
|
||||
</inverse-join-columns>
|
||||
</join-table>
|
||||
</many-to-many>
|
||||
@@ -1368,8 +1368,7 @@ defaults to "id", just as in one-to-one or many-to-one mappings.
|
||||
|
||||
Additionally, when using typed properties with Doctrine 2.9 or newer
|
||||
you can skip ``targetEntity`` in ``ManyToOne`` and ``OneToOne``
|
||||
associations as they will be set based on type. Also ``nullable``
|
||||
attribute on ``JoinColumn`` will be inherited from PHP type. So that:
|
||||
associations as they will be set based on type. So that:
|
||||
|
||||
.. configuration-block::
|
||||
|
||||
@@ -1409,7 +1408,7 @@ Is essentially the same as following:
|
||||
<?php
|
||||
/** One Product has One Shipment. */
|
||||
#[OneToOne(targetEntity: Shipment::class)]
|
||||
#[JoinColumn(name: 'shipment_id', referencedColumnName: 'id', nullable: false)]
|
||||
#[JoinColumn(name: 'shipment_id', referencedColumnName: 'id')]
|
||||
private Shipment $shipment;
|
||||
|
||||
.. code-block:: annotation
|
||||
@@ -1418,7 +1417,7 @@ Is essentially the same as following:
|
||||
/**
|
||||
* One Product has One Shipment.
|
||||
* @OneToOne(targetEntity="Shipment")
|
||||
* @JoinColumn(name="shipment_id", referencedColumnName="id", nullable=false)
|
||||
* @JoinColumn(name="shipment_id", referencedColumnName="id")
|
||||
*/
|
||||
private Shipment $shipment;
|
||||
|
||||
@@ -1442,7 +1441,6 @@ Is essentially the same as following:
|
||||
joinColumn:
|
||||
name: shipment_id
|
||||
referencedColumnName: id
|
||||
nullable: false
|
||||
|
||||
If you accept these defaults, you can reduce the mapping code to a
|
||||
minimum.
|
||||
|
||||
@@ -14,7 +14,7 @@ Index
|
||||
- :ref:`#[AttributeOverride] <attrref_attributeoverride>`
|
||||
- :ref:`#[Column] <attrref_column>`
|
||||
- :ref:`#[Cache] <attrref_cache>`
|
||||
- :ref:`#[ChangeTrackingPolicy <attrref_changetrackingpolicy>`
|
||||
- :ref:`#[ChangeTrackingPolicy] <attrref_changetrackingpolicy>`
|
||||
- :ref:`#[CustomIdGenerator] <attrref_customidgenerator>`
|
||||
- :ref:`#[DiscriminatorColumn] <attrref_discriminatorcolumn>`
|
||||
- :ref:`#[DiscriminatorMap] <attrref_discriminatormap>`
|
||||
|
||||
@@ -239,6 +239,7 @@ Here is a complete list of ``Column``s attributes (all optional):
|
||||
- ``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.
|
||||
- ``generated`` (default: ``null``): Whether the generated strategy should be ``'NEVER'``, ``'INSERT'`` and ``ALWAYS``.
|
||||
- ``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),
|
||||
@@ -300,50 +301,12 @@ and a custom ``Doctrine\ORM\Mapping\TypedFieldMapper`` implementation.
|
||||
Doctrine Mapping Types
|
||||
----------------------
|
||||
|
||||
The ``type`` option used in the ``@Column`` accepts any of the existing
|
||||
Doctrine types or even your own custom types. A Doctrine type defines
|
||||
The ``type`` option used in the ``@Column`` accepts any of the
|
||||
`existing Doctrine DBAL types <https://docs.doctrine-project.org/projects/doctrine-dbal/en/stable/reference/types.html#reference>`_
|
||||
or :doc:`your own custom mapping types
|
||||
<../cookbook/custom-mapping-types>`. A Doctrine type defines
|
||||
the conversion between PHP and SQL types, independent from the database vendor
|
||||
you are using. All Mapping Types that ship with Doctrine are fully portable
|
||||
between the supported database systems.
|
||||
|
||||
As an example, the Doctrine Mapping Type ``string`` defines the
|
||||
mapping from a PHP string to a SQL VARCHAR (or VARCHAR2 etc.
|
||||
depending on the RDBMS brand). Here is a quick overview of the
|
||||
built-in mapping types:
|
||||
|
||||
- ``string``: Type that maps a SQL VARCHAR to a PHP string.
|
||||
- ``integer``: Type that maps a SQL INT to a PHP integer.
|
||||
- ``smallint``: Type that maps a database SMALLINT to a PHP
|
||||
integer.
|
||||
- ``bigint``: Type that maps a database BIGINT to a PHP string.
|
||||
- ``boolean``: Type that maps a SQL boolean or equivalent (TINYINT) to a PHP boolean.
|
||||
- ``decimal``: Type that maps a SQL DECIMAL to a PHP string.
|
||||
- ``date``: Type that maps a SQL DATETIME to a PHP DateTime
|
||||
object.
|
||||
- ``time``: Type that maps a SQL TIME to a PHP DateTime object.
|
||||
- ``datetime``: Type that maps a SQL DATETIME/TIMESTAMP to a PHP
|
||||
DateTime object.
|
||||
- ``datetimetz``: Type that maps a SQL DATETIME/TIMESTAMP to a PHP
|
||||
DateTime object with timezone.
|
||||
- ``text``: Type that maps a SQL CLOB to a PHP string.
|
||||
- ``object``: Type that maps a SQL CLOB to a PHP object using
|
||||
``serialize()`` and ``unserialize()``
|
||||
- ``array``: Type that maps a SQL CLOB to a PHP array using
|
||||
``serialize()`` and ``unserialize()``
|
||||
- ``simple_array``: Type that maps a SQL CLOB to a PHP array using
|
||||
``implode()`` and ``explode()``, with a comma as delimiter. *IMPORTANT*
|
||||
Only use this type if you are sure that your values cannot contain a ",".
|
||||
- ``json_array``: Type that maps a SQL CLOB to a PHP array using
|
||||
``json_encode()`` and ``json_decode()``
|
||||
- ``float``: Type that maps a SQL Float (Double Precision) to a
|
||||
PHP double. *IMPORTANT*: Works only with locale settings that use
|
||||
decimal points as separator.
|
||||
- ``guid``: Type that maps a database GUID/UUID to a PHP string. Defaults to
|
||||
varchar but uses a specific type if the platform supports it.
|
||||
- ``blob``: Type that maps a SQL BLOB to a PHP resource stream
|
||||
|
||||
A cookbook article shows how to define :doc:`your own custom mapping types
|
||||
<../cookbook/custom-mapping-types>`.
|
||||
you are using.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -462,7 +425,7 @@ Here is the list of possible generation strategies:
|
||||
a new entity is passed to ``EntityManager#persist``. NONE is the
|
||||
same as leaving off the ``#[GeneratedValue]`` entirely.
|
||||
- ``CUSTOM``: With this option, you can use the ``#[CustomIdGenerator]`` attribute.
|
||||
It will allow you to pass a :ref:`class of your own to generate the identifiers.<annref_customidgenerator>`
|
||||
It will allow you to pass a :ref:`class of your own to generate the identifiers. <annref_customidgenerator>`
|
||||
|
||||
Sequence Generator
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -18,14 +18,20 @@ especially what the strategies presented here provide help with.
|
||||
|
||||
.. note::
|
||||
|
||||
Having an SQL logger enabled when processing batches can have a serious impact on performance and resource usage.
|
||||
To avoid that you should remove the corresponding middleware.
|
||||
To remove all middlewares, you can use this line:
|
||||
Having an SQL logger enabled when processing batches can have a
|
||||
serious impact on performance and resource usage.
|
||||
To avoid that, you should use a PSR logger implementation that can be
|
||||
disabled at runtime.
|
||||
For example, with Monolog, you can use ``Logger::pushHandler()``
|
||||
to push a ``NullHandler`` to the logger instance, and then pop it
|
||||
when you need to enable logging again.
|
||||
|
||||
With DBAL 2, you can disable the SQL logger like below:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$em->getConnection()->getConfiguration()->setMiddlewares([]); // DBAL 3
|
||||
$em->getConnection()->getConfiguration()->setSQLLogger(null); // DBAL 2
|
||||
$em->getConnection()->getConfiguration()->setSQLLogger(null);
|
||||
|
||||
Bulk Inserts
|
||||
------------
|
||||
@@ -188,6 +194,3 @@ problems using the following approach:
|
||||
Iterating results is not possible with queries that
|
||||
fetch-join a collection-valued association. The nature of such SQL
|
||||
result sets is not suitable for incremental hydration.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -812,7 +812,7 @@ classes have to implement the base class :
|
||||
namespace MyProject\Query\AST;
|
||||
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\Lexer;
|
||||
use Doctrine\ORM\Query\TokenType;
|
||||
|
||||
class MysqlFloor extends FunctionNode
|
||||
{
|
||||
@@ -827,12 +827,12 @@ classes have to implement the base class :
|
||||
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
$parser->match(TokenType::T_IDENTIFIER);
|
||||
$parser->match(TokenType::T_OPEN_PARENTHESIS);
|
||||
|
||||
$this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1003,7 +1003,7 @@ The Query class
|
||||
---------------
|
||||
|
||||
An instance of the ``Doctrine\ORM\Query`` class represents a DQL
|
||||
query. You create a Query instance be calling
|
||||
query. You create a Query instance by calling
|
||||
``EntityManager#createQuery($dql)``, passing the DQL query string.
|
||||
Alternatively you can create an empty ``Query`` instance and invoke
|
||||
``Query#setDQL($dql)`` afterwards. Here are some examples:
|
||||
@@ -1020,58 +1020,146 @@ Alternatively you can create an empty ``Query`` instance and invoke
|
||||
$q = $em->createQuery();
|
||||
$q->setDQL('select u from MyProject\Model\User u');
|
||||
|
||||
Query Result Formats
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
Query Result Formats (Hydration Modes)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The format in which the result of a DQL SELECT query is returned
|
||||
can be influenced by a so-called ``hydration mode``. A hydration
|
||||
mode specifies a particular way in which a SQL result set is
|
||||
transformed. Each hydration mode has its own dedicated method on
|
||||
the Query class. Here they are:
|
||||
The way in which the SQL result set of a DQL SELECT query is transformed
|
||||
to PHP is determined by the so-called "hydration mode".
|
||||
|
||||
``getResult()``
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
- ``Query#getResult()``: Retrieves a collection of objects. The
|
||||
result is either a plain collection of objects (pure) or an array
|
||||
where the objects are nested in the result rows (mixed).
|
||||
- ``Query#getSingleResult()``: Retrieves a single object. If the
|
||||
result contains more than one object, an ``NonUniqueResultException``
|
||||
is thrown. If the result contains no objects, an ``NoResultException``
|
||||
is thrown. The pure/mixed distinction does not apply.
|
||||
- ``Query#getOneOrNullResult()``: Retrieve a single object. If the
|
||||
result contains more than one object, a ``NonUniqueResultException``
|
||||
is thrown. If no object is found null will be returned.
|
||||
- ``Query#getArrayResult()``: Retrieves an array graph (a nested
|
||||
array) that is largely interchangeable with the object graph
|
||||
generated by ``Query#getResult()`` for read-only purposes.
|
||||
Retrieves a collection of objects. The result is either a plain collection of objects (pure) or an array
|
||||
where the objects are nested in the result rows (mixed):
|
||||
|
||||
.. note::
|
||||
.. code-block:: php
|
||||
|
||||
An array graph can differ from the corresponding object
|
||||
graph in certain scenarios due to the difference of the identity
|
||||
semantics between arrays and objects.
|
||||
<?php
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
|
||||
$query = $em->createQuery('SELECT u FROM User u');
|
||||
$users = $query->getResult();
|
||||
// same as:
|
||||
$users = $query->getResult(AbstractQuery::HYDRATE_OBJECT);
|
||||
|
||||
- Objects fetched in a FROM clause are returned as a Set, that means every
|
||||
object is only ever included in the resulting array once. This is the case
|
||||
even when using JOIN or GROUP BY in ways that return the same row for an
|
||||
object multiple times. If the hydrator sees the same object multiple times,
|
||||
then it makes sure it is only returned once.
|
||||
|
||||
- ``Query#getScalarResult()``: Retrieves a flat/rectangular result
|
||||
set of scalar values that can contain duplicate data. The
|
||||
pure/mixed distinction does not apply.
|
||||
- ``Query#getSingleScalarResult()``: Retrieves a single scalar
|
||||
value from the result returned by the dbms. If the result contains
|
||||
more than a single scalar value, an exception is thrown. The
|
||||
pure/mixed distinction does not apply.
|
||||
- If an object is already in memory from a previous query of any kind, then
|
||||
then the previous object is used, even if the database may contain more
|
||||
recent data. This even happens if the previous object is still an unloaded proxy.
|
||||
|
||||
Instead of using these methods, you can alternatively use the
|
||||
general-purpose method
|
||||
``Query#execute(array $params = [], $hydrationMode = Query::HYDRATE_OBJECT)``.
|
||||
Using this method you can directly supply the hydration mode as the
|
||||
second parameter via one of the Query constants. In fact, the
|
||||
methods mentioned earlier are just convenient shortcuts for the
|
||||
execute method. For example, the method ``Query#getResult()``
|
||||
internally invokes execute, passing in ``Query::HYDRATE_OBJECT`` as
|
||||
the hydration mode.
|
||||
``getArrayResult()``
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The use of the methods mentioned earlier is generally preferred as
|
||||
it leads to more concise code.
|
||||
Retrieves an array graph (a nested array) for read-only purposes.
|
||||
|
||||
.. note::
|
||||
|
||||
An array graph can differ from the corresponding object
|
||||
graph in certain scenarios due to the difference of the identity
|
||||
semantics between arrays and objects.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$users = $query->getArrayResult();
|
||||
// same as:
|
||||
$users = $query->getResult(AbstractQuery::HYDRATE_ARRAY);
|
||||
|
||||
``getScalarResult()``
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Retrieves a flat/rectangular result set of scalar values that can contain duplicate data. The
|
||||
pure/mixed distinction does not apply.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$users = $query->getScalarResult();
|
||||
// same as:
|
||||
$users = $query->getResult(AbstractQuery::HYDRATE_SCALAR);
|
||||
|
||||
Fields from classes are prefixed by the DQL alias in the result.
|
||||
A query of the kind `SELECT u.name ...` returns a key `u_name` in the result rows.
|
||||
|
||||
``getSingleScalarResult()``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Retrieves a single scalar value from the result returned by the database. If the result contains
|
||||
more than a single scalar value, a ``NonUniqueResultException`` is thrown. The pure/mixed distinction does not apply.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT COUNT(u.id) FROM User u');
|
||||
$numUsers = $query->getSingleScalarResult();
|
||||
// same as:
|
||||
$numUsers = $query->getResult(AbstractQuery::HYDRATE_SINGLE_SCALAR);
|
||||
|
||||
``getSingleColumnResult()``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Retrieves an array from a one-dimensional array of scalar values:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT a.id FROM User u');
|
||||
$ids = $query->getSingleColumnResult();
|
||||
// same as:
|
||||
$ids = $query->getResult(AbstractQuery::HYDRATE_SCALAR_COLUMN);
|
||||
|
||||
``getSingleResult()``
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Retrieves a single object. If the result contains more than one object, a ``NonUniqueResultException``
|
||||
is thrown. If the result contains no objects, a ``NoResultException`` is thrown. The pure/mixed distinction does not apply.
|
||||
|
||||
``getOneOrNullResult()``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Retrieves a single object. If the result contains more than one object, a ``NonUniqueResultException``
|
||||
is thrown. If no object is found, ``null`` will be returned.
|
||||
|
||||
Custom Hydration Modes
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You can easily add your own custom hydration modes by first
|
||||
creating a class which extends ``AbstractHydrator``:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
namespace MyProject\Hydrators;
|
||||
|
||||
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
|
||||
|
||||
class CustomHydrator extends AbstractHydrator
|
||||
{
|
||||
protected function _hydrateAll()
|
||||
{
|
||||
return $this->_stmt->fetchAllAssociative();
|
||||
}
|
||||
}
|
||||
|
||||
Next you just need to add the class to the ORM configuration:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$em->getConfiguration()->addCustomHydrationMode('CustomHydrator', 'MyProject\Hydrators\CustomHydrator');
|
||||
|
||||
Now the hydrator is ready to be used in your queries:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT u FROM CmsUser u');
|
||||
$results = $query->getResult('CustomHydrator');
|
||||
|
||||
Pure and Mixed Results
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -1175,165 +1263,6 @@ will return the rows iterating the different top-level entities.
|
||||
[2] => Object (User)
|
||||
[3] => Object (Group)
|
||||
|
||||
|
||||
Hydration Modes
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Each of the Hydration Modes makes assumptions about how the result
|
||||
is returned to user land. You should know about all the details to
|
||||
make best use of the different result formats:
|
||||
|
||||
The constants for the different hydration modes are:
|
||||
|
||||
|
||||
- ``Query::HYDRATE_OBJECT``
|
||||
- ``Query::HYDRATE_ARRAY``
|
||||
- ``Query::HYDRATE_SCALAR``
|
||||
- ``Query::HYDRATE_SINGLE_SCALAR``
|
||||
- ``Query::HYDRATE_SCALAR_COLUMN``
|
||||
|
||||
Object Hydration
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Object hydration hydrates the result set into the object graph:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT u FROM CmsUser u');
|
||||
$users = $query->getResult(Query::HYDRATE_OBJECT);
|
||||
|
||||
Sometimes the behavior in the object hydrator can be confusing, which is
|
||||
why we are listing as many of the assumptions here for reference:
|
||||
|
||||
- Objects fetched in a FROM clause are returned as a Set, that means every
|
||||
object is only ever included in the resulting array once. This is the case
|
||||
even when using JOIN or GROUP BY in ways that return the same row for an
|
||||
object multiple times. If the hydrator sees the same object multiple times,
|
||||
then it makes sure it is only returned once.
|
||||
|
||||
- If an object is already in memory from a previous query of any kind, then
|
||||
then the previous object is used, even if the database may contain more
|
||||
recent data. Data from the database is discarded. This even happens if the
|
||||
previous object is still an unloaded proxy.
|
||||
|
||||
This list might be incomplete.
|
||||
|
||||
Array Hydration
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
You can run the same query with array hydration and the result set
|
||||
is hydrated into an array that represents the object graph:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT u FROM CmsUser u');
|
||||
$users = $query->getResult(Query::HYDRATE_ARRAY);
|
||||
|
||||
You can use the ``getArrayResult()`` shortcut as well:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$users = $query->getArrayResult();
|
||||
|
||||
Scalar Hydration
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
If you want to return a flat rectangular result set instead of an
|
||||
object graph you can use scalar hydration:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT u FROM CmsUser u');
|
||||
$users = $query->getResult(Query::HYDRATE_SCALAR);
|
||||
echo $users[0]['u_id'];
|
||||
|
||||
The following assumptions are made about selected fields using
|
||||
Scalar Hydration:
|
||||
|
||||
|
||||
1. Fields from classes are prefixed by the DQL alias in the result.
|
||||
A query of the kind 'SELECT u.name ..' returns a key 'u_name' in
|
||||
the result rows.
|
||||
|
||||
Single Scalar Hydration
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If you have a query which returns just a single scalar value you can use
|
||||
single scalar hydration:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT COUNT(a.id) FROM CmsUser u LEFT JOIN u.articles a WHERE u.username = ?1 GROUP BY u.id');
|
||||
$query->setParameter(1, 'jwage');
|
||||
$numArticles = $query->getResult(Query::HYDRATE_SINGLE_SCALAR);
|
||||
|
||||
You can use the ``getSingleScalarResult()`` shortcut as well:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$numArticles = $query->getSingleScalarResult();
|
||||
|
||||
Scalar Column Hydration
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If you have a query which returns a one-dimensional array of scalar values
|
||||
you can use scalar column hydration:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT a.id FROM CmsUser u');
|
||||
$ids = $query->getResult(Query::HYDRATE_SCALAR_COLUMN);
|
||||
|
||||
You can use the ``getSingleColumnResult()`` shortcut as well:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$ids = $query->getSingleColumnResult();
|
||||
|
||||
Custom Hydration Modes
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You can easily add your own custom hydration modes by first
|
||||
creating a class which extends ``AbstractHydrator``:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
namespace MyProject\Hydrators;
|
||||
|
||||
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
|
||||
|
||||
class CustomHydrator extends AbstractHydrator
|
||||
{
|
||||
protected function _hydrateAll()
|
||||
{
|
||||
return $this->_stmt->fetchAllAssociative();
|
||||
}
|
||||
}
|
||||
|
||||
Next you just need to add the class to the ORM configuration:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$em->getConfiguration()->addCustomHydrationMode('CustomHydrator', 'MyProject\Hydrators\CustomHydrator');
|
||||
|
||||
Now the hydrator is ready to be used in your queries:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$query = $em->createQuery('SELECT u FROM CmsUser u');
|
||||
$results = $query->getResult('CustomHydrator');
|
||||
|
||||
Iterating Large Result Sets
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -131,47 +131,47 @@ There are two ways to set up an event handler:
|
||||
* For *all events* you can create a Lifecycle Event Listener or Subscriber class and register
|
||||
it by calling ``$eventManager->addEventListener()`` or ``eventManager->addEventSubscriber()``,
|
||||
see
|
||||
:ref:`Listening and subscribing to Lifecycle Events<listening-and-subscribing-to-lifecycle-events>`
|
||||
:ref:`Listening and subscribing to Lifecycle Events <listening-and-subscribing-to-lifecycle-events>`
|
||||
* For *some events* (see table below), you can create a *Lifecycle Callback* method in the
|
||||
entity, see :ref:`Lifecycle Callbacks<lifecycle-callbacks>`.
|
||||
entity, see :ref:`Lifecycle Callbacks <lifecycle-callbacks>`.
|
||||
|
||||
.. _reference-events-lifecycle-events:
|
||||
|
||||
Events Overview
|
||||
---------------
|
||||
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| Event | Dispatched by | Lifecycle | Passed |
|
||||
| | | Callback | Argument |
|
||||
+=================================================================+=======================+===========+=====================================+
|
||||
| :ref:`preRemove<reference-events-pre-remove>` | ``$em->remove()`` | Yes | `PreRemoveEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postRemove<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `PostRemoveEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`prePersist<reference-events-pre-persist>` | ``$em->persist()`` | Yes | `PrePersistEventArgs`_ |
|
||||
| | on *initial* persist | | |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postPersist<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `PostPersistEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`preUpdate<reference-events-pre-update>` | ``$em->flush()`` | Yes | `PreUpdateEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postUpdate<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `PostUpdateEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postLoad<reference-events-post-load>` | Loading from database | Yes | `PostLoadEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`loadClassMetadata<reference-events-load-class-metadata>` | Loading of mapping | No | `LoadClassMetadataEventArgs`_ |
|
||||
| | metadata | | |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| ``onClassMetadataNotFound`` | ``MappingException`` | No | `OnClassMetadataNotFoundEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`preFlush<reference-events-pre-flush>` | ``$em->flush()`` | Yes | `PreFlushEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`onFlush<reference-events-on-flush>` | ``$em->flush()`` | No | `OnFlushEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postFlush<reference-events-post-flush>` | ``$em->flush()`` | No | `PostFlushEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`onClear<reference-events-on-clear>` | ``$em->clear()`` | No | `OnClearEventArgs`_ |
|
||||
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| Event | Dispatched by | Lifecycle | Passed |
|
||||
| | | Callback | Argument |
|
||||
+==================================================================+=======================+===========+=====================================+
|
||||
| :ref:`preRemove <reference-events-pre-remove>` | ``$em->remove()`` | Yes | `PreRemoveEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postRemove <reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `PostRemoveEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`prePersist <reference-events-pre-persist>` | ``$em->persist()`` | Yes | `PrePersistEventArgs`_ |
|
||||
| | on *initial* persist | | |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postPersist <reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `PostPersistEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`preUpdate <reference-events-pre-update>` | ``$em->flush()`` | Yes | `PreUpdateEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postUpdate <reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `PostUpdateEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postLoad <reference-events-post-load>` | Loading from database | Yes | `PostLoadEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`loadClassMetadata <reference-events-load-class-metadata>` | Loading of mapping | No | `LoadClassMetadataEventArgs`_ |
|
||||
| | metadata | | |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| ``onClassMetadataNotFound`` | ``MappingException`` | No | `OnClassMetadataNotFoundEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`preFlush <reference-events-pre-flush>` | ``$em->flush()`` | Yes | `PreFlushEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`onFlush <reference-events-on-flush>` | ``$em->flush()`` | No | `OnFlushEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`postFlush <reference-events-post-flush>` | ``$em->flush()`` | No | `PostFlushEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
| :ref:`onClear <reference-events-on-clear>` | ``$em->clear()`` | No | `OnClearEventArgs`_ |
|
||||
+------------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
|
||||
|
||||
.. warning::
|
||||
|
||||
@@ -358,7 +358,7 @@ behaviors across different entity classes.
|
||||
|
||||
Note that they require much more detailed knowledge about the inner
|
||||
workings of the ``EntityManager`` and ``UnitOfWork`` classes. Please
|
||||
read the :ref:`Implementing Event Listeners<reference-events-implementing-listeners>` section
|
||||
read the :ref:`Implementing Event Listeners <reference-events-implementing-listeners>` section
|
||||
carefully if you are trying to write your own listener.
|
||||
|
||||
For event subscribers, there are no surprises. They declare the
|
||||
@@ -471,11 +471,11 @@ prePersist
|
||||
There are two ways for the ``prePersist`` event to be triggered:
|
||||
|
||||
- One is when you call ``EntityManager::persist()``. The
|
||||
event is also called for all :ref:`cascaded associations<transitive-persistence>`.
|
||||
event is also called for all :ref:`cascaded associations <transitive-persistence>`.
|
||||
- The other is inside the ``flush()`` method when changes to associations are computed and
|
||||
this association is marked as :ref:`cascade: persist<transitive-persistence>`. Any new entity found
|
||||
this association is marked as :ref:`cascade: persist <transitive-persistence>`. Any new entity found
|
||||
during this operation is also persisted and ``prePersist`` called
|
||||
on it. This is called :ref:`persistence by reachability<persistence-by-reachability>`.
|
||||
on it. This is called :ref:`persistence by reachability <persistence-by-reachability>`.
|
||||
|
||||
In both cases you get passed a ``PrePersistEventArgs`` instance
|
||||
which has access to the entity and the entity manager.
|
||||
@@ -499,7 +499,7 @@ preRemove
|
||||
|
||||
The ``preRemove`` event is called on every entity immediately when it is passed
|
||||
to the ``EntityManager::remove()`` method. It is cascaded for all
|
||||
associations that are marked as :ref:`cascade: remove<transitive-persistence>`
|
||||
associations that are marked as :ref:`cascade: remove <transitive-persistence>`
|
||||
|
||||
It is not called for a DQL ``DELETE`` statement.
|
||||
|
||||
@@ -547,7 +547,7 @@ entities and their associations have been computed. This means, the
|
||||
- Collections scheduled for removal
|
||||
|
||||
To make use of the ``onFlush`` event you have to be familiar with the
|
||||
internal :ref:`UnitOfWork<unit-of-work>` API, which grants you access to the previously
|
||||
internal :ref:`UnitOfWork <unit-of-work>` API, which grants you access to the previously
|
||||
mentioned sets. See this example:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
@@ -101,7 +101,7 @@ The many-to-many association is only supporting foreign keys in the table defini
|
||||
To work with many-to-many tables containing extra columns you have to use the
|
||||
foreign keys as primary keys feature of Doctrine ORM.
|
||||
|
||||
See :doc:`the tutorial on composite primary keys for more information<../tutorials/composite-primary-keys>`.
|
||||
See :doc:`the tutorial on composite primary keys for more information <../tutorials/composite-primary-keys>`.
|
||||
|
||||
|
||||
How can i paginate fetch-joined collections?
|
||||
|
||||
@@ -380,7 +380,7 @@ It is not supported to use overrides in entity inheritance scenarios.
|
||||
.. note::
|
||||
|
||||
When using traits, make sure not to miss the warnings given in the
|
||||
:doc:`Limitations and Known Issues</reference/limitations-and-known-issues>` chapter.
|
||||
:doc:`Limitations and Known Issues </reference/limitations-and-known-issues>` chapter.
|
||||
|
||||
|
||||
Association Override
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
:orphan:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ implements the ``MappingDriver`` interface:
|
||||
/**
|
||||
* Loads the metadata for the specified class into the provided container.
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
* @psalm-param ClassMetadata<T> $metadata
|
||||
* @param class-string<T> $className
|
||||
* @param ClassMetadata<T> $metadata
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -93,8 +93,7 @@ implements the ``MappingDriver`` interface:
|
||||
/**
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
* @return array<int, string> The names of all mapped classes known to this driver.
|
||||
* @psalm-return list<class-string>
|
||||
* @return list<class-string> The names of all mapped classes known to this driver.
|
||||
*/
|
||||
public function getAllClassNames();
|
||||
|
||||
@@ -102,7 +101,7 @@ implements the ``MappingDriver`` interface:
|
||||
* Returns whether the class with the specified name should have its metadata loaded.
|
||||
* This is only the case if it is either mapped as an Entity or a MappedSuperclass.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @param class-string $className
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -88,7 +88,7 @@ requirement.
|
||||
|
||||
A more convenient alternative for explicit transaction demarcation is the use
|
||||
of provided control abstractions in the form of
|
||||
``Connection#transactional($func)`` and ``EntityManager#transactional($func)``.
|
||||
``Connection#transactional($func)`` and ``EntityManager#wrapInTransaction($func)``.
|
||||
When used, these control abstractions ensure that you never forget to rollback
|
||||
the transaction, in addition to the obvious code reduction. An example that is
|
||||
functionally equivalent to the previously shown code looks as follows:
|
||||
@@ -96,21 +96,23 @@ functionally equivalent to the previously shown code looks as follows:
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// transactional with Connection instance
|
||||
// $conn instanceof Connection
|
||||
$conn->transactional(function($conn) {
|
||||
// ... do some work
|
||||
$user = new User;
|
||||
$user->setName('George');
|
||||
});
|
||||
|
||||
// transactional with EntityManager instance
|
||||
// $em instanceof EntityManager
|
||||
$em->transactional(function($em) {
|
||||
$em->wrapInTransaction(function($em) {
|
||||
// ... do some work
|
||||
$user = new User;
|
||||
$user->setName('George');
|
||||
$em->persist($user);
|
||||
});
|
||||
|
||||
.. warning::
|
||||
|
||||
For historical reasons, ``EntityManager#transactional($func)`` will return
|
||||
``true`` whenever the return value of ``$func`` is loosely false.
|
||||
Some examples of this include ``array()``, ``"0"``, ``""``, ``0``, and
|
||||
``null``.
|
||||
|
||||
The difference between ``Connection#transactional($func)`` and
|
||||
``EntityManager#transactional($func)`` is that the latter
|
||||
abstraction flushes the ``EntityManager`` prior to transaction
|
||||
|
||||
@@ -102,7 +102,7 @@ How Doctrine Detects Changes
|
||||
----------------------------
|
||||
|
||||
Doctrine is a data-mapper that tries to achieve persistence-ignorance (PI).
|
||||
This means you map php objects into a relational database that don't
|
||||
This means you map PHP objects into a relational database that don't
|
||||
necessarily know about the database at all. A natural question would now be,
|
||||
"how does Doctrine even detect objects have changed?".
|
||||
|
||||
|
||||
@@ -338,10 +338,11 @@ Performance of different deletion strategies
|
||||
Deleting an object with all its associated objects can be achieved
|
||||
in multiple ways with very different performance impacts.
|
||||
|
||||
1. If an association is marked as ``CASCADE=REMOVE`` Doctrine ORM
|
||||
will fetch this association. If its a Single association it will
|
||||
pass this entity to
|
||||
``EntityManager#remove()``. If the association is a collection, Doctrine will loop over all its elements and pass them to``EntityManager#remove()``.
|
||||
1. If an association is marked as ``CASCADE=REMOVE`` Doctrine ORM will
|
||||
fetch this association. If it's a Single association it will pass
|
||||
this entity to ``EntityManager#remove()``. If the association is a
|
||||
collection, Doctrine will loop over all its elements and pass them to
|
||||
``EntityManager#remove()``.
|
||||
In both cases the cascade remove semantics are applied recursively.
|
||||
For large object graphs this removal strategy can be very costly.
|
||||
2. Using a DQL ``DELETE`` statement allows you to delete multiple
|
||||
|
||||
@@ -1,83 +1,77 @@
|
||||
.. toc::
|
||||
:orphan:
|
||||
|
||||
.. tocheader:: Tutorials
|
||||
.. toctree::
|
||||
:caption: Tutorials
|
||||
:depth: 3
|
||||
|
||||
.. toctree::
|
||||
:depth: 3
|
||||
tutorials/getting-started
|
||||
tutorials/getting-started-database
|
||||
tutorials/getting-started-models
|
||||
tutorials/working-with-indexed-associations
|
||||
tutorials/extra-lazy-associations
|
||||
tutorials/composite-primary-keys
|
||||
tutorials/ordered-associations
|
||||
tutorials/override-field-association-mappings-in-subclasses
|
||||
tutorials/pagination
|
||||
tutorials/embeddables
|
||||
|
||||
tutorials/getting-started
|
||||
tutorials/getting-started-database
|
||||
tutorials/getting-started-models
|
||||
tutorials/working-with-indexed-associations
|
||||
tutorials/extra-lazy-associations
|
||||
tutorials/composite-primary-keys
|
||||
tutorials/ordered-associations
|
||||
tutorials/override-field-association-mappings-in-subclasses
|
||||
tutorials/pagination
|
||||
tutorials/embeddables
|
||||
.. toctree::
|
||||
:caption: Reference
|
||||
:depth: 3
|
||||
|
||||
.. toc::
|
||||
reference/architecture
|
||||
reference/configuration
|
||||
reference/faq
|
||||
reference/basic-mapping
|
||||
reference/association-mapping
|
||||
reference/inheritance-mapping
|
||||
reference/working-with-objects
|
||||
reference/working-with-associations
|
||||
reference/typedfieldmapper
|
||||
reference/events
|
||||
reference/unitofwork
|
||||
reference/unitofwork-associations
|
||||
reference/transactions-and-concurrency
|
||||
reference/batch-processing
|
||||
reference/dql-doctrine-query-language
|
||||
reference/query-builder
|
||||
reference/native-sql
|
||||
reference/change-tracking-policies
|
||||
reference/partial-objects
|
||||
reference/annotations-reference
|
||||
reference/attributes-reference
|
||||
reference/xml-mapping
|
||||
reference/yaml-mapping
|
||||
reference/php-mapping
|
||||
reference/caching
|
||||
reference/improving-performance
|
||||
reference/tools
|
||||
reference/metadata-drivers
|
||||
reference/best-practices
|
||||
reference/limitations-and-known-issues
|
||||
tutorials/pagination
|
||||
reference/filters
|
||||
reference/namingstrategy
|
||||
reference/advanced-configuration
|
||||
reference/second-level-cache
|
||||
reference/security
|
||||
|
||||
.. tocheader:: Reference
|
||||
.. toctree::
|
||||
:caption: Cookbook
|
||||
:depth: 3
|
||||
|
||||
.. toctree::
|
||||
:depth: 3
|
||||
|
||||
reference/architecture
|
||||
reference/configuration
|
||||
reference/faq
|
||||
reference/basic-mapping
|
||||
reference/association-mapping
|
||||
reference/inheritance-mapping
|
||||
reference/working-with-objects
|
||||
reference/working-with-associations
|
||||
reference/events
|
||||
reference/unitofwork
|
||||
reference/unitofwork-associations
|
||||
reference/transactions-and-concurrency
|
||||
reference/batch-processing
|
||||
reference/dql-doctrine-query-language
|
||||
reference/query-builder
|
||||
reference/native-sql
|
||||
reference/change-tracking-policies
|
||||
reference/partial-objects
|
||||
reference/annotations-reference
|
||||
reference/attributes-reference
|
||||
reference/xml-mapping
|
||||
reference/yaml-mapping
|
||||
reference/php-mapping
|
||||
reference/caching
|
||||
reference/improving-performance
|
||||
reference/tools
|
||||
reference/metadata-drivers
|
||||
reference/best-practices
|
||||
reference/limitations-and-known-issues
|
||||
tutorials/pagination
|
||||
reference/filters
|
||||
reference/namingstrategy
|
||||
reference/advanced-configuration
|
||||
reference/second-level-cache
|
||||
reference/security
|
||||
|
||||
.. toc::
|
||||
|
||||
.. tocheader:: Cookbook
|
||||
|
||||
.. toctree::
|
||||
:depth: 3
|
||||
|
||||
cookbook/aggregate-fields
|
||||
cookbook/custom-mapping-types
|
||||
cookbook/decorator-pattern
|
||||
cookbook/dql-custom-walkers
|
||||
cookbook/dql-user-defined-functions
|
||||
cookbook/implementing-arrayaccess-for-domain-objects
|
||||
cookbook/implementing-the-notify-changetracking-policy
|
||||
cookbook/resolve-target-entity-listener
|
||||
cookbook/sql-table-prefixes
|
||||
cookbook/strategy-cookbook-introduction
|
||||
cookbook/validation-of-entities
|
||||
cookbook/working-with-datetime
|
||||
cookbook/mysql-enums
|
||||
cookbook/advanced-field-value-conversion-using-custom-mapping-types
|
||||
cookbook/entities-in-session
|
||||
cookbook/aggregate-fields
|
||||
cookbook/custom-mapping-types
|
||||
cookbook/decorator-pattern
|
||||
cookbook/dql-custom-walkers
|
||||
cookbook/dql-user-defined-functions
|
||||
cookbook/implementing-arrayaccess-for-domain-objects
|
||||
cookbook/implementing-the-notify-changetracking-policy
|
||||
cookbook/resolve-target-entity-listener
|
||||
cookbook/sql-table-prefixes
|
||||
cookbook/strategy-cookbook-introduction
|
||||
cookbook/validation-of-entities
|
||||
cookbook/working-with-datetime
|
||||
cookbook/mysql-enums
|
||||
cookbook/advanced-field-value-conversion-using-custom-mapping-types
|
||||
cookbook/entities-in-session
|
||||
|
||||
@@ -188,7 +188,7 @@ We keep up the example of an Article with arbitrary attributes, the mapping look
|
||||
#[OneToMany(targetEntity: ArticleAttribute::class, mappedBy: 'article', cascade: ['ALL'], indexBy: 'attribute')]
|
||||
private Collection $attributes;
|
||||
|
||||
public function addAttribute(string $name, ArticleAttribute $value): void
|
||||
public function addAttribute(string $name, string $value): void
|
||||
{
|
||||
$this->attributes[$name] = new ArticleAttribute($name, $value, $this);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ can be called without triggering a full load of the collection:
|
||||
- ``Collection#containsKey($key)``
|
||||
- ``Collection#count()``
|
||||
- ``Collection#get($key)``
|
||||
- ``Collection#isEmpty()``
|
||||
- ``Collection#slice($offset, $length = null)``
|
||||
|
||||
For each of the above methods the following semantics apply:
|
||||
|
||||
@@ -144,7 +144,7 @@ step:
|
||||
|
||||
// Create a simple "default" Doctrine ORM configuration for Attributes
|
||||
$config = ORMSetup::createAttributeMetadataConfiguration(
|
||||
paths: array(__DIR__."/src"),
|
||||
paths: [__DIR__ . '/src'],
|
||||
isDevMode: true,
|
||||
);
|
||||
// or if you prefer annotation, YAML or XML
|
||||
@@ -153,7 +153,7 @@ step:
|
||||
// isDevMode: true,
|
||||
// );
|
||||
// $config = ORMSetup::createXMLMetadataConfiguration(
|
||||
// paths: array(__DIR__."/config/xml"),
|
||||
// paths: [__DIR__ . '/config/xml'],
|
||||
// isDevMode: true,
|
||||
//);
|
||||
// $config = ORMSetup::createYAMLMetadataConfiguration(
|
||||
|
||||
@@ -9,7 +9,7 @@ i.e. attributes and associations metadata in particular. The example here shows
|
||||
the overriding of a class that uses a trait but is similar when extending a base
|
||||
class as shown at the end of this tutorial.
|
||||
|
||||
Suppose we have a class ExampleEntityWithOverride. This class uses trait ExampleTrait:
|
||||
Suppose we have a class ``ExampleEntityWithOverride``. This class uses trait ``ExampleTrait``:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
@@ -17,22 +17,20 @@ Suppose we have a class ExampleEntityWithOverride. This class uses trait Example
|
||||
|
||||
#[Entity]
|
||||
#[AttributeOverrides([
|
||||
new AttributeOverride('foo', [
|
||||
'column' => new Column([
|
||||
'name' => 'foo_overridden',
|
||||
'type' => 'integer',
|
||||
'length' => 140,
|
||||
'nullable' => false,
|
||||
'unique' => false,
|
||||
]),
|
||||
]),
|
||||
new AttributeOverride('foo', new Column(
|
||||
name: 'foo_overridden',
|
||||
type: 'integer',
|
||||
length: 140,
|
||||
nullable: false,
|
||||
unique: false,
|
||||
)),
|
||||
])]
|
||||
#[AssociationOverrides([
|
||||
new AssociationOverride('bar', [
|
||||
'joinColumns' => new JoinColumn([
|
||||
'name' => 'example_entity_overridden_bar_id',
|
||||
'referencedColumnName' => 'id',
|
||||
]),
|
||||
new JoinColumn(
|
||||
name: 'example_entity_overridden_bar_id',
|
||||
referencedColumnName: 'id',
|
||||
),
|
||||
]),
|
||||
])]
|
||||
class ExampleEntityWithOverride
|
||||
@@ -47,7 +45,7 @@ Suppose we have a class ExampleEntityWithOverride. This class uses trait Example
|
||||
private $id;
|
||||
}
|
||||
|
||||
The docblock is showing metadata override of the attribute and association type. It
|
||||
``#[AttributeOverrides]`` contains metadata override of the attribute and association type. It
|
||||
basically changes the names of the columns mapped for a property ``foo`` and for
|
||||
the association ``bar`` which relates to Bar class shown above. Here is the trait
|
||||
which has mapping metadata that is overridden by the attribute above:
|
||||
|
||||
@@ -31,169 +31,18 @@ You can map indexed associations by adding:
|
||||
The code and mappings for the Market entity looks like this:
|
||||
|
||||
.. configuration-block::
|
||||
.. code-block:: attribute
|
||||
.. literalinclude:: working-with-indexed-associations/Market.php
|
||||
:language: attribute
|
||||
|
||||
<?php
|
||||
namespace Doctrine\Tests\Models\StockExchange;
|
||||
.. literalinclude:: working-with-indexed-associations/Market-annotations.php
|
||||
:language: annotation
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
.. literalinclude:: working-with-indexed-associations/market.xml
|
||||
:language: xml
|
||||
|
||||
#[Entity]
|
||||
#[Table(name: 'exchange_markets')]
|
||||
class Market
|
||||
{
|
||||
#[Id, Column(type: 'integer'), GeneratedValue]
|
||||
private int|null $id = null;
|
||||
.. literalinclude:: working-with-indexed-associations/market.yaml
|
||||
:language: yaml
|
||||
|
||||
#[Column(type: 'string')]
|
||||
private string $name;
|
||||
|
||||
/** @var Collection<string, Stock> */
|
||||
#[OneToMany(targetEntity: Stock::class, mappedBy: 'market', indexBy: 'symbol')]
|
||||
private Collection $stocks;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->stocks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): int|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function addStock(Stock $stock): void
|
||||
{
|
||||
$this->stocks[$stock->getSymbol()] = $stock;
|
||||
}
|
||||
|
||||
public function getStock(string $symbol): Stock
|
||||
{
|
||||
if (!isset($this->stocks[$symbol])) {
|
||||
throw new \InvalidArgumentException("Symbol is not traded on this market.");
|
||||
}
|
||||
|
||||
return $this->stocks[$symbol];
|
||||
}
|
||||
|
||||
/** @return array<string, Stock> */
|
||||
public function getStocks(): array
|
||||
{
|
||||
return $this->stocks->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
.. code-block:: annotation
|
||||
|
||||
<?php
|
||||
namespace Doctrine\Tests\Models\StockExchange;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="exchange_markets")
|
||||
*/
|
||||
class Market
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer") @GeneratedValue
|
||||
* @var int
|
||||
*/
|
||||
private int|null $id = null;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private string $name;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Stock", mappedBy="market", indexBy="symbol")
|
||||
* @var Collection<int, Stock>
|
||||
*/
|
||||
private Collection $stocks;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->stocks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): int|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function addStock(Stock $stock): void
|
||||
{
|
||||
$this->stocks[$stock->getSymbol()] = $stock;
|
||||
}
|
||||
|
||||
public function getStock($symbol): Stock
|
||||
{
|
||||
if (!isset($this->stocks[$symbol])) {
|
||||
throw new \InvalidArgumentException("Symbol is not traded on this market.");
|
||||
}
|
||||
|
||||
return $this->stocks[$symbol];
|
||||
}
|
||||
|
||||
/** @return array<string, Stock> */
|
||||
public function getStocks(): array
|
||||
{
|
||||
return $this->stocks->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\StockExchange\Market">
|
||||
<id name="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<field name="name" type="string"/>
|
||||
|
||||
<one-to-many target-entity="Stock" mapped-by="market" field="stocks" index-by="symbol" />
|
||||
</entity>
|
||||
</doctrine-mapping>
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
Doctrine\Tests\Models\StockExchange\Market:
|
||||
type: entity
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
name:
|
||||
type:string
|
||||
oneToMany:
|
||||
stocks:
|
||||
targetEntity: Stock
|
||||
mappedBy: market
|
||||
indexBy: symbol
|
||||
|
||||
Inside the ``addStock()`` method you can see how we directly set the key of the association to the symbol,
|
||||
so that we can work with the indexed association directly after invoking ``addStock()``. Inside ``getStock($symbol)``
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\StockExchange;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Entity;
|
||||
use Doctrine\ORM\Mapping\GeneratedValue;
|
||||
use Doctrine\ORM\Mapping\Id;
|
||||
use Doctrine\ORM\Mapping\OneToMany;
|
||||
use Doctrine\ORM\Mapping\Table;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="exchange_markets")
|
||||
*/
|
||||
class Market
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer") @GeneratedValue
|
||||
* @var int
|
||||
*/
|
||||
private int|null $id = null;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private string $name;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Stock", mappedBy="market", indexBy="symbol")
|
||||
* @var Collection<int, Stock>
|
||||
*/
|
||||
private Collection $stocks;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->stocks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): int|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function addStock(Stock $stock): void
|
||||
{
|
||||
$this->stocks[$stock->getSymbol()] = $stock;
|
||||
}
|
||||
|
||||
public function getStock($symbol): Stock
|
||||
{
|
||||
if (!isset($this->stocks[$symbol])) {
|
||||
throw new InvalidArgumentException("Symbol is not traded on this market.");
|
||||
}
|
||||
|
||||
return $this->stocks[$symbol];
|
||||
}
|
||||
|
||||
/** @return array<string, Stock> */
|
||||
public function getStocks(): array
|
||||
{
|
||||
return $this->stocks->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\Models\StockExchange;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Entity;
|
||||
use Doctrine\ORM\Mapping\GeneratedValue;
|
||||
use Doctrine\ORM\Mapping\Id;
|
||||
use Doctrine\ORM\Mapping\OneToMany;
|
||||
use Doctrine\ORM\Mapping\Table;
|
||||
use InvalidArgumentException;
|
||||
|
||||
#[Entity]
|
||||
#[Table(name: 'exchange_markets')]
|
||||
class Market
|
||||
{
|
||||
#[Id]
|
||||
#[Column(type: 'integer')]
|
||||
#[GeneratedValue]
|
||||
private int|null $id = null;
|
||||
|
||||
#[Column(type: 'string')]
|
||||
private string $name;
|
||||
|
||||
/** @var Collection<string, Stock> */
|
||||
#[OneToMany(targetEntity: Stock::class, mappedBy: 'market', indexBy: 'symbol')]
|
||||
private Collection $stocks;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->stocks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): int|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function addStock(Stock $stock): void
|
||||
{
|
||||
$this->stocks[$stock->getSymbol()] = $stock;
|
||||
}
|
||||
|
||||
public function getStock(string $symbol): Stock
|
||||
{
|
||||
if (! isset($this->stocks[$symbol])) {
|
||||
throw new InvalidArgumentException('Symbol is not traded on this market.');
|
||||
}
|
||||
|
||||
return $this->stocks[$symbol];
|
||||
}
|
||||
|
||||
/** @return array<string, Stock> */
|
||||
public function getStocks(): array
|
||||
{
|
||||
return $this->stocks->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\StockExchange\Market">
|
||||
<id name="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<field name="name" type="string"/>
|
||||
|
||||
<one-to-many target-entity="Stock" mapped-by="market" field="stocks" index-by="symbol" />
|
||||
</entity>
|
||||
</doctrine-mapping>
|
||||
@@ -0,0 +1,15 @@
|
||||
Doctrine\Tests\Models\StockExchange\Market:
|
||||
type: entity
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
name:
|
||||
type:string
|
||||
oneToMany:
|
||||
stocks:
|
||||
targetEntity: Stock
|
||||
mappedBy: market
|
||||
indexBy: symbol
|
||||
@@ -375,7 +375,7 @@
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
|
||||
</xs:choice>
|
||||
<xs:attribute name="value" type="xs:NMTOKEN" use="required"/>
|
||||
<xs:attribute name="value" type="orm:type" use="required"/>
|
||||
<xs:attribute name="class" type="orm:fqcn" use="required"/>
|
||||
<xs:anyAttribute namespace="##other"/>
|
||||
</xs:complexType>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset>
|
||||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
name="PHP_CodeSniffer"
|
||||
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
|
||||
<arg name="basepath" value="."/>
|
||||
<arg name="extensions" value="php"/>
|
||||
<arg name="parallel" value="80"/>
|
||||
@@ -14,7 +16,6 @@
|
||||
<file>src</file>
|
||||
<file>tests</file>
|
||||
|
||||
<exclude-pattern>*/src/Mapping/InverseJoinColumn.php</exclude-pattern>
|
||||
<exclude-pattern>*/tests/Tests/Proxies/__CG__*</exclude-pattern>
|
||||
<exclude-pattern>*/tests/Tests/ORM/Tools/Export/export/*</exclude-pattern>
|
||||
|
||||
@@ -279,4 +280,9 @@
|
||||
<!-- https://github.com/doctrine/orm/issues/8537 -->
|
||||
<exclude-pattern>src/QueryBuilder.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses">
|
||||
<!-- We need those parentheses to make enum access seem like valid syntax on PHP 7 -->
|
||||
<exclude-pattern>src/Mapping/Driver/XmlDriver.php</exclude-pattern>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@ parameters:
|
||||
|
||||
ignoreErrors:
|
||||
# PHPStan doesn't understand our method_exists() safeguards.
|
||||
- '/Call to function method_exists.*/'
|
||||
- '/Call to an undefined method Doctrine\\DBAL\\Connection::createSchemaManager\(\)\./'
|
||||
# Class name will change in DBAL 3.
|
||||
- '/^Class Doctrine\\DBAL\\Platforms\\PostgreSQLPlatform not found\.$/'
|
||||
@@ -46,6 +47,16 @@ parameters:
|
||||
path: src/Query/AST/Functions/LocateFunction.php
|
||||
|
||||
# Won't get fixed in DBAL 2
|
||||
-
|
||||
message: '#.*deleteItem.*expects string.*#'
|
||||
count: 1
|
||||
path: src/Query.php
|
||||
|
||||
-
|
||||
message: '#.*get(Drop|Create)SchemaS(ql|QL).*should return list.*but returns array.*#'
|
||||
count: 2
|
||||
path: src/Tools/SchemaTool.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$start of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getSubstringExpression\\(\\) expects int, string given\\.$#"
|
||||
count: 1
|
||||
@@ -61,6 +72,24 @@ parameters:
|
||||
count: 2
|
||||
path: src/Mapping/ClassMetadataFactory.php
|
||||
|
||||
- '~^Call to deprecated method getSQLResultCasing\(\) of class Doctrine\\DBAL\\Platforms\\AbstractPlatform\.$~'
|
||||
-
|
||||
message: '~deprecated class Doctrine\\DBAL\\Tools\\Console\\Command\\ImportCommand\:~'
|
||||
path: src/Tools/Console/ConsoleRunner.php
|
||||
|
||||
-
|
||||
message: '#^Method Doctrine\\ORM\\AbstractQuery\:\:getHydrationCacheId\(\) should return array\{string, string\} but returns array\<string\>\.$#'
|
||||
path: src/AbstractQuery.php
|
||||
|
||||
-
|
||||
message: '#^Method Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator\:\:\w+\(\) has parameter \$stmt with no value type specified in iterable type Doctrine\\DBAL\\Driver\\ResultStatement\.$#'
|
||||
path: src/Internal/Hydration/AbstractHydrator.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$key of method Psr\\Cache\\CacheItemPoolInterface\:\:deleteItem\(\) expects string, string\|false given\.$#'
|
||||
path: src/Query
|
||||
|
||||
|
||||
# Symfony cache supports passing a key prefix to the clear method.
|
||||
- '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/'
|
||||
|
||||
@@ -74,3 +103,9 @@ parameters:
|
||||
-
|
||||
message: '#^Call to method injectObjectManager\(\) on an unknown class Doctrine\\Persistence\\ObjectManagerAware\.$#'
|
||||
path: src/UnitOfWork.php
|
||||
|
||||
-
|
||||
message: '#contains generic type.*but class.*is not generic#'
|
||||
paths:
|
||||
- src/Mapping/Driver/XmlDriver.php
|
||||
- src/Mapping/Driver/YamlDriver.php
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
parameters:
|
||||
level: 5
|
||||
level: 7
|
||||
paths:
|
||||
- src
|
||||
- tests/StaticAnalysis
|
||||
@@ -8,8 +8,4 @@ parameters:
|
||||
earlyTerminatingMethodCalls:
|
||||
Doctrine\ORM\Query\Parser:
|
||||
- syntaxError
|
||||
phpVersion: 80200
|
||||
|
||||
ignoreErrors:
|
||||
# Remove on 3.0.x
|
||||
- '~^Default value of the parameter #2 \$value \(array\{\}\) of method Doctrine\\ORM\\Query\\AST\\InstanceOfExpression\:\:__construct\(\) is incompatible with type non\-empty\-array<int, Doctrine\\ORM\\Query\\AST\\InputParameter\|string>\.$~'
|
||||
phpVersion: 80400
|
||||
|
||||
@@ -3,6 +3,8 @@ includes:
|
||||
- phpstan-params.neon
|
||||
|
||||
parameters:
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
|
||||
ignoreErrors:
|
||||
# deprecations from doctrine/dbal:3.x
|
||||
- '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getGuidExpression\(\).$/'
|
||||
@@ -31,6 +33,31 @@ parameters:
|
||||
message: '/^Instanceof between Doctrine\\DBAL\\Platforms\\AbstractPlatform and Doctrine\\DBAL\\Platforms\\MySQLPlatform will always evaluate to false\.$/'
|
||||
path: src/Utility/LockSqlHelper.php
|
||||
|
||||
# Forward compatibility with Collections 3
|
||||
-
|
||||
message: '#^Parameter \$order of anonymous function has invalid type Doctrine\\Common\\Collections\\Order\.$#'
|
||||
path: src/Internal/CriteriaOrderings.php
|
||||
|
||||
-
|
||||
message: '#^Anonymous function has invalid return type Doctrine\\Common\\Collections\\Order\.$#'
|
||||
path: src/Internal/CriteriaOrderings.php
|
||||
|
||||
-
|
||||
message: '#^Access to property \$value on an unknown class Doctrine\\Common\\Collections\\Order\.$#'
|
||||
path: src/Internal/CriteriaOrderings.php
|
||||
|
||||
-
|
||||
message: '#^Call to static method from\(\) on an unknown class Doctrine\\Common\\Collections\\Order\.$#'
|
||||
path: src/Internal/CriteriaOrderings.php
|
||||
|
||||
-
|
||||
message: '#^Call to an undefined method Doctrine\\Common\\Collections\\Criteria\:\:orderings\(\)\.$#'
|
||||
path: src/Internal/CriteriaOrderings.php
|
||||
|
||||
-
|
||||
message: '#^Method .+\:\:mapToOrderEnumIfAvailable\(\) has invalid return type Doctrine\\Common\\Collections\\Order\.$#'
|
||||
path: src/Internal/CriteriaOrderings.php
|
||||
|
||||
# False positive
|
||||
-
|
||||
message: '/^Call to an undefined method Doctrine\\Common\\Cache\\Cache::deleteAll\(\)\.$/'
|
||||
@@ -39,3 +66,37 @@ parameters:
|
||||
|
||||
# Symfony cache supports passing a key prefix to the clear method.
|
||||
- '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/'
|
||||
|
||||
-
|
||||
message: '#contains generic type.*but class.*is not generic#'
|
||||
paths:
|
||||
- src/Mapping/Driver/XmlDriver.php
|
||||
- src/Mapping/Driver/YamlDriver.php
|
||||
|
||||
# Extending a deprecated class conditionally to maintain BC
|
||||
-
|
||||
message: '~deprecated class Doctrine\\Persistence\\Mapping\\Driver\\AnnotationDriver\:~'
|
||||
path: src/Mapping/Driver/CompatibilityAnnotationDriver.php
|
||||
|
||||
# We're sniffing for this deprecated class in order to detect Persistence 2
|
||||
-
|
||||
message: '~deprecated class Doctrine\\Common\\Persistence\\PersistentObject\:~'
|
||||
path: src/EntityManager.php
|
||||
|
||||
-
|
||||
message: '#Cannot access offset \S+ on .*ClassMetadata.*#'
|
||||
paths:
|
||||
- src/Mapping/Driver/XmlDriver.php
|
||||
- src/Mapping/Driver/YamlDriver.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$orderings of method Doctrine\\Common\\Collections\\Criteria\:\:orderBy\(\) expects array\<string\>, array\<string, Doctrine\\Common\\Collections\\Order\|string\> given\.$#'
|
||||
path: src/PersistentCollection.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#5 \.\.\.\$args of static method Doctrine\\Deprecations\\Deprecation\:\:trigger\(\) expects float\|int\|string, string\|false given\.$#'
|
||||
path: src/Mapping/ClassMetadataFactory.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$classNames of method Doctrine\\ORM\\Mapping\\ClassMetadataInfo\<object\>\:\:setParentClasses\(\) expects list\<class\-string\>, array\<string\> given\.$#'
|
||||
path: src/Mapping/ClassMetadataFactory.php
|
||||
|
||||
2787
psalm-baseline.xml
2787
psalm-baseline.xml
File diff suppressed because it is too large
Load Diff
305
psalm.xml
305
psalm.xml
@@ -1,305 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="2"
|
||||
phpVersion="8.2"
|
||||
resolveFromConfigFile="true"
|
||||
findUnusedBaselineEntry="true"
|
||||
findUnusedCode="false"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
errorBaseline="psalm-baseline.xml"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
<directory name="tests/StaticAnalysis" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
<file name="src/Mapping/Driver/AttributeReader.php" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
<enableExtensions>
|
||||
<extension name="simplexml" />
|
||||
</enableExtensions>
|
||||
<issueHandlers>
|
||||
<DeprecatedClass>
|
||||
<errorLevel type="suppress">
|
||||
<!-- DBAL 2 compatibility -->
|
||||
<referencedClass name="Doctrine\DBAL\Tools\Console\Command\ImportCommand"/>
|
||||
<referencedClass name="Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper"/>
|
||||
<!-- The exception is thrown by a deprecated method. -->
|
||||
<referencedClass name="Doctrine\ORM\Cache\Exception\InvalidResultCacheDriver"/>
|
||||
<!-- We wire the command as long as DBAL ships it -->
|
||||
<referencedClass name="Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand" />
|
||||
<!-- Remove on 3.0.x -->
|
||||
<referencedClass name="Doctrine\Common\Persistence\PersistentObject"/>
|
||||
<referencedClass name="Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets"/>
|
||||
<referencedClass name="Doctrine\ORM\Event\LifecycleEventArgs"/>
|
||||
<referencedClass name="Doctrine\ORM\Exception\UnknownEntityNamespace"/>
|
||||
<referencedClass name="Doctrine\ORM\Mapping\Driver\AnnotationDriver"/>
|
||||
<referencedClass name="Doctrine\ORM\Mapping\Driver\YamlDriver"/>
|
||||
<referencedClass name="Doctrine\ORM\Mapping\NamedNativeQueries"/>
|
||||
<referencedClass name="Doctrine\ORM\Mapping\NamedNativeQuery"/>
|
||||
<referencedClass name="Doctrine\ORM\Mapping\NamedQueries"/>
|
||||
<referencedClass name="Doctrine\ORM\Mapping\NamedQuery"/>
|
||||
<referencedClass name="Doctrine\ORM\Query\AST\InExpression"/>
|
||||
<referencedClass name="Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand"/>
|
||||
<referencedClass name="Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand"/>
|
||||
<referencedClass name="Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand"/>
|
||||
<referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand"/>
|
||||
<referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand"/>
|
||||
<referencedClass name="Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper"/>
|
||||
<referencedClass name="Doctrine\ORM\Tools\Console\EntityManagerProvider\HelperSetManagerProvider"/>
|
||||
</errorLevel>
|
||||
</DeprecatedClass>
|
||||
<DeprecatedConstant>
|
||||
<errorLevel type="suppress">
|
||||
<file name="src/Configuration.php"/>
|
||||
<file name="src/Query/Lexer.php"/>
|
||||
<file name="src/Query/Parser.php"/>
|
||||
<file name="src/QueryBuilder.php"/>
|
||||
<file name="src/Tools/EntityGenerator.php"/>
|
||||
<file name="src/Mapping/ClassMetadataInfo.php" />
|
||||
<file name="src/Tools/EntityGenerator.php" />
|
||||
<file name="src/Tools/Export/Driver/AbstractExporter.php" />
|
||||
<file name="src/Tools/SchemaTool.php" />
|
||||
</errorLevel>
|
||||
</DeprecatedConstant>
|
||||
<DeprecatedInterface>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Remove on 3.0.x -->
|
||||
<referencedClass name="Doctrine\ORM\Cache\MultiGetRegion"/>
|
||||
<referencedClass name="Doctrine\ORM\Mapping\Annotation"/>
|
||||
</errorLevel>
|
||||
</DeprecatedInterface>
|
||||
<DeprecatedMethod>
|
||||
<errorLevel type="suppress">
|
||||
<!-- We're calling the deprecated method for BC here. -->
|
||||
<file name="src/Internal/SQLResultCasing.php"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getIdentitySequenceName"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::usesSequenceEmulatedIdentityColumns"/>
|
||||
<!-- We need to keep the calls for DBAL 2.13 compatibility. -->
|
||||
<referencedMethod name="Doctrine\DBAL\Cache\QueryCacheProfile::getResultCacheDriver"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Cache\QueryCacheProfile::setResultCacheDriver"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Configuration::getResultCacheImpl"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Configuration::setResultCacheImpl"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Connection::getSchemaManager"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getGuidExpression"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::supportsForeignKeyConstraints"/>
|
||||
<!-- Remove on 3.0.x -->
|
||||
<referencedMethod name="Doctrine\DBAL\Connection::getEventManager"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getReadLockSQL"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getWriteLockSQL"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Schema\Schema::visit"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Schema\SchemaDiff::toSaveSql"/>
|
||||
<referencedMethod name="Doctrine\DBAL\Schema\SchemaDiff::toSql"/>
|
||||
<referencedMethod name="Doctrine\ORM\Internal\Hydration\AbstractHydrator::hydrateRow"/>
|
||||
<referencedMethod name="Doctrine\ORM\Configuration::ensureProductionSettings"/>
|
||||
<referencedMethod name="Doctrine\ORM\Configuration::newDefaultAnnotationDriver"/>
|
||||
<referencedMethod name="Doctrine\ORM\EntityManager::createConnection"/>
|
||||
<referencedMethod name="Doctrine\ORM\EntityManagerInterface::getPartialReference"/>
|
||||
<referencedMethod name="Doctrine\ORM\Id\AbstractIdGenerator::generate"/>
|
||||
<referencedMethod name="Doctrine\ORM\ORMInvalidArgumentException::invalidEntityName"/>
|
||||
<referencedMethod name="Doctrine\ORM\ORMSetup::createDefaultAnnotationDriver"/>
|
||||
<referencedMethod name="Doctrine\ORM\Query\SqlWalker::walkInExpression"/>
|
||||
<referencedMethod name="Doctrine\ORM\Query\TreeWalkerAdapter::_getQueryComponents"/>
|
||||
<referencedMethod name="Doctrine\ORM\Mapping\ClassMetadataInfo::isInheritanceTypeTablePerClass"/>
|
||||
<file name="src/Query/TreeWalkerChain.php"/>
|
||||
</errorLevel>
|
||||
</DeprecatedMethod>
|
||||
<DeprecatedProperty>
|
||||
<errorLevel type="suppress">
|
||||
<referencedProperty name="Doctrine\ORM\Cache\Region\DefaultRegion::$cache"/>
|
||||
<referencedProperty name="Doctrine\ORM\Mapping\Driver\AttributeDriver::$entityAnnotationClasses"/>
|
||||
</errorLevel>
|
||||
</DeprecatedProperty>
|
||||
<DocblockTypeContradiction>
|
||||
<errorLevel type="suppress">
|
||||
<!-- We're catching invalid input here. -->
|
||||
<file name="src/Internal/Hydration/AbstractHydrator.php"/>
|
||||
|
||||
<!-- DBAL 3.2 forward compatibility -->
|
||||
<file name="src/Tools/Pagination/CountOutputWalker.php"/>
|
||||
<file name="src/Tools/Pagination/LimitSubqueryOutputWalker.php"/>
|
||||
<!-- https://github.com/vimeo/psalm/issues/8520 -->
|
||||
<file name="src/PersistentCollection.php"/>
|
||||
</errorLevel>
|
||||
</DocblockTypeContradiction>
|
||||
<DuplicateClass>
|
||||
<errorLevel type="suppress">
|
||||
<file name="src/Tools/Console/CommandCompatibility.php"/>
|
||||
<file name="src/Tools/Console/Helper/EntityManagerHelper.php"/>
|
||||
</errorLevel>
|
||||
</DuplicateClass>
|
||||
<ForbiddenCode>
|
||||
<errorLevel type="suppress">
|
||||
<file name="src/Tools/Debug.php"/>
|
||||
</errorLevel>
|
||||
</ForbiddenCode>
|
||||
<InvalidArgument>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Argument type changes in DBAL 3.2 -->
|
||||
<referencedFunction name="Doctrine\DBAL\Cache\QueryCacheProfile::__construct"/>
|
||||
<!-- https://github.com/vimeo/psalm/issues/9155 -->
|
||||
<referencedFunction name="Doctrine\ORM\Mapping\ClassMetadata::addInheritedAssociationMapping"/>
|
||||
</errorLevel>
|
||||
</InvalidArgument>
|
||||
<InvalidArrayAccess>
|
||||
<errorLevel type="suppress">
|
||||
<!-- https://github.com/vimeo/psalm/issues/9160 -->
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
</errorLevel>
|
||||
</InvalidArrayAccess>
|
||||
<InvalidArrayAssignment>
|
||||
<errorLevel type="suppress">
|
||||
<!-- https://github.com/vimeo/psalm/issues/9160 -->
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
</errorLevel>
|
||||
</InvalidArrayAssignment>
|
||||
<InvalidClass>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Class name changes in DBAL 3. -->
|
||||
<referencedClass name="Doctrine\DBAL\Platforms\PostgreSQLPlatform" />
|
||||
<referencedClass name="Doctrine\DBAL\Platforms\MySQLPlatform" />
|
||||
</errorLevel>
|
||||
</InvalidClass>
|
||||
<InvalidParamDefault>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Remove on 3.0.x -->
|
||||
<file name="src/Query/AST/InstanceOfExpression.php"/>
|
||||
</errorLevel>
|
||||
</InvalidParamDefault>
|
||||
<InvalidPropertyAssignmentValue>
|
||||
<errorLevel type="suppress">
|
||||
<!-- https://github.com/vimeo/psalm/issues/9155 -->
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
</errorLevel>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<MethodSignatureMismatch>
|
||||
<errorLevel type="suppress">
|
||||
<!-- See https://github.com/vimeo/psalm/issues/7357 -->
|
||||
<file name="src/Mapping/ReflectionReadonlyProperty.php"/>
|
||||
</errorLevel>
|
||||
</MethodSignatureMismatch>
|
||||
<MissingDependency>
|
||||
<errorLevel type="suppress">
|
||||
<!-- DBAL 3.2 forward compatibility -->
|
||||
<file name="src/Internal/SQLResultCasing.php"/>
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
<file name="src/Tools/Pagination/LimitSubqueryOutputWalker.php"/>
|
||||
</errorLevel>
|
||||
</MissingDependency>
|
||||
<MissingParamType>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Persistence 2 compatibility -->
|
||||
<file name="src/EntityManager.php"/>
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
<file name="src/Mapping/ClassMetadataInfo.php"/>
|
||||
</errorLevel>
|
||||
</MissingParamType>
|
||||
<NonInvariantDocblockPropertyType>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Remove on 3.0.x -->
|
||||
<file name="src/Query/AST/InListExpression.php"/>
|
||||
<file name="src/Query/AST/InSubselectExpression.php"/>
|
||||
</errorLevel>
|
||||
</NonInvariantDocblockPropertyType>
|
||||
<PossiblyInvalidArgument>
|
||||
<errorLevel type="suppress">
|
||||
<!-- https://github.com/vimeo/psalm/issues/9155 -->
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
</errorLevel>
|
||||
</PossiblyInvalidArgument>
|
||||
<PropertyNotSetInConstructor>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Remove on 3.0.x -->
|
||||
<referencedProperty name="Doctrine\ORM\Cache\CacheKey::$hash"/>
|
||||
</errorLevel>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="src/Query/AST" />
|
||||
</errorLevel>
|
||||
</PropertyNotSetInConstructor>
|
||||
<PropertyTypeCoercion>
|
||||
<errorLevel type="suppress">
|
||||
<file name="src/Mapping/ClassMetadataInfo.php"/>
|
||||
</errorLevel>
|
||||
</PropertyTypeCoercion>
|
||||
<RedundantCastGivenDocblockType>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Can be removed once the "getMaxResults" methods of those classes have native parameter types -->
|
||||
<file name="src/Query.php"/>
|
||||
<file name="src/QueryBuilder.php"/>
|
||||
</errorLevel>
|
||||
</RedundantCastGivenDocblockType>
|
||||
<RedundantCondition>
|
||||
<errorLevel type="suppress">
|
||||
<!-- The SQLAnywherePlatform class may or may not exist depending on the DBAL version -->
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
</errorLevel>
|
||||
</RedundantCondition>
|
||||
<ReferenceConstraintViolation>
|
||||
<errorLevel type="suppress">
|
||||
<!-- https://github.com/vimeo/psalm/issues/9155 -->
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
</errorLevel>
|
||||
</ReferenceConstraintViolation>
|
||||
<TooManyArguments>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Symfony cache supports passing a key prefix to the clear method. -->
|
||||
<referencedFunction name="Psr\Cache\CacheItemPoolInterface::clear"/>
|
||||
|
||||
<!-- Persistence 2 compatibility -->
|
||||
<referencedFunction name="Doctrine\Persistence\ObjectManager::clear"/>
|
||||
|
||||
<!-- Remove on 3.0.x -->
|
||||
<referencedFunction name="Doctrine\Persistence\ObjectManager::refresh"/>
|
||||
</errorLevel>
|
||||
</TooManyArguments>
|
||||
<TypeDoesNotContainType>
|
||||
<errorLevel type="suppress">
|
||||
<file name="src/Internal/SQLResultCasing.php"/>
|
||||
<file name="src/Mapping/ClassMetadataFactory.php"/>
|
||||
<file name="src/Utility/LockSqlHelper.php"/>
|
||||
</errorLevel>
|
||||
</TypeDoesNotContainType>
|
||||
<UndefinedClass>
|
||||
<errorLevel type="suppress">
|
||||
<referencedClass name="Doctrine\Common\Cache\ApcCache"/>
|
||||
<referencedClass name="Doctrine\Common\Cache\ArrayCache"/>
|
||||
<referencedClass name="Doctrine\Common\Cache\XcacheCache"/>
|
||||
|
||||
<!-- DBAL 2 compatibility -->
|
||||
<referencedClass name="Doctrine\DBAL\Driver\ResultStatement"/>
|
||||
<referencedClass name="Doctrine\DBAL\ForwardCompatibility\Result"/>
|
||||
<referencedClass name="Doctrine\DBAL\Platforms\SQLAnywherePlatform"/>
|
||||
|
||||
<!-- DBAL 3.2 forward compatibility -->
|
||||
<referencedClass name="Doctrine\DBAL\Platforms\PostgreSQLPlatform"/>
|
||||
<referencedClass name="Doctrine\DBAL\Platforms\SQLServerPlatform"/>
|
||||
|
||||
<!-- Persistence 2 compatibility -->
|
||||
<referencedClass name="Doctrine\Persistence\ObjectManagerAware"/>
|
||||
|
||||
<!-- Annotations 1 compatibility -->
|
||||
<referencedClass name="Doctrine\Common\Annotations\CachedReader"/>
|
||||
</errorLevel>
|
||||
</UndefinedClass>
|
||||
<UndefinedDocblockClass>
|
||||
<errorLevel type="suppress">
|
||||
<!-- DBAL 2 compatibility -->
|
||||
<referencedClass name="Doctrine\DBAL\Driver\ResultStatement"/>
|
||||
</errorLevel>
|
||||
</UndefinedDocblockClass>
|
||||
<UndefinedMethod>
|
||||
<errorLevel type="suppress">
|
||||
<!-- See https://github.com/doctrine/orm/issues/8884 -->
|
||||
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getGuidExpression"/>
|
||||
</errorLevel>
|
||||
</UndefinedMethod>
|
||||
<MissingClosureReturnType>
|
||||
<errorLevel type="suppress">
|
||||
<file name="src/Tools/Pagination/Paginator.php"/>
|
||||
</errorLevel>
|
||||
</MissingClosureReturnType>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
@@ -90,7 +90,7 @@ abstract class AbstractQuery
|
||||
* The parameter map of this query.
|
||||
*
|
||||
* @var ArrayCollection|Parameter[]
|
||||
* @psalm-var ArrayCollection<int, Parameter>
|
||||
* @phpstan-var ArrayCollection<int, Parameter>
|
||||
*/
|
||||
protected $parameters;
|
||||
|
||||
@@ -111,7 +111,7 @@ abstract class AbstractQuery
|
||||
/**
|
||||
* The map of query hints.
|
||||
*
|
||||
* @psalm-var array<string, mixed>
|
||||
* @phpstan-var array<string, mixed>
|
||||
*/
|
||||
protected $_hints = [];
|
||||
|
||||
@@ -119,7 +119,7 @@ abstract class AbstractQuery
|
||||
* The hydration mode.
|
||||
*
|
||||
* @var string|int
|
||||
* @psalm-var string|AbstractQuery::HYDRATE_*
|
||||
* @phpstan-var string|AbstractQuery::HYDRATE_*
|
||||
*/
|
||||
protected $_hydrationMode = self::HYDRATE_OBJECT;
|
||||
|
||||
@@ -157,7 +157,7 @@ abstract class AbstractQuery
|
||||
* Second level query cache mode.
|
||||
*
|
||||
* @var int|null
|
||||
* @psalm-var Cache::MODE_*|null
|
||||
* @phpstan-var Cache::MODE_*|null
|
||||
*/
|
||||
protected $cacheMode;
|
||||
|
||||
@@ -254,7 +254,7 @@ abstract class AbstractQuery
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
* @psalm-return Cache::MODE_*|null
|
||||
* @phpstan-return Cache::MODE_*|null
|
||||
*/
|
||||
public function getCacheMode()
|
||||
{
|
||||
@@ -263,7 +263,7 @@ abstract class AbstractQuery
|
||||
|
||||
/**
|
||||
* @param int $cacheMode
|
||||
* @psalm-param Cache::MODE_* $cacheMode
|
||||
* @phpstan-param Cache::MODE_* $cacheMode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -311,7 +311,7 @@ abstract class AbstractQuery
|
||||
* Get all defined parameters.
|
||||
*
|
||||
* @return ArrayCollection The defined query parameters.
|
||||
* @psalm-return ArrayCollection<int, Parameter>
|
||||
* @phpstan-return ArrayCollection<int, Parameter>
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
@@ -344,14 +344,14 @@ abstract class AbstractQuery
|
||||
* Sets a collection of query parameters.
|
||||
*
|
||||
* @param ArrayCollection|mixed[] $parameters
|
||||
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
|
||||
* @phpstan-param ArrayCollection<int, Parameter>|mixed[] $parameters
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParameters($parameters)
|
||||
{
|
||||
if (is_array($parameters)) {
|
||||
/** @psalm-var ArrayCollection<int, Parameter> $parameterCollection */
|
||||
/** @phpstan-var ArrayCollection<int, Parameter> $parameterCollection */
|
||||
$parameterCollection = new ArrayCollection();
|
||||
|
||||
foreach ($parameters as $key => $value) {
|
||||
@@ -558,9 +558,11 @@ abstract class AbstractQuery
|
||||
|
||||
// DBAL 2
|
||||
if (! method_exists(QueryCacheProfile::class, 'setResultCache')) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
if (! $profile->getResultCacheDriver()) {
|
||||
$defaultHydrationCacheImpl = $this->_em->getConfiguration()->getHydrationCache();
|
||||
if ($defaultHydrationCacheImpl) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
$profile = $profile->setResultCacheDriver(DoctrineProvider::wrap($defaultHydrationCacheImpl));
|
||||
}
|
||||
}
|
||||
@@ -609,9 +611,11 @@ abstract class AbstractQuery
|
||||
|
||||
// DBAL 2
|
||||
if (! method_exists(QueryCacheProfile::class, 'setResultCache')) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
if (! $profile->getResultCacheDriver()) {
|
||||
$defaultResultCacheDriver = $this->_em->getConfiguration()->getResultCache();
|
||||
if ($defaultResultCacheDriver) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
$profile = $profile->setResultCacheDriver(DoctrineProvider::wrap($defaultResultCacheDriver));
|
||||
}
|
||||
}
|
||||
@@ -677,6 +681,7 @@ abstract class AbstractQuery
|
||||
$resultCacheDriver = DoctrineProvider::wrap($resultCache);
|
||||
|
||||
$this->_queryCacheProfile = $this->_queryCacheProfile
|
||||
// @phpstan-ignore method.deprecated
|
||||
? $this->_queryCacheProfile->setResultCacheDriver($resultCacheDriver)
|
||||
: new QueryCacheProfile(0, null, $resultCacheDriver);
|
||||
|
||||
@@ -780,6 +785,7 @@ abstract class AbstractQuery
|
||||
|
||||
// Compatibility for DBAL 2
|
||||
if (! method_exists($this->_queryCacheProfile, 'setResultCache')) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
$this->_queryCacheProfile = $this->_queryCacheProfile->setResultCacheDriver(DoctrineProvider::wrap($cache));
|
||||
|
||||
return $this;
|
||||
@@ -838,7 +844,7 @@ abstract class AbstractQuery
|
||||
* @param class-string $class
|
||||
* @param string $assocName
|
||||
* @param int $fetchMode
|
||||
* @psalm-param Mapping\ClassMetadata::FETCH_EAGER|Mapping\ClassMetadata::FETCH_LAZY $fetchMode
|
||||
* @phpstan-param Mapping\ClassMetadata::FETCH_EAGER|Mapping\ClassMetadata::FETCH_LAZY $fetchMode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -864,7 +870,7 @@ abstract class AbstractQuery
|
||||
*
|
||||
* @param string|int $hydrationMode Doctrine processing mode to be used during hydration process.
|
||||
* One of the Query::HYDRATE_* constants.
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_* $hydrationMode
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_* $hydrationMode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -879,7 +885,7 @@ abstract class AbstractQuery
|
||||
* Gets the hydration mode currently used by the query.
|
||||
*
|
||||
* @return string|int
|
||||
* @psalm-return string|AbstractQuery::HYDRATE_*
|
||||
* @phpstan-return string|AbstractQuery::HYDRATE_*
|
||||
*/
|
||||
public function getHydrationMode()
|
||||
{
|
||||
@@ -892,7 +898,7 @@ abstract class AbstractQuery
|
||||
* Alias for execute(null, $hydrationMode = HYDRATE_OBJECT).
|
||||
*
|
||||
* @param string|int $hydrationMode
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_* $hydrationMode
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_* $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -941,7 +947,7 @@ abstract class AbstractQuery
|
||||
* Get exactly one result or null.
|
||||
*
|
||||
* @param string|int|null $hydrationMode
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -979,7 +985,7 @@ abstract class AbstractQuery
|
||||
* If there is no result, a NoResultException is thrown.
|
||||
*
|
||||
* @param string|int|null $hydrationMode
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -1077,8 +1083,8 @@ abstract class AbstractQuery
|
||||
*
|
||||
* @param ArrayCollection|mixed[]|null $parameters The query parameters.
|
||||
* @param string|int|null $hydrationMode The hydration mode to use.
|
||||
* @psalm-param ArrayCollection<int, Parameter>|array<string, mixed>|null $parameters
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode The hydration mode to use.
|
||||
* @phpstan-param ArrayCollection<int, Parameter>|array<string, mixed>|null $parameters
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_*|null $hydrationMode The hydration mode to use.
|
||||
*
|
||||
* @return IterableResult
|
||||
*/
|
||||
@@ -1115,8 +1121,8 @@ abstract class AbstractQuery
|
||||
*
|
||||
* @param ArrayCollection|array|mixed[] $parameters The query parameters.
|
||||
* @param string|int|null $hydrationMode The hydration mode to use.
|
||||
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
* @phpstan-param ArrayCollection<int, Parameter>|mixed[] $parameters
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
*
|
||||
* @return iterable<mixed>
|
||||
*/
|
||||
@@ -1152,8 +1158,8 @@ abstract class AbstractQuery
|
||||
*
|
||||
* @param ArrayCollection|mixed[]|null $parameters Query parameters.
|
||||
* @param string|int|null $hydrationMode Processing mode to be used during the hydration process.
|
||||
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
* @phpstan-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -1171,8 +1177,8 @@ abstract class AbstractQuery
|
||||
*
|
||||
* @param ArrayCollection|mixed[]|null $parameters
|
||||
* @param string|int|null $hydrationMode
|
||||
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
* @phpstan-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -1235,6 +1241,7 @@ abstract class AbstractQuery
|
||||
|
||||
// Support for DBAL 2
|
||||
if (! method_exists($this->_hydrationCacheProfile, 'getResultCache')) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
$cacheDriver = $this->_hydrationCacheProfile->getResultCacheDriver();
|
||||
assert($cacheDriver !== null);
|
||||
|
||||
@@ -1252,8 +1259,8 @@ abstract class AbstractQuery
|
||||
*
|
||||
* @param ArrayCollection|mixed[]|null $parameters
|
||||
* @param string|int|null $hydrationMode
|
||||
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
* @phpstan-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_*|null $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -1316,7 +1323,7 @@ abstract class AbstractQuery
|
||||
* automatically generated for you.
|
||||
*
|
||||
* @return string[] ($key, $hash)
|
||||
* @psalm-return array{string, string} ($key, $hash)
|
||||
* @phpstan-return array{string, string} ($key, $hash)
|
||||
*/
|
||||
protected function getHydrationCacheId()
|
||||
{
|
||||
|
||||
@@ -21,15 +21,13 @@ class AssociationCacheEntry implements CacheEntry
|
||||
* The entity class name
|
||||
*
|
||||
* @readonly Public only for performance reasons, it should be considered immutable.
|
||||
* @var string
|
||||
* @psalm-var class-string
|
||||
* @var class-string
|
||||
*/
|
||||
public $class;
|
||||
|
||||
/**
|
||||
* @param string $class The entity class.
|
||||
* @param class-string $class The entity class.
|
||||
* @param array<string, mixed> $identifier The entity identifier.
|
||||
* @psalm-param class-string $class
|
||||
*/
|
||||
public function __construct($class, array $identifier)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ use Doctrine\ORM\Persisters\Entity\EntityPersister;
|
||||
/**
|
||||
* Contract for building second level cache regions components.
|
||||
*
|
||||
* @psalm-import-type AssociationMapping from ClassMetadata
|
||||
* @phpstan-import-type AssociationMapping from ClassMetadata
|
||||
*/
|
||||
interface CacheFactory
|
||||
{
|
||||
|
||||
@@ -26,8 +26,7 @@ class CollectionCacheKey extends CacheKey
|
||||
* The owner entity class
|
||||
*
|
||||
* @readonly Public only for performance reasons, it should be considered immutable.
|
||||
* @var string
|
||||
* @psalm-var class-string
|
||||
* @var class-string
|
||||
*/
|
||||
public $entityClass;
|
||||
|
||||
@@ -40,12 +39,11 @@ class CollectionCacheKey extends CacheKey
|
||||
public $association;
|
||||
|
||||
/**
|
||||
* @param string $entityClass The entity class.
|
||||
* @param class-string $entityClass The entity class.
|
||||
* @param string $association The field name that represents the association.
|
||||
* @param array<string, mixed> $ownerIdentifier The identifier of the owning entity.
|
||||
* @psalm-param class-string $entityClass
|
||||
*/
|
||||
public function __construct($entityClass, $association, array $ownerIdentifier)
|
||||
public function __construct($entityClass, $association, array $ownerIdentifier, string $filterHash = '')
|
||||
{
|
||||
ksort($ownerIdentifier);
|
||||
|
||||
@@ -53,6 +51,8 @@ class CollectionCacheKey extends CacheKey
|
||||
$this->entityClass = (string) $entityClass;
|
||||
$this->association = (string) $association;
|
||||
|
||||
parent::__construct(str_replace('\\', '.', strtolower($entityClass)) . '_' . implode(' ', $ownerIdentifier) . '__' . $association);
|
||||
$filterHash = $filterHash === '' ? '' : '_' . $filterHash;
|
||||
|
||||
parent::__construct(str_replace('\\', '.', strtolower($entityClass)) . '_' . implode(' ', $ownerIdentifier) . '__' . $association . $filterHash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class DefaultCache implements Cache
|
||||
|
||||
/**
|
||||
* @var QueryCache[]
|
||||
* @psalm-var array<string, QueryCache>
|
||||
* @phpstan-var array<string, QueryCache>
|
||||
*/
|
||||
private $queryCaches = [];
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ use function reset;
|
||||
/**
|
||||
* Default query cache implementation.
|
||||
*
|
||||
* @psalm-import-type AssociationMapping from ClassMetadata
|
||||
* @phpstan-import-type AssociationMapping from ClassMetadata
|
||||
*/
|
||||
class DefaultQueryCache implements QueryCache
|
||||
{
|
||||
@@ -262,7 +262,6 @@ class DefaultQueryCache implements QueryCache
|
||||
$region = $persister->getCacheRegion();
|
||||
|
||||
$cm = $this->em->getClassMetadata($entityName);
|
||||
assert($cm instanceof ClassMetadata);
|
||||
|
||||
foreach ($result as $index => $entity) {
|
||||
$identifier = $this->uow->getEntityIdentifier($entity);
|
||||
@@ -331,7 +330,7 @@ class DefaultQueryCache implements QueryCache
|
||||
* @param mixed $assocValue
|
||||
*
|
||||
* @return mixed[]|null
|
||||
* @psalm-return array{targetEntity: class-string, type: mixed, list?: array[], identifier?: array}|null
|
||||
* @phpstan-return array{targetEntity: class-string, type: mixed, list?: array[], identifier?: array}|null
|
||||
*/
|
||||
private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue): ?array
|
||||
{
|
||||
@@ -386,7 +385,7 @@ class DefaultQueryCache implements QueryCache
|
||||
* @param object $entity
|
||||
*
|
||||
* @return mixed[]|object|null
|
||||
* @psalm-return list<mixed>|object|null
|
||||
* @phpstan-return list<mixed>|object|null
|
||||
*/
|
||||
private function getAssociationValue(
|
||||
ResultSetMapping $rsm,
|
||||
@@ -414,10 +413,10 @@ class DefaultQueryCache implements QueryCache
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-param array<array-key, array{field: string, class: string}> $path
|
||||
* @phpstan-param array<array-key, array{field: string, class: string}> $path
|
||||
*
|
||||
* @return mixed[]|object|null
|
||||
* @psalm-return list<mixed>|object|null
|
||||
* @phpstan-return list<mixed>|object|null
|
||||
*/
|
||||
private function getAssociationPathValue($value, array $path)
|
||||
{
|
||||
|
||||
@@ -25,15 +25,13 @@ class EntityCacheEntry implements CacheEntry
|
||||
* The entity class name
|
||||
*
|
||||
* @readonly Public only for performance reasons, it should be considered immutable.
|
||||
* @var string
|
||||
* @psalm-var class-string
|
||||
* @var class-string
|
||||
*/
|
||||
public $class;
|
||||
|
||||
/**
|
||||
* @param string $class The entity class.
|
||||
* @param class-string $class The entity class.
|
||||
* @param array<string,mixed> $data The entity data.
|
||||
* @psalm-param class-string $class
|
||||
*/
|
||||
public function __construct($class, array $data)
|
||||
{
|
||||
|
||||
@@ -26,15 +26,13 @@ class EntityCacheKey extends CacheKey
|
||||
* The entity class name
|
||||
*
|
||||
* @readonly Public only for performance reasons, it should be considered immutable.
|
||||
* @var string
|
||||
* @psalm-var class-string
|
||||
* @var class-string
|
||||
*/
|
||||
public $entityClass;
|
||||
|
||||
/**
|
||||
* @param string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class.
|
||||
* @param class-string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class.
|
||||
* @param array<string, mixed> $identifier The entity identifier
|
||||
* @psalm-param class-string $entityClass
|
||||
*/
|
||||
public function __construct($entityClass, array $identifier)
|
||||
{
|
||||
|
||||
@@ -19,13 +19,14 @@ use Doctrine\ORM\Mapping\ClassMetadataFactory;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
use Doctrine\ORM\Persisters\Collection\CollectionPersister;
|
||||
use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver;
|
||||
use Doctrine\ORM\Query\FilterCollection;
|
||||
use Doctrine\ORM\UnitOfWork;
|
||||
|
||||
use function array_values;
|
||||
use function assert;
|
||||
use function count;
|
||||
|
||||
/** @psalm-import-type AssociationMapping from ClassMetadata */
|
||||
/** @phpstan-import-type AssociationMapping from ClassMetadata */
|
||||
abstract class AbstractCollectionPersister implements CachedCollectionPersister
|
||||
{
|
||||
/** @var UnitOfWork */
|
||||
@@ -55,6 +56,9 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister
|
||||
/** @var string */
|
||||
protected $regionName;
|
||||
|
||||
/** @var FilterCollection */
|
||||
protected $filters;
|
||||
|
||||
/** @var CollectionHydrator */
|
||||
protected $hydrator;
|
||||
|
||||
@@ -76,6 +80,7 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister
|
||||
$this->region = $region;
|
||||
$this->persister = $persister;
|
||||
$this->association = $association;
|
||||
$this->filters = $em->getFilters();
|
||||
$this->regionName = $region->getName();
|
||||
$this->uow = $em->getUnitOfWork();
|
||||
$this->metadataFactory = $em->getMetadataFactory();
|
||||
@@ -189,7 +194,7 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister
|
||||
public function count(PersistentCollection $collection)
|
||||
{
|
||||
$ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId);
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId, $this->filters->getHash());
|
||||
$entry = $this->region->get($key);
|
||||
|
||||
if ($entry !== null) {
|
||||
@@ -241,7 +246,8 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister
|
||||
$key = new CollectionCacheKey(
|
||||
$this->sourceEntity->rootEntityName,
|
||||
$this->association['fieldName'],
|
||||
$this->uow->getEntityIdentifier($collection->getOwner())
|
||||
$this->uow->getEntityIdentifier($collection->getOwner()),
|
||||
$this->filters->getHash()
|
||||
);
|
||||
|
||||
$this->region->evict($key);
|
||||
@@ -254,9 +260,8 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister
|
||||
/**
|
||||
* @deprecated This method is not used anymore.
|
||||
*
|
||||
* @param string $targetEntity
|
||||
* @param object $element
|
||||
* @psalm-param class-string $targetEntity
|
||||
* @param class-string $targetEntity
|
||||
* @param object $element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -45,7 +45,7 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPers
|
||||
public function delete(PersistentCollection $collection)
|
||||
{
|
||||
$ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId);
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId, $this->filters->getHash());
|
||||
|
||||
$this->persister->delete($collection);
|
||||
|
||||
@@ -65,7 +65,7 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPers
|
||||
}
|
||||
|
||||
$ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId);
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId, $this->filters->getHash());
|
||||
|
||||
// Invalidate non initialized collections OR ordered collection
|
||||
if ($isDirty && ! $isInitialized || isset($this->association['orderBy'])) {
|
||||
|
||||
@@ -13,7 +13,7 @@ use Doctrine\ORM\Persisters\Collection\CollectionPersister;
|
||||
|
||||
use function spl_object_id;
|
||||
|
||||
/** @psalm-import-type AssociationMapping from ClassMetadata */
|
||||
/** @phpstan-import-type AssociationMapping from ClassMetadata */
|
||||
class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister
|
||||
{
|
||||
/** @param AssociationMapping $association The association mapping. */
|
||||
@@ -68,7 +68,7 @@ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister
|
||||
public function delete(PersistentCollection $collection)
|
||||
{
|
||||
$ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId);
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId, $this->filters->getHash());
|
||||
$lock = $this->region->lock($key);
|
||||
|
||||
$this->persister->delete($collection);
|
||||
@@ -98,7 +98,7 @@ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister
|
||||
$this->persister->update($collection);
|
||||
|
||||
$ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId);
|
||||
$key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId, $this->filters->getHash());
|
||||
$lock = $this->region->lock($key);
|
||||
|
||||
if ($lock === null) {
|
||||
|
||||
@@ -16,20 +16,24 @@ use Doctrine\ORM\Cache\Region;
|
||||
use Doctrine\ORM\Cache\TimestampCacheKey;
|
||||
use Doctrine\ORM\Cache\TimestampRegion;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Internal\CriteriaOrderings;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Mapping\ClassMetadataFactory;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
use Doctrine\ORM\Persisters\Entity\EntityPersister;
|
||||
use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver;
|
||||
use Doctrine\ORM\Query\FilterCollection;
|
||||
use Doctrine\ORM\UnitOfWork;
|
||||
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function func_get_args;
|
||||
use function serialize;
|
||||
use function sha1;
|
||||
|
||||
abstract class AbstractEntityPersister implements CachedEntityPersister
|
||||
{
|
||||
use CriteriaOrderings;
|
||||
|
||||
/** @var UnitOfWork */
|
||||
protected $uow;
|
||||
|
||||
@@ -60,6 +64,9 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
|
||||
/** @var Cache */
|
||||
protected $cache;
|
||||
|
||||
/** @var FilterCollection */
|
||||
protected $filters;
|
||||
|
||||
/** @var CacheLogger|null */
|
||||
protected $cacheLogger;
|
||||
|
||||
@@ -89,6 +96,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
|
||||
$this->region = $region;
|
||||
$this->persister = $persister;
|
||||
$this->cache = $em->getCache();
|
||||
$this->filters = $em->getFilters();
|
||||
$this->regionName = $region->getName();
|
||||
$this->uow = $em->getUnitOfWork();
|
||||
$this->metadataFactory = $em->getMetadataFactory();
|
||||
@@ -259,7 +267,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
|
||||
? $this->persister->expandCriteriaParameters($criteria)
|
||||
: $this->persister->expandParameters($criteria);
|
||||
|
||||
return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset);
|
||||
return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset . $this->filters->getHash());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,7 +483,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
|
||||
*/
|
||||
public function loadCriteria(Criteria $criteria)
|
||||
{
|
||||
$orderBy = $criteria->getOrderings();
|
||||
$orderBy = self::getCriteriaOrderings($criteria);
|
||||
$limit = $criteria->getMaxResults();
|
||||
$offset = $criteria->getFirstResult();
|
||||
$query = $this->persister->getSelectSQL($criteria);
|
||||
@@ -522,7 +530,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
|
||||
}
|
||||
|
||||
$ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
||||
$key = $this->buildCollectionCacheKey($assoc, $ownerId);
|
||||
$key = $this->buildCollectionCacheKey($assoc, $ownerId, $this->filters->getHash());
|
||||
$list = $persister->loadCollectionCache($collection, $key);
|
||||
|
||||
if ($list !== null) {
|
||||
@@ -557,7 +565,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
|
||||
}
|
||||
|
||||
$ownerId = $this->uow->getEntityIdentifier($collection->getOwner());
|
||||
$key = $this->buildCollectionCacheKey($assoc, $ownerId);
|
||||
$key = $this->buildCollectionCacheKey($assoc, $ownerId, $this->filters->getHash());
|
||||
$list = $persister->loadCollectionCache($collection, $key);
|
||||
|
||||
if ($list !== null) {
|
||||
@@ -609,11 +617,15 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
|
||||
*
|
||||
* @return CollectionCacheKey
|
||||
*/
|
||||
protected function buildCollectionCacheKey(array $association, $ownerId)
|
||||
protected function buildCollectionCacheKey(array $association, $ownerId/*, string $filterHash */)
|
||||
{
|
||||
$metadata = $this->metadataFactory->getMetadataFor($association['sourceEntity']);
|
||||
assert($metadata instanceof ClassMetadata);
|
||||
$filterHash = (string) (func_get_args()[2] ?? ''); // todo: move to argument in next major release
|
||||
|
||||
return new CollectionCacheKey($metadata->rootEntityName, $association['fieldName'], $ownerId);
|
||||
return new CollectionCacheKey(
|
||||
$this->metadataFactory->getMetadataFor($association['sourceEntity'])->rootEntityName,
|
||||
$association['fieldName'],
|
||||
$ownerId,
|
||||
$filterHash
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class QueryCacheKey extends CacheKey
|
||||
*
|
||||
* @readonly Public only for performance reasons, it should be considered immutable.
|
||||
* @var int
|
||||
* @psalm-var Cache::MODE_*
|
||||
* @phpstan-var Cache::MODE_*
|
||||
*/
|
||||
public $cacheMode;
|
||||
|
||||
@@ -34,7 +34,7 @@ class QueryCacheKey extends CacheKey
|
||||
*/
|
||||
public $timestampKey;
|
||||
|
||||
/** @psalm-param Cache::MODE_* $cacheMode */
|
||||
/** @phpstan-param Cache::MODE_* $cacheMode */
|
||||
public function __construct(
|
||||
string $cacheId,
|
||||
int $lifetime = 0,
|
||||
|
||||
@@ -8,6 +8,8 @@ use Doctrine\ORM\Cache\Exception\CacheException;
|
||||
|
||||
/**
|
||||
* Defines a contract for accessing a particular named region.
|
||||
*
|
||||
* @phpstan-ignore interface.extendsDeprecatedInterface
|
||||
*/
|
||||
interface Region extends MultiGetRegion
|
||||
{
|
||||
|
||||
@@ -72,6 +72,7 @@ class DefaultRegion implements Region
|
||||
CacheItemPoolInterface::class
|
||||
);
|
||||
|
||||
// @phpstan-ignore property.deprecated
|
||||
$this->cache = $cacheItemPool;
|
||||
$this->cacheItemPool = CacheAdapter::wrap($cacheItemPool);
|
||||
} elseif (! $cacheItemPool instanceof CacheItemPoolInterface) {
|
||||
@@ -82,6 +83,7 @@ class DefaultRegion implements Region
|
||||
get_debug_type($cacheItemPool)
|
||||
));
|
||||
} else {
|
||||
// @phpstan-ignore property.deprecated
|
||||
$this->cache = DoctrineProvider::wrap($cacheItemPool);
|
||||
$this->cacheItemPool = $cacheItemPool;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class FileLockRegion implements ConcurrentRegion
|
||||
/** @var string */
|
||||
private $directory;
|
||||
|
||||
/** @psalm-var numeric-string */
|
||||
/** @phpstan-var numeric-string */
|
||||
private $lockLifetime;
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,16 +70,16 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/** @var mixed[] */
|
||||
protected $_attributes = [];
|
||||
|
||||
/** @psalm-var array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> */
|
||||
/** @phpstan-var array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> */
|
||||
private $identityGenerationPreferences = [];
|
||||
|
||||
/** @psalm-param array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> $value */
|
||||
/** @phpstan-param array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> $value */
|
||||
public function setIdentityGenerationPreferences(array $value): void
|
||||
{
|
||||
$this->identityGenerationPreferences = $value;
|
||||
}
|
||||
|
||||
/** @psalm-return array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> $value */
|
||||
/** @phpstan-return array<class-string<AbstractPlatform>, ClassMetadata::GENERATOR_TYPE_*> $value */
|
||||
public function getIdentityGenerationPreferences(): array
|
||||
{
|
||||
return $this->identityGenerationPreferences;
|
||||
@@ -172,7 +172,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @param string|string[] $paths
|
||||
* @param bool $useSimpleAnnotationReader
|
||||
* @psalm-param string|list<string> $paths
|
||||
* @phpstan-param string|list<string> $paths
|
||||
*
|
||||
* @return AnnotationDriver
|
||||
*/
|
||||
@@ -269,6 +269,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
);
|
||||
|
||||
if (! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) {
|
||||
// @phpstan-ignore staticMethod.deprecatedClass
|
||||
throw UnknownEntityNamespace::fromNamespaceAlias($entityNamespaceAlias);
|
||||
}
|
||||
|
||||
@@ -278,7 +279,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Sets the entity alias map.
|
||||
*
|
||||
* @psalm-param array<string, string> $entityNamespaces
|
||||
* @phpstan-param array<string, string> $entityNamespaces
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -290,7 +291,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Retrieves the list of registered entity namespace aliases.
|
||||
*
|
||||
* @psalm-return array<string, string>
|
||||
* @phpstan-return array<string, string>
|
||||
*/
|
||||
public function getEntityNamespaces()
|
||||
{
|
||||
@@ -314,6 +315,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
{
|
||||
// Compatibility with DBAL 2
|
||||
if (! method_exists(parent::class, 'getResultCache')) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
$cacheImpl = $this->getResultCacheImpl();
|
||||
|
||||
return $cacheImpl ? CacheAdapter::wrap($cacheImpl) : null;
|
||||
@@ -329,6 +331,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
{
|
||||
// Compatibility with DBAL 2
|
||||
if (! method_exists(parent::class, 'setResultCache')) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
$this->setResultCacheImpl(DoctrineProvider::wrap($cache));
|
||||
|
||||
return;
|
||||
@@ -548,7 +551,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
* @param string $name The name of the query.
|
||||
*
|
||||
* @return mixed[]
|
||||
* @psalm-return array{string, ResultSetMapping} A tuple with the first element being the SQL string and the second
|
||||
* @phpstan-return array{string, ResultSetMapping} A tuple with the first element being the SQL string and the second
|
||||
* element being the ResultSetMapping.
|
||||
*
|
||||
* @throws NamedNativeQueryNotFound
|
||||
@@ -617,7 +620,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @param string $name Function name.
|
||||
* @param class-string|callable $className Class name or a callable that returns the function.
|
||||
* @psalm-param class-string<FunctionNode>|callable(string):FunctionNode $className
|
||||
* @phpstan-param class-string<FunctionNode>|callable(string):FunctionNode $className
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -632,7 +635,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
* @param string $name
|
||||
*
|
||||
* @return string|callable|null
|
||||
* @psalm-return class-string<FunctionNode>|callable(string):FunctionNode|null
|
||||
* @phpstan-return class-string<FunctionNode>|callable(string):FunctionNode|null
|
||||
*/
|
||||
public function getCustomStringFunction($name)
|
||||
{
|
||||
@@ -649,7 +652,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* Any previously added string functions are discarded.
|
||||
*
|
||||
* @psalm-param array<string, class-string<FunctionNode>|callable(string):FunctionNode> $functions The map of custom
|
||||
* @phpstan-param array<string, class-string<FunctionNode>|callable(string):FunctionNode> $functions The map of custom
|
||||
* DQL string functions.
|
||||
*
|
||||
* @return void
|
||||
@@ -670,7 +673,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @param string $name Function name.
|
||||
* @param class-string|callable $className Class name or a callable that returns the function.
|
||||
* @psalm-param class-string<FunctionNode>|callable(string):FunctionNode $className
|
||||
* @phpstan-param class-string<FunctionNode>|callable(string):FunctionNode $className
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -684,8 +687,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string|callable|null
|
||||
* @psalm-return class-string|callable|null
|
||||
* @return class-string|callable|null
|
||||
*/
|
||||
public function getCustomNumericFunction($name)
|
||||
{
|
||||
@@ -702,7 +704,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* Any previously added numeric functions are discarded.
|
||||
*
|
||||
* @psalm-param array<string, class-string> $functions The map of custom
|
||||
* @param array<string, class-string> $functions The map of custom
|
||||
* DQL numeric functions.
|
||||
*
|
||||
* @return void
|
||||
@@ -723,7 +725,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @param string $name Function name.
|
||||
* @param string|callable $className Class name or a callable that returns the function.
|
||||
* @psalm-param class-string<FunctionNode>|callable(string):FunctionNode $className
|
||||
* @phpstan-param class-string<FunctionNode>|callable(string):FunctionNode $className
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -737,8 +739,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string|callable|null
|
||||
* @psalm-return class-string|callable|null
|
||||
* @return class-string|callable|null
|
||||
*/
|
||||
public function getCustomDatetimeFunction($name)
|
||||
{
|
||||
@@ -756,7 +757,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
* Any previously added date/time functions are discarded.
|
||||
*
|
||||
* @param array $functions The map of custom DQL date/time functions.
|
||||
* @psalm-param array<string, class-string<FunctionNode>|callable(string):FunctionNode> $functions
|
||||
* @phpstan-param array<string, class-string<FunctionNode>|callable(string):FunctionNode> $functions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -804,8 +805,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @param string $modeName The hydration mode name.
|
||||
*
|
||||
* @return string|null The hydrator class name.
|
||||
* @psalm-return class-string<AbstractHydrator>|null
|
||||
* @return class-string<AbstractHydrator>|null The hydrator class name.
|
||||
*/
|
||||
public function getCustomHydrationMode($modeName)
|
||||
{
|
||||
@@ -815,9 +815,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Adds a custom hydration mode.
|
||||
*
|
||||
* @param string $modeName The hydration mode name.
|
||||
* @param string $hydrator The hydrator class name.
|
||||
* @psalm-param class-string<AbstractHydrator> $hydrator
|
||||
* @param string $modeName The hydration mode name.
|
||||
* @param class-string<AbstractHydrator> $hydrator The hydrator class name.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -829,8 +828,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Sets a class metadata factory.
|
||||
*
|
||||
* @param string $cmfName
|
||||
* @psalm-param class-string $cmfName
|
||||
* @param class-string $cmfName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -839,10 +837,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
$this->_attributes['classMetadataFactoryName'] = $cmfName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @psalm-return class-string
|
||||
*/
|
||||
/** @return class-string */
|
||||
public function getClassMetadataFactoryName()
|
||||
{
|
||||
if (! isset($this->_attributes['classMetadataFactoryName'])) {
|
||||
@@ -855,9 +850,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Adds a filter to the list of possible filters.
|
||||
*
|
||||
* @param string $name The name of the filter.
|
||||
* @param string $className The class name of the filter.
|
||||
* @psalm-param class-string<SQLFilter> $className
|
||||
* @param string $name The name of the filter.
|
||||
* @param class-string<SQLFilter> $className The class name of the filter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -871,9 +865,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @param string $name The name of the filter.
|
||||
*
|
||||
* @return string|null The class name of the filter, or null if it is not
|
||||
* defined.
|
||||
* @psalm-return class-string<SQLFilter>|null
|
||||
* @return class-string<SQLFilter>|null The class name of the filter,
|
||||
* or null if it is not defined.
|
||||
*/
|
||||
public function getFilterClassName($name)
|
||||
{
|
||||
@@ -883,8 +876,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Sets default repository class.
|
||||
*
|
||||
* @param string $className
|
||||
* @psalm-param class-string<EntityRepository> $className
|
||||
* @param class-string<EntityRepository> $className
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -912,8 +904,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Get default repository class.
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string<EntityRepository>
|
||||
* @return class-string<EntityRepository>
|
||||
*/
|
||||
public function getDefaultRepositoryClassName()
|
||||
{
|
||||
@@ -1047,7 +1038,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Returns query hints, which will be applied to every query in application
|
||||
*
|
||||
* @psalm-return array<string, mixed>
|
||||
* @phpstan-return array<string, mixed>
|
||||
*/
|
||||
public function getDefaultQueryHints()
|
||||
{
|
||||
@@ -1057,7 +1048,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
/**
|
||||
* Sets array of query hints, which will be applied to every query in application
|
||||
*
|
||||
* @psalm-param array<string, mixed> $defaultQueryHints
|
||||
* @phpstan-param array<string, mixed> $defaultQueryHints
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -50,9 +50,9 @@ abstract class EntityManagerDecorator extends ObjectManagerDecorator implements
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
* @param class-string<T> $className
|
||||
*
|
||||
* @psalm-return EntityRepository<T>
|
||||
* @phpstan-return EntityRepository<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -96,6 +96,7 @@ abstract class EntityManagerDecorator extends ObjectManagerDecorator implements
|
||||
E_USER_NOTICE
|
||||
);
|
||||
|
||||
// @phpstan-ignore method.deprecated
|
||||
return $this->wrapped->transactional($func);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@ use Doctrine\ORM\Query\FilterCollection;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\ORM\Repository\RepositoryFactory;
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use InvalidArgumentException;
|
||||
use Throwable;
|
||||
|
||||
use function array_keys;
|
||||
use function class_exists;
|
||||
@@ -162,8 +160,9 @@ class EntityManager implements EntityManagerInterface
|
||||
throw MissingMappingDriverImplementation::create();
|
||||
}
|
||||
|
||||
$this->conn = $conn;
|
||||
$this->config = $config;
|
||||
$this->conn = $conn;
|
||||
$this->config = $config;
|
||||
// @phpstan-ignore method.deprecated
|
||||
$this->eventManager = $eventManager ?? $conn->getEventManager();
|
||||
|
||||
$metadataFactoryClassName = $config->getClassMetadataFactoryName();
|
||||
@@ -246,18 +245,24 @@ class EntityManager implements EntityManagerInterface
|
||||
|
||||
$this->conn->beginTransaction();
|
||||
|
||||
$successful = false;
|
||||
|
||||
try {
|
||||
$return = $func($this);
|
||||
|
||||
$this->flush();
|
||||
$this->conn->commit();
|
||||
|
||||
return $return ?: true;
|
||||
} catch (Throwable $e) {
|
||||
$this->close();
|
||||
$this->conn->rollBack();
|
||||
$successful = true;
|
||||
|
||||
throw $e;
|
||||
return $return ?: true;
|
||||
} finally {
|
||||
if (! $successful) {
|
||||
$this->close();
|
||||
if ($this->conn->isTransactionActive()) {
|
||||
$this->conn->rollBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,18 +273,24 @@ class EntityManager implements EntityManagerInterface
|
||||
{
|
||||
$this->conn->beginTransaction();
|
||||
|
||||
$successful = false;
|
||||
|
||||
try {
|
||||
$return = $func($this);
|
||||
|
||||
$this->flush();
|
||||
$this->conn->commit();
|
||||
|
||||
return $return;
|
||||
} catch (Throwable $e) {
|
||||
$this->close();
|
||||
$this->conn->rollBack();
|
||||
$successful = true;
|
||||
|
||||
throw $e;
|
||||
return $return;
|
||||
} finally {
|
||||
if (! $successful) {
|
||||
$this->close();
|
||||
if ($this->conn->isTransactionActive()) {
|
||||
$this->conn->rollBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,25 +417,23 @@ class EntityManager implements EntityManagerInterface
|
||||
/**
|
||||
* Finds an Entity by its identifier.
|
||||
*
|
||||
* @param string $className The class name of the entity to find.
|
||||
* @param mixed $id The identity of the entity to find.
|
||||
* @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants
|
||||
* or NULL if no specific lock mode should be used
|
||||
* during the search.
|
||||
* @param int|null $lockVersion The version of the entity to find when using
|
||||
* optimistic locking.
|
||||
* @psalm-param class-string<T> $className
|
||||
* @psalm-param LockMode::*|null $lockMode
|
||||
* @param class-string<T> $className The class name of the entity to find.
|
||||
* @param mixed $id The identity of the entity to find.
|
||||
* @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants
|
||||
* or NULL if no specific lock mode should be used
|
||||
* during the search.
|
||||
* @param int|null $lockVersion The version of the entity to find when using
|
||||
* optimistic locking.
|
||||
* @phpstan-param LockMode::*|null $lockMode
|
||||
*
|
||||
* @return object|null The entity instance or NULL if the entity can not be found.
|
||||
* @psalm-return ?T
|
||||
* @return T|null The entity instance or NULL if the entity can not be found.
|
||||
*
|
||||
* @throws OptimisticLockException
|
||||
* @throws ORMInvalidArgumentException
|
||||
* @throws TransactionRequiredException
|
||||
* @throws ORMException
|
||||
*
|
||||
* @template T
|
||||
* @template T of object
|
||||
*/
|
||||
public function find($className, $id, $lockMode = null, $lockVersion = null)
|
||||
{
|
||||
@@ -615,6 +624,7 @@ class EntityManager implements EntityManagerInterface
|
||||
public function clear($entityName = null)
|
||||
{
|
||||
if ($entityName !== null && ! is_string($entityName)) {
|
||||
// @phpstan-ignore staticMethod.deprecated
|
||||
throw ORMInvalidArgumentException::invalidEntityName($entityName);
|
||||
}
|
||||
|
||||
@@ -700,7 +710,7 @@ class EntityManager implements EntityManagerInterface
|
||||
* overriding any local changes that have not yet been persisted.
|
||||
*
|
||||
* @param object $entity The entity to refresh
|
||||
* @psalm-param LockMode::*|null $lockMode
|
||||
* @phpstan-param LockMode::*|null $lockMode
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -776,7 +786,7 @@ class EntityManager implements EntityManagerInterface
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-return never
|
||||
* @phpstan-return never
|
||||
*/
|
||||
public function copy($entity, $deep = false)
|
||||
{
|
||||
@@ -801,11 +811,9 @@ class EntityManager implements EntityManagerInterface
|
||||
/**
|
||||
* Gets the repository for an entity class.
|
||||
*
|
||||
* @param string $entityName The name of the entity.
|
||||
* @psalm-param class-string<T> $entityName
|
||||
* @param class-string<T> $entityName The name of the entity.
|
||||
*
|
||||
* @return ObjectRepository|EntityRepository The repository class.
|
||||
* @psalm-return EntityRepository<T>
|
||||
* @return EntityRepository<T> The repository class.
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -975,7 +983,7 @@ class EntityManager implements EntityManagerInterface
|
||||
* @param mixed[]|Connection $connection An array with the connection parameters or an existing Connection instance.
|
||||
* @param Configuration $config The Configuration instance to use.
|
||||
* @param EventManager|null $eventManager The EventManager instance to use.
|
||||
* @psalm-param array<string, mixed>|Connection $connection
|
||||
* @phpstan-param array<string, mixed>|Connection $connection
|
||||
*
|
||||
* @return EntityManager The created EntityManager.
|
||||
*
|
||||
@@ -1006,7 +1014,7 @@ class EntityManager implements EntityManagerInterface
|
||||
* @param mixed[]|Connection $connection An array with the connection parameters or an existing Connection instance.
|
||||
* @param Configuration $config The Configuration instance to use.
|
||||
* @param EventManager|null $eventManager The EventManager instance to use.
|
||||
* @psalm-param array<string, mixed>|Connection $connection
|
||||
* @phpstan-param array<string, mixed>|Connection $connection
|
||||
*
|
||||
* @return Connection
|
||||
*
|
||||
@@ -1073,7 +1081,7 @@ class EntityManager implements EntityManagerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param LockMode::* $lockMode
|
||||
* @phpstan-param LockMode::* $lockMode
|
||||
*
|
||||
* @throws OptimisticLockException
|
||||
* @throws TransactionRequiredException
|
||||
@@ -1109,6 +1117,7 @@ class EntityManager implements EntityManagerInterface
|
||||
|
||||
private function configureLegacyMetadataCache(): void
|
||||
{
|
||||
// @phpstan-ignore method.deprecated
|
||||
$metadataCache = $this->config->getMetadataCacheImpl();
|
||||
if (! $metadataCache) {
|
||||
return;
|
||||
|
||||
@@ -29,9 +29,9 @@ interface EntityManagerInterface extends ObjectManager
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
* @param class-string<T> $className
|
||||
*
|
||||
* @psalm-return EntityRepository<T>
|
||||
* @return EntityRepository<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -172,12 +172,10 @@ interface EntityManagerInterface extends ObjectManager
|
||||
* Gets a reference to the entity identified by the given type and identifier
|
||||
* without actually loading it, if the entity is not yet loaded.
|
||||
*
|
||||
* @param string $entityName The name of the entity type.
|
||||
* @param mixed $id The entity identifier.
|
||||
* @psalm-param class-string<T> $entityName
|
||||
* @param class-string<T> $entityName The name of the entity type.
|
||||
* @param mixed $id The entity identifier.
|
||||
*
|
||||
* @return object|null The entity reference.
|
||||
* @psalm-return T|null
|
||||
* @return T|null The entity reference.
|
||||
*
|
||||
* @throws ORMException
|
||||
*
|
||||
@@ -202,12 +200,10 @@ interface EntityManagerInterface extends ObjectManager
|
||||
*
|
||||
* @deprecated 2.7 This method is being removed from the ORM and won't have any replacement
|
||||
*
|
||||
* @param string $entityName The name of the entity type.
|
||||
* @param mixed $identifier The entity identifier.
|
||||
* @psalm-param class-string<T> $entityName
|
||||
* @param class-string<T> $entityName The name of the entity type.
|
||||
* @param mixed $identifier The entity identifier.
|
||||
*
|
||||
* @return object|null The (partial) entity reference
|
||||
* @psalm-return T|null
|
||||
* @return T|null The (partial) entity reference
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
@@ -242,7 +238,7 @@ interface EntityManagerInterface extends ObjectManager
|
||||
* @param object $entity
|
||||
* @param int $lockMode
|
||||
* @param int|DateTimeInterface|null $lockVersion
|
||||
* @psalm-param LockMode::* $lockMode
|
||||
* @phpstan-param LockMode::* $lockMode
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -288,7 +284,7 @@ interface EntityManagerInterface extends ObjectManager
|
||||
* @deprecated
|
||||
*
|
||||
* @param string|int $hydrationMode
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_* $hydrationMode
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_* $hydrationMode
|
||||
*
|
||||
* @return AbstractHydrator
|
||||
*/
|
||||
@@ -298,7 +294,7 @@ interface EntityManagerInterface extends ObjectManager
|
||||
* Create a new instance for the given hydration mode.
|
||||
*
|
||||
* @param string|int $hydrationMode
|
||||
* @psalm-param string|AbstractQuery::HYDRATE_* $hydrationMode
|
||||
* @phpstan-param string|AbstractQuery::HYDRATE_* $hydrationMode
|
||||
*
|
||||
* @return AbstractHydrator
|
||||
*
|
||||
@@ -337,12 +333,12 @@ interface EntityManagerInterface extends ObjectManager
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-param string|class-string<T> $className
|
||||
* @param string|class-string<T> $className
|
||||
*
|
||||
* @return Mapping\ClassMetadata
|
||||
* @psalm-return Mapping\ClassMetadata<T>
|
||||
* @phpstan-return ($className is class-string<T> ? Mapping\ClassMetadata<T> : Mapping\ClassMetadata<object>)
|
||||
*
|
||||
* @psalm-template T of object
|
||||
* @phpstan-template T of object
|
||||
*/
|
||||
public function getClassMetadata($className);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
/**
|
||||
* @internal This property will be private in 3.0, call {@see getEntityName()} instead.
|
||||
*
|
||||
* @var string
|
||||
* @psalm-var class-string<T>
|
||||
* @var class-string<T>
|
||||
*/
|
||||
protected $_entityName;
|
||||
|
||||
@@ -58,14 +57,14 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
* @internal This property will be private in 3.0, call {@see getClassMetadata()} instead.
|
||||
*
|
||||
* @var ClassMetadata
|
||||
* @psalm-var ClassMetadata<T>
|
||||
* @phpstan-var ClassMetadata<T>
|
||||
*/
|
||||
protected $_class;
|
||||
|
||||
/** @var Inflector|null */
|
||||
private static $inflector;
|
||||
|
||||
/** @psalm-param ClassMetadata<T> $class */
|
||||
/** @phpstan-param ClassMetadata<T> $class */
|
||||
public function __construct(EntityManagerInterface $em, ClassMetadata $class)
|
||||
{
|
||||
$this->_entityName = $class->name;
|
||||
@@ -187,10 +186,10 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
* or NULL if no specific lock mode should be used
|
||||
* during the search.
|
||||
* @param int|null $lockVersion The lock version.
|
||||
* @psalm-param LockMode::*|null $lockMode
|
||||
* @phpstan-param LockMode::*|null $lockMode
|
||||
*
|
||||
* @return object|null The entity instance or NULL if the entity can not be found.
|
||||
* @psalm-return ?T
|
||||
* @phpstan-return ?T
|
||||
*/
|
||||
public function find($id, $lockMode = null, $lockVersion = null)
|
||||
{
|
||||
@@ -200,7 +199,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
/**
|
||||
* Finds all entities in the repository.
|
||||
*
|
||||
* @psalm-return list<T> The entities.
|
||||
* @phpstan-return list<T> The entities.
|
||||
*/
|
||||
public function findAll()
|
||||
{
|
||||
@@ -212,11 +211,11 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
*
|
||||
* @param int|null $limit
|
||||
* @param int|null $offset
|
||||
* @psalm-param array<string, mixed> $criteria
|
||||
* @psalm-param array<string, string>|null $orderBy
|
||||
* @phpstan-param array<string, mixed> $criteria
|
||||
* @phpstan-param array<string, string>|null $orderBy
|
||||
*
|
||||
* @return object[] The objects.
|
||||
* @psalm-return list<T>
|
||||
* @phpstan-return list<T>
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
|
||||
{
|
||||
@@ -228,11 +227,11 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
/**
|
||||
* Finds a single entity by a set of criteria.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $criteria
|
||||
* @psalm-param array<string, string>|null $orderBy
|
||||
* @phpstan-param array<string, mixed> $criteria
|
||||
* @phpstan-param array<string, string>|null $orderBy
|
||||
*
|
||||
* @return object|null The entity instance or NULL if the entity can not be found.
|
||||
* @psalm-return ?T
|
||||
* @phpstan-return ?T
|
||||
*/
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null)
|
||||
{
|
||||
@@ -244,7 +243,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
/**
|
||||
* Counts entities by a set of criteria.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $criteria
|
||||
* @phpstan-param array<string, mixed> $criteria
|
||||
*
|
||||
* @return int The cardinality of the objects that match the given criteria.
|
||||
*
|
||||
@@ -260,7 +259,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
*
|
||||
* @param string $method
|
||||
* @param mixed[] $arguments
|
||||
* @psalm-param list<mixed> $arguments
|
||||
* @phpstan-param list<mixed> $arguments
|
||||
*
|
||||
* @return mixed The returned value from the resolved method.
|
||||
*
|
||||
@@ -287,10 +286,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @psalm-return class-string<T>
|
||||
*/
|
||||
/** @return class-string<T> */
|
||||
protected function getEntityName()
|
||||
{
|
||||
return $this->_entityName;
|
||||
@@ -312,7 +308,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
|
||||
/**
|
||||
* @return ClassMetadata
|
||||
* @psalm-return ClassMetadata<T>
|
||||
* @phpstan-return ClassMetadata<T>
|
||||
*/
|
||||
protected function getClassMetadata()
|
||||
{
|
||||
@@ -324,7 +320,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
* return a new collection containing these elements.
|
||||
*
|
||||
* @return AbstractLazyCollection
|
||||
* @psalm-return AbstractLazyCollection<int, T>&Selectable<int, T>
|
||||
* @phpstan-return AbstractLazyCollection<int, T>&Selectable<int, T>
|
||||
*/
|
||||
public function matching(Criteria $criteria)
|
||||
{
|
||||
@@ -338,7 +334,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
*
|
||||
* @param string $method The method to call
|
||||
* @param string $by The property name used as condition
|
||||
* @psalm-param list<mixed> $arguments The arguments to pass at method call
|
||||
* @phpstan-param list<mixed> $arguments The arguments to pass at method call
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
|
||||
@@ -43,7 +43,7 @@ class ListenersInvoker
|
||||
* @param string $eventName The entity lifecycle event.
|
||||
*
|
||||
* @return int Bitmask of subscribed event systems.
|
||||
* @psalm-return int-mask-of<self::INVOKE_*>
|
||||
* @phpstan-return int-mask-of<self::INVOKE_*>
|
||||
*/
|
||||
public function getSubscribedSystems(ClassMetadata $metadata, $eventName)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ class ListenersInvoker
|
||||
* @param object $entity The Entity on which the event occurred.
|
||||
* @param EventArgs $event The Event args.
|
||||
* @param int $invoke Bitmask to invoke listeners.
|
||||
* @psalm-param int-mask-of<self::INVOKE_*> $invoke
|
||||
* @phpstan-param int-mask-of<self::INVOKE_*> $invoke
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Event;
|
||||
|
||||
/** @phpstan-ignore class.extendsDeprecatedClass */
|
||||
final class PostLoadEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Event;
|
||||
|
||||
/** @phpstan-ignore class.extendsDeprecatedClass */
|
||||
final class PostPersistEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Event;
|
||||
|
||||
/** @phpstan-ignore class.extendsDeprecatedClass */
|
||||
final class PostRemoveEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Event;
|
||||
|
||||
/** @phpstan-ignore class.extendsDeprecatedClass */
|
||||
final class PostUpdateEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Event;
|
||||
|
||||
/** @phpstan-ignore class.extendsDeprecatedClass */
|
||||
final class PrePersistEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Event;
|
||||
|
||||
/** @phpstan-ignore class.extendsDeprecatedClass */
|
||||
final class PreRemoveEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ use function sprintf;
|
||||
|
||||
/**
|
||||
* Class that holds event arguments for a preUpdate event.
|
||||
*
|
||||
* @phpstan-ignore class.extendsDeprecatedClass
|
||||
*/
|
||||
class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
@@ -22,10 +24,11 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
/**
|
||||
* @param object $entity
|
||||
* @param mixed[][] $changeSet
|
||||
* @psalm-param array<string, array{mixed, mixed}|PersistentCollection> $changeSet
|
||||
* @phpstan-param array<string, array{mixed, mixed}|PersistentCollection> $changeSet
|
||||
*/
|
||||
public function __construct($entity, EntityManagerInterface $em, array &$changeSet)
|
||||
{
|
||||
// @phpstan-ignore staticMethod.deprecatedClass
|
||||
parent::__construct($entity, $em);
|
||||
|
||||
$this->entityChangeSet = &$changeSet;
|
||||
@@ -35,7 +38,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
* Retrieves entity changeset.
|
||||
*
|
||||
* @return mixed[][]
|
||||
* @psalm-return array<string, array{mixed, mixed}|PersistentCollection>
|
||||
* @phpstan-return array<string, array{mixed, mixed}|PersistentCollection>
|
||||
*/
|
||||
public function getEntityChangeSet()
|
||||
{
|
||||
|
||||
@@ -103,16 +103,14 @@ final class Events
|
||||
* The onFlush event occurs when the EntityManager#flush() operation is invoked,
|
||||
* after any changes to managed entities have been determined but before any
|
||||
* actual database operations are executed. The event is only raised if there is
|
||||
* actually something to do for the underlying UnitOfWork. If nothing needs to be done,
|
||||
* the onFlush event is not raised.
|
||||
* actually something to do for the underlying UnitOfWork.
|
||||
*/
|
||||
public const onFlush = 'onFlush';
|
||||
|
||||
/**
|
||||
* The postFlush event occurs when the EntityManager#flush() operation is invoked and
|
||||
* after all actual database operations are executed successfully. The event is only raised if there is
|
||||
* actually something to do for the underlying UnitOfWork. If nothing needs to be done,
|
||||
* the postFlush event is not raised. The event won't be raised if an error occurs during the
|
||||
* actually something to do for the underlying UnitOfWork. The event won't be raised if an error occurs during the
|
||||
* flush operation.
|
||||
*/
|
||||
public const postFlush = 'postFlush';
|
||||
|
||||
@@ -8,6 +8,8 @@ use Doctrine\ORM\ORMException as BaseORMException;
|
||||
|
||||
/**
|
||||
* Should become an interface in 3.0
|
||||
*
|
||||
* @phpstan-ignore class.extendsDeprecatedClass
|
||||
*/
|
||||
class ORMException extends BaseORMException
|
||||
{
|
||||
|
||||
@@ -73,6 +73,7 @@ abstract class AbstractIdGenerator
|
||||
throw new InvalidArgumentException('Unsupported entity manager implementation.');
|
||||
}
|
||||
|
||||
// @phpstan-ignore method.deprecated
|
||||
return $this->generate($em, $entity);
|
||||
}
|
||||
|
||||
|
||||
51
src/Internal/CriteriaOrderings.php
Normal file
51
src/Internal/CriteriaOrderings.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Internal;
|
||||
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\Order;
|
||||
|
||||
use function array_map;
|
||||
use function class_exists;
|
||||
use function method_exists;
|
||||
use function strtoupper;
|
||||
|
||||
trait CriteriaOrderings
|
||||
{
|
||||
/** @return array<string, string> */
|
||||
private static function getCriteriaOrderings(Criteria $criteria): array
|
||||
{
|
||||
if (! method_exists(Criteria::class, 'orderings')) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
return $criteria->getOrderings();
|
||||
}
|
||||
|
||||
return array_map(
|
||||
static function (Order $order): string {
|
||||
return $order->value;
|
||||
},
|
||||
$criteria->orderings()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $orderings
|
||||
*
|
||||
* @return array<string, string>|array<string, Order>
|
||||
*/
|
||||
private static function mapToOrderEnumIfAvailable(array $orderings): array
|
||||
{
|
||||
if (! class_exists(Order::class)) {
|
||||
return $orderings;
|
||||
}
|
||||
|
||||
return array_map(
|
||||
static function (string $order): Order {
|
||||
return Order::from(strtoupper($order));
|
||||
},
|
||||
$orderings
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ abstract class AbstractHydrator
|
||||
*
|
||||
* @param Result|ResultStatement $stmt
|
||||
* @param ResultSetMapping $resultSetMapping
|
||||
* @psalm-param array<string, mixed> $hints
|
||||
* @phpstan-param array<string, mixed> $hints
|
||||
*
|
||||
* @return IterableResult
|
||||
*/
|
||||
@@ -142,7 +142,7 @@ abstract class AbstractHydrator
|
||||
* Initiates a row-by-row hydration.
|
||||
*
|
||||
* @param Result|ResultStatement $stmt
|
||||
* @psalm-param array<string, mixed> $hints
|
||||
* @phpstan-param array<string, mixed> $hints
|
||||
*
|
||||
* @return Generator<array-key, mixed>
|
||||
*
|
||||
@@ -182,29 +182,31 @@ abstract class AbstractHydrator
|
||||
|
||||
$this->prepare();
|
||||
|
||||
while (true) {
|
||||
$row = $this->statement()->fetchAssociative();
|
||||
try {
|
||||
while (true) {
|
||||
$row = $this->statement()->fetchAssociative();
|
||||
|
||||
if ($row === false) {
|
||||
$this->cleanup();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
$this->hydrateRowData($row, $result);
|
||||
|
||||
$this->cleanupAfterRowIteration();
|
||||
if (count($result) === 1) {
|
||||
if (count($resultSetMapping->indexByMap) === 0) {
|
||||
yield end($result);
|
||||
} else {
|
||||
yield from $result;
|
||||
if ($row === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
$this->hydrateRowData($row, $result);
|
||||
|
||||
$this->cleanupAfterRowIteration();
|
||||
if (count($result) === 1) {
|
||||
if (count($resultSetMapping->indexByMap) === 0) {
|
||||
yield end($result);
|
||||
} else {
|
||||
yield from $result;
|
||||
}
|
||||
} else {
|
||||
yield $result;
|
||||
}
|
||||
} else {
|
||||
yield $result;
|
||||
}
|
||||
} finally {
|
||||
$this->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +233,7 @@ abstract class AbstractHydrator
|
||||
*
|
||||
* @param Result|ResultStatement $stmt
|
||||
* @param ResultSetMapping $resultSetMapping
|
||||
* @psalm-param array<string, string> $hints
|
||||
* @phpstan-param array<string, string> $hints
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
@@ -388,14 +390,14 @@ abstract class AbstractHydrator
|
||||
* the values applied. Scalar values are kept in a specific key 'scalars'.
|
||||
*
|
||||
* @param mixed[] $data SQL Result Row.
|
||||
* @psalm-param array<string, string> $id Dql-Alias => ID-Hash.
|
||||
* @psalm-param array<string, bool> $nonemptyComponents Does this DQL-Alias has at least one non NULL value?
|
||||
* @phpstan-param array<string, string> $id Dql-Alias => ID-Hash.
|
||||
* @phpstan-param array<string, bool> $nonemptyComponents Does this DQL-Alias has at least one non NULL value?
|
||||
*
|
||||
* @return array<string, array<string, mixed>> An array with all the fields
|
||||
* (name => value) of the data
|
||||
* row, grouped by their
|
||||
* component alias.
|
||||
* @psalm-return array{
|
||||
* @phpstan-return array{
|
||||
* data: array<array-key, array>,
|
||||
* newObjects?: array<array-key, array{
|
||||
* class: mixed,
|
||||
@@ -493,10 +495,10 @@ abstract class AbstractHydrator
|
||||
* of elements as before.
|
||||
*
|
||||
* @param mixed[] $data
|
||||
* @psalm-param array<string, mixed> $data
|
||||
* @phpstan-param array<string, mixed> $data
|
||||
*
|
||||
* @return mixed[] The processed row.
|
||||
* @psalm-return array<string, mixed>
|
||||
* @phpstan-return array<string, mixed>
|
||||
*/
|
||||
protected function gatherScalarRowData(&$data)
|
||||
{
|
||||
@@ -531,7 +533,7 @@ abstract class AbstractHydrator
|
||||
* @param string $key Column name
|
||||
*
|
||||
* @return mixed[]|null
|
||||
* @psalm-return array<string, mixed>|null
|
||||
* @phpstan-return array<string, mixed>|null
|
||||
*/
|
||||
protected function hydrateColumnInfo($key)
|
||||
{
|
||||
@@ -628,7 +630,7 @@ abstract class AbstractHydrator
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
* @psalm-return non-empty-list<string>
|
||||
* @phpstan-return non-empty-list<string>
|
||||
*/
|
||||
private function getDiscriminatorValues(ClassMetadata $classMetadata): array
|
||||
{
|
||||
|
||||
@@ -219,7 +219,7 @@ class ObjectHydrator extends AbstractHydrator
|
||||
* Gets an entity instance.
|
||||
*
|
||||
* @param string $dqlAlias The DQL alias of the entity's class.
|
||||
* @psalm-param array<string, mixed> $data The instance data.
|
||||
* @phpstan-param array<string, mixed> $data The instance data.
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
@@ -273,8 +273,8 @@ class ObjectHydrator extends AbstractHydrator
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param class-string $className
|
||||
* @psalm-param array<string, mixed> $data
|
||||
* @param class-string $className
|
||||
* @phpstan-param array<string, mixed> $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -367,11 +367,15 @@ class ObjectHydrator extends AbstractHydrator
|
||||
$parentObject = $this->resultPointers[$parentAlias];
|
||||
} else {
|
||||
// Parent object of relation not found, mark as not-fetched again
|
||||
$element = $this->getEntity($data, $dqlAlias);
|
||||
if (isset($nonemptyComponents[$dqlAlias])) {
|
||||
$element = $this->getEntity($data, $dqlAlias);
|
||||
|
||||
// Update result pointer and provide initial fetch data for parent
|
||||
$this->resultPointers[$dqlAlias] = $element;
|
||||
$rowData['data'][$parentAlias][$relationField] = $element;
|
||||
// Update result pointer and provide initial fetch data for parent
|
||||
$this->resultPointers[$dqlAlias] = $element;
|
||||
$rowData['data'][$parentAlias][$relationField] = $element;
|
||||
} else {
|
||||
$element = null;
|
||||
}
|
||||
|
||||
// Mark as not-fetched again
|
||||
unset($this->_hints['fetched'][$parentAlias][$relationField]);
|
||||
|
||||
@@ -16,6 +16,7 @@ use function array_keys;
|
||||
use function array_search;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function key;
|
||||
use function reset;
|
||||
use function sprintf;
|
||||
@@ -143,14 +144,21 @@ class SimpleObjectHydrator extends AbstractHydrator
|
||||
}
|
||||
|
||||
if ($value !== null && isset($cacheKeyInfo['enumType'])) {
|
||||
$originalValue = $value;
|
||||
$originalValue = $currentValue = $value;
|
||||
try {
|
||||
$value = $this->buildEnum($originalValue, $cacheKeyInfo['enumType']);
|
||||
if (! is_array($originalValue)) {
|
||||
$value = $this->buildEnum($originalValue, $cacheKeyInfo['enumType']);
|
||||
} else {
|
||||
$value = [];
|
||||
foreach ($originalValue as $i => $currentValue) {
|
||||
$value[$i] = $this->buildEnum($currentValue, $cacheKeyInfo['enumType']);
|
||||
}
|
||||
}
|
||||
} catch (ValueError $e) {
|
||||
throw MappingException::invalidEnumValue(
|
||||
$entityName,
|
||||
$cacheKeyInfo['fieldName'],
|
||||
(string) $originalValue,
|
||||
(string) $currentValue,
|
||||
$cacheKeyInfo['enumType'],
|
||||
$e
|
||||
);
|
||||
|
||||
@@ -76,11 +76,11 @@ class LazyCriteriaCollection extends AbstractLazyCollection implements Selectabl
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Do an optimized search of an element
|
||||
*
|
||||
* @template TMaybeContained
|
||||
* @param mixed $element The element to search for.
|
||||
*
|
||||
* @return bool TRUE if the collection contains $element, FALSE otherwise.
|
||||
*/
|
||||
public function contains($element)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ final class AssociationOverride implements MappingAttribute
|
||||
* The fetching strategy to use for the association.
|
||||
*
|
||||
* @var string|null
|
||||
* @psalm-var 'LAZY'|'EAGER'|'EXTRA_LAZY'|null
|
||||
* @phpstan-var 'LAZY'|'EAGER'|'EXTRA_LAZY'|null
|
||||
* @readonly
|
||||
* @Enum({"LAZY", "EAGER", "EXTRA_LAZY"})
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ final class AssociationOverride implements MappingAttribute
|
||||
/**
|
||||
* @param JoinColumn|array<JoinColumn> $joinColumns
|
||||
* @param JoinColumn|array<JoinColumn> $inverseJoinColumns
|
||||
* @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY'|null $fetch
|
||||
* @phpstan-param 'LAZY'|'EAGER'|'EXTRA_LAZY'|null $fetch
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
|
||||
@@ -135,7 +135,7 @@ class ClassMetadataBuilder
|
||||
* Adds Index.
|
||||
*
|
||||
* @param string $name
|
||||
* @psalm-param list<string> $columns
|
||||
* @phpstan-param list<string> $columns
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -154,7 +154,7 @@ class ClassMetadataBuilder
|
||||
* Adds Unique Constraint.
|
||||
*
|
||||
* @param string $name
|
||||
* @psalm-param list<string> $columns
|
||||
* @phpstan-param list<string> $columns
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -172,6 +172,8 @@ class ClassMetadataBuilder
|
||||
/**
|
||||
* Adds named query.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $dqlQuery
|
||||
*
|
||||
@@ -216,11 +218,11 @@ class ClassMetadataBuilder
|
||||
/**
|
||||
* Sets the discriminator column details.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @param int $length
|
||||
* @psalm-param class-string<BackedEnum>|null $enumType
|
||||
* @psalm-param array<string, mixed> $options
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @param int $length
|
||||
* @param class-string<BackedEnum>|null $enumType
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -299,7 +301,7 @@ class ClassMetadataBuilder
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @psalm-param array<string, mixed> $mapping
|
||||
* @phpstan-param array<string, mixed> $mapping
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Doctrine\ORM\Mapping\Builder;
|
||||
class OneToManyAssociationBuilder extends AssociationBuilder
|
||||
{
|
||||
/**
|
||||
* @psalm-param array<string, string> $fieldNames
|
||||
* @phpstan-param array<string, string> $fieldNames
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
@@ -22,14 +22,14 @@ final class Cache implements MappingAttribute
|
||||
*
|
||||
* @Enum({"READ_ONLY", "NONSTRICT_READ_WRITE", "READ_WRITE"})
|
||||
* @var string
|
||||
* @psalm-var 'READ_ONLY'|'NONSTRICT_READ_WRITE'|'READ_WRITE'
|
||||
* @phpstan-var 'READ_ONLY'|'NONSTRICT_READ_WRITE'|'READ_WRITE'
|
||||
*/
|
||||
public $usage = 'READ_ONLY';
|
||||
|
||||
/** @var string|null Cache region name. */
|
||||
public $region;
|
||||
|
||||
/** @psalm-param 'READ_ONLY'|'NONSTRICT_READ_WRITE'|'READ_WRITE' $usage */
|
||||
/** @phpstan-param 'READ_ONLY'|'NONSTRICT_READ_WRITE'|'READ_WRITE' $usage */
|
||||
public function __construct(string $usage = 'READ_ONLY', ?string $region = null)
|
||||
{
|
||||
$this->usage = $usage;
|
||||
|
||||
@@ -19,13 +19,13 @@ final class ChangeTrackingPolicy implements MappingAttribute
|
||||
* The change tracking policy.
|
||||
*
|
||||
* @var string
|
||||
* @psalm-var 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY'
|
||||
* @phpstan-var 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY'
|
||||
* @readonly
|
||||
* @Enum({"DEFERRED_IMPLICIT", "DEFERRED_EXPLICIT", "NOTIFY"})
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/** @psalm-param 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY' $value */
|
||||
/** @phpstan-param 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY' $value */
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
@@ -12,7 +12,7 @@ use BackedEnum;
|
||||
* @todo remove or rename ClassMetadataInfo to ClassMetadata
|
||||
* @template-covariant T of object
|
||||
* @template-extends ClassMetadataInfo<T>
|
||||
* @psalm-type FieldMapping = array{
|
||||
* @phpstan-type FieldMapping = array{
|
||||
* type: string,
|
||||
* fieldName: string,
|
||||
* columnName: string,
|
||||
@@ -38,7 +38,7 @@ use BackedEnum;
|
||||
* version?: string,
|
||||
* default?: string|int,
|
||||
* }
|
||||
* @psalm-type JoinColumnData = array{
|
||||
* @phpstan-type JoinColumnData = array{
|
||||
* name: string,
|
||||
* referencedColumnName: string,
|
||||
* unique?: bool,
|
||||
@@ -48,7 +48,7 @@ use BackedEnum;
|
||||
* columnDefinition?: string,
|
||||
* nullable?: bool,
|
||||
* }
|
||||
* @psalm-type AssociationMapping = array{
|
||||
* @phpstan-type AssociationMapping = array{
|
||||
* cache?: array,
|
||||
* cascade: array<string>,
|
||||
* declared?: class-string,
|
||||
@@ -83,7 +83,7 @@ use BackedEnum;
|
||||
* type: int,
|
||||
* unique?: bool,
|
||||
* }
|
||||
* @psalm-type DiscriminatorColumnMapping = array{
|
||||
* @phpstan-type DiscriminatorColumnMapping = array{
|
||||
* name: string,
|
||||
* fieldName: string,
|
||||
* type: string,
|
||||
@@ -92,7 +92,7 @@ use BackedEnum;
|
||||
* enumType?: class-string<BackedEnum>|null,
|
||||
* options?: array<string, mixed>,
|
||||
* }
|
||||
* @psalm-type EmbeddedClassMapping = array{
|
||||
* @phpstan-type EmbeddedClassMapping = array{
|
||||
* class: class-string,
|
||||
* columnPrefix: string|null,
|
||||
* declaredField: string|null,
|
||||
@@ -109,7 +109,7 @@ class ClassMetadata extends ClassMetadataInfo
|
||||
* @see https://github.com/doctrine/orm/issues/8709
|
||||
*
|
||||
* @param string $entityName The name of the entity class the new instance is used for.
|
||||
* @psalm-param class-string<T> $entityName
|
||||
* @phpstan-param class-string<T> $entityName
|
||||
*/
|
||||
public function __construct($entityName, ?NamingStrategy $namingStrategy = null, ?TypedFieldMapper $typedFieldMapper = null)
|
||||
{
|
||||
|
||||
@@ -52,9 +52,9 @@ use function substr;
|
||||
* to a relational database.
|
||||
*
|
||||
* @extends AbstractClassMetadataFactory<ClassMetadata>
|
||||
* @psalm-import-type AssociationMapping from ClassMetadata
|
||||
* @psalm-import-type EmbeddedClassMapping from ClassMetadata
|
||||
* @psalm-import-type FieldMapping from ClassMetadata
|
||||
* @phpstan-import-type AssociationMapping from ClassMetadata
|
||||
* @phpstan-import-type EmbeddedClassMapping from ClassMetadata
|
||||
* @phpstan-import-type FieldMapping from ClassMetadata
|
||||
*/
|
||||
class ClassMetadataFactory extends AbstractClassMetadataFactory
|
||||
{
|
||||
@@ -420,7 +420,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
|
||||
/**
|
||||
* Gets the lower-case short name of a class.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @param class-string $className
|
||||
*/
|
||||
private function getShortName(string $className): string
|
||||
{
|
||||
@@ -558,6 +558,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
|
||||
{
|
||||
foreach ($parentClass->namedQueries as $name => $query) {
|
||||
if (! isset($subClass->namedQueries[$name])) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
$subClass->addNamedQuery(
|
||||
[
|
||||
'name' => $query['name'],
|
||||
@@ -575,6 +576,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
|
||||
{
|
||||
foreach ($parentClass->namedNativeQueries as $name => $query) {
|
||||
if (! isset($subClass->namedNativeQueries[$name])) {
|
||||
// @phpstan-ignore method.deprecated
|
||||
$subClass->addNamedNativeQuery(
|
||||
[
|
||||
'name' => $query['name'],
|
||||
@@ -637,7 +639,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
|
||||
$platform = $this->getTargetPlatform();
|
||||
|
||||
// Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour.
|
||||
/** @psalm-suppress UndefinedClass, InvalidClass */
|
||||
// @phpstan-ignore method.deprecated
|
||||
if (! $platform instanceof MySQLPlatform && ! $platform instanceof SqlitePlatform && ! $platform instanceof SQLServerPlatform && $platform->usesSequenceEmulatedIdentityColumns()) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/orm',
|
||||
@@ -654,8 +656,9 @@ DEPRECATION
|
||||
$columnName = $class->getSingleIdentifierColumnName();
|
||||
$quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
|
||||
$sequencePrefix = $class->getSequencePrefix($this->getTargetPlatform());
|
||||
$sequenceName = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName);
|
||||
$definition = [
|
||||
// @phpstan-ignore method.deprecated
|
||||
$sequenceName = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName);
|
||||
$definition = [
|
||||
'sequenceName' => $this->truncateSequenceName($sequenceName),
|
||||
];
|
||||
|
||||
@@ -711,6 +714,7 @@ DEPRECATION
|
||||
$class->setIdGenerator(new AssignedGenerator());
|
||||
break;
|
||||
|
||||
// @phpstan-ignore classConstant.deprecated
|
||||
case ClassMetadata::GENERATOR_TYPE_UUID:
|
||||
Deprecation::trigger(
|
||||
'doctrine/orm',
|
||||
@@ -718,6 +722,7 @@ DEPRECATION
|
||||
'Mapping for %s: the "UUID" id generator strategy is deprecated with no replacement',
|
||||
$class->name
|
||||
);
|
||||
// @phpstan-ignore new.deprecated
|
||||
$class->setIdGenerator(new UuidGenerator());
|
||||
break;
|
||||
|
||||
@@ -739,7 +744,7 @@ DEPRECATION
|
||||
}
|
||||
}
|
||||
|
||||
/** @psalm-return ClassMetadata::GENERATOR_TYPE_* */
|
||||
/** @phpstan-return ClassMetadata::GENERATOR_TYPE_* */
|
||||
private function determineIdGeneratorStrategy(AbstractPlatform $platform): int
|
||||
{
|
||||
assert($this->em !== null);
|
||||
@@ -825,7 +830,6 @@ DEPRECATION
|
||||
*/
|
||||
protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService)
|
||||
{
|
||||
assert($class instanceof ClassMetadata);
|
||||
$class->wakeupReflection($reflService);
|
||||
}
|
||||
|
||||
@@ -834,7 +838,6 @@ DEPRECATION
|
||||
*/
|
||||
protected function initializeReflection(ClassMetadataInterface $class, ReflectionService $reflService)
|
||||
{
|
||||
assert($class instanceof ClassMetadata);
|
||||
$class->initializeReflection($reflService);
|
||||
}
|
||||
|
||||
@@ -845,8 +848,10 @@ DEPRECATION
|
||||
*/
|
||||
protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
|
||||
{
|
||||
/** @psalm-var class-string */
|
||||
return $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
/** @var class-string $classString */
|
||||
$classString = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
|
||||
return $classString;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,11 +68,11 @@ use const PHP_VERSION_ID;
|
||||
*
|
||||
* @template-covariant T of object
|
||||
* @template-implements ClassMetadata<T>
|
||||
* @psalm-import-type AssociationMapping from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @psalm-import-type FieldMapping from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @psalm-import-type EmbeddedClassMapping from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @psalm-import-type JoinColumnData from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @psalm-import-type DiscriminatorColumnMapping from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @phpstan-import-type AssociationMapping from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @phpstan-import-type FieldMapping from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @phpstan-import-type EmbeddedClassMapping from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @phpstan-import-type JoinColumnData from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
* @phpstan-import-type DiscriminatorColumnMapping from \Doctrine\ORM\Mapping\ClassMetadata
|
||||
*/
|
||||
class ClassMetadataInfo implements ClassMetadata
|
||||
{
|
||||
@@ -257,8 +257,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* READ-ONLY: The name of the entity class.
|
||||
*
|
||||
* @var string
|
||||
* @psalm-var class-string<T>
|
||||
* @var class-string<T>
|
||||
*/
|
||||
public $name;
|
||||
|
||||
@@ -275,8 +274,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same
|
||||
* as {@link $name}.
|
||||
*
|
||||
* @var string
|
||||
* @psalm-var class-string
|
||||
* @var class-string
|
||||
*/
|
||||
public $rootEntityName;
|
||||
|
||||
@@ -300,8 +298,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* The name of the custom repository class used for the entity class.
|
||||
* (Optional).
|
||||
*
|
||||
* @var string|null
|
||||
* @psalm-var ?class-string<EntityRepository>
|
||||
* @var class-string<EntityRepository>|null
|
||||
*/
|
||||
public $customRepositoryClassName;
|
||||
|
||||
@@ -323,7 +320,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* READ-ONLY: The names of the parent <em>entity</em> classes (ancestors), starting with the
|
||||
* nearest one and ending with the root entity class.
|
||||
*
|
||||
* @psalm-var list<class-string>
|
||||
* @var list<class-string>
|
||||
*/
|
||||
public $parentClasses = [];
|
||||
|
||||
@@ -350,7 +347,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* For subclasses of such root entities, the list can be reused/passed downwards, it only needs to
|
||||
* be filtered accordingly (only keep remaining subclasses)
|
||||
*
|
||||
* @psalm-var list<class-string>
|
||||
* @var list<class-string>
|
||||
*/
|
||||
public $subClasses = [];
|
||||
|
||||
@@ -373,14 +370,14 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* declared in another parent <em>entity or mapped superclass</em>. The value is the FQCN
|
||||
* of the topmost non-transient class that contains mapping information for this field.
|
||||
*
|
||||
* @psalm-var array<string, EmbeddedClassMapping>
|
||||
* @phpstan-var array<string, EmbeddedClassMapping>
|
||||
*/
|
||||
public $embeddedClasses = [];
|
||||
|
||||
/**
|
||||
* READ-ONLY: The named queries allowed to be called directly from Repository.
|
||||
*
|
||||
* @psalm-var array<string, array<string, mixed>>
|
||||
* @phpstan-var array<string, array<string, mixed>>
|
||||
*/
|
||||
public $namedQueries = [];
|
||||
|
||||
@@ -397,7 +394,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @psalm-var array<string, array<string, mixed>>
|
||||
* @phpstan-var array<string, array<string, mixed>>
|
||||
*/
|
||||
public $namedNativeQueries = [];
|
||||
|
||||
@@ -413,7 +410,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @psalm-var array<string, array{
|
||||
* @phpstan-var array<string, array{
|
||||
* name: string,
|
||||
* entities: mixed[],
|
||||
* columns: mixed[]
|
||||
@@ -425,7 +422,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* READ-ONLY: The field names of all fields that are part of the identifier/primary key
|
||||
* of the mapped entity class.
|
||||
*
|
||||
* @psalm-var list<string>
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
public $identifier = [];
|
||||
|
||||
@@ -433,7 +430,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* READ-ONLY: The inheritance mapping type used by the class.
|
||||
*
|
||||
* @var int
|
||||
* @psalm-var self::INHERITANCE_TYPE_*
|
||||
* @phpstan-var self::INHERITANCE_TYPE_*
|
||||
*/
|
||||
public $inheritanceType = self::INHERITANCE_TYPE_NONE;
|
||||
|
||||
@@ -441,7 +438,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* READ-ONLY: The Id generator type used by the class.
|
||||
*
|
||||
* @var int
|
||||
* @psalm-var self::GENERATOR_TYPE_*
|
||||
* @phpstan-var self::GENERATOR_TYPE_*
|
||||
*/
|
||||
public $generatorType = self::GENERATOR_TYPE_NONE;
|
||||
|
||||
@@ -505,7 +502,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* of the topmost non-transient class that contains mapping information for this field.
|
||||
*
|
||||
* @var mixed[]
|
||||
* @psalm-var array<string, FieldMapping>
|
||||
* @phpstan-var array<string, FieldMapping>
|
||||
*/
|
||||
public $fieldMappings = [];
|
||||
|
||||
@@ -513,7 +510,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* READ-ONLY: An array of field names. Used to look up field names from column names.
|
||||
* Keys are column names and values are field names.
|
||||
*
|
||||
* @psalm-var array<string, string>
|
||||
* @phpstan-var array<string, string>
|
||||
*/
|
||||
public $fieldNames = [];
|
||||
|
||||
@@ -548,9 +545,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*
|
||||
* @see discriminatorColumn
|
||||
*
|
||||
* @var array<int|string, string>
|
||||
*
|
||||
* @psalm-var array<int|string, class-string>
|
||||
* @var array<int|string, class-string>
|
||||
*/
|
||||
public $discriminatorMap = [];
|
||||
|
||||
@@ -559,7 +554,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* inheritance mappings.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
* @psalm-var DiscriminatorColumnMapping|null
|
||||
* @phpstan-var DiscriminatorColumnMapping|null
|
||||
*/
|
||||
public $discriminatorColumn;
|
||||
|
||||
@@ -573,7 +568,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* uniqueConstraints => array
|
||||
*
|
||||
* @var mixed[]
|
||||
* @psalm-var array{
|
||||
* @phpstan-var array{
|
||||
* name: string,
|
||||
* schema?: string,
|
||||
* indexes?: array,
|
||||
@@ -587,14 +582,14 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* READ-ONLY: The registered lifecycle callbacks for entities of this class.
|
||||
*
|
||||
* @psalm-var array<string, list<string>>
|
||||
* @phpstan-var array<string, list<string>>
|
||||
*/
|
||||
public $lifecycleCallbacks = [];
|
||||
|
||||
/**
|
||||
* READ-ONLY: The registered entity listeners.
|
||||
*
|
||||
* @psalm-var array<string, list<array{class: class-string, method: string}>>
|
||||
* @phpstan-var array<string, list<array{class: class-string, method: string}>>
|
||||
*/
|
||||
public $entityListeners = [];
|
||||
|
||||
@@ -670,7 +665,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @psalm-var array<string, AssociationMapping>
|
||||
* @phpstan-var array<string, AssociationMapping>
|
||||
*/
|
||||
public $associationMappings = [];
|
||||
|
||||
@@ -721,7 +716,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* </code>
|
||||
*
|
||||
* @var array<string, mixed>|null
|
||||
* @psalm-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed}|null
|
||||
* @phpstan-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed}|null
|
||||
* @todo Merge with tableGeneratorDefinition into generic generatorDefinition
|
||||
*/
|
||||
public $sequenceGeneratorDefinition;
|
||||
@@ -811,8 +806,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Initializes a new ClassMetadata instance that will hold the object-relational mapping
|
||||
* metadata of the class with the given name.
|
||||
*
|
||||
* @param string $entityName The name of the entity class the new instance is used for.
|
||||
* @psalm-param class-string<T> $entityName
|
||||
* @param class-string<T> $entityName The name of the entity class the new instance is used for.
|
||||
*/
|
||||
public function __construct($entityName, ?NamingStrategy $namingStrategy = null, ?TypedFieldMapper $typedFieldMapper = null)
|
||||
{
|
||||
@@ -827,7 +821,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Gets the ReflectionProperties of the mapped class.
|
||||
*
|
||||
* @return ReflectionProperty[]|null[] An array of ReflectionProperty instances.
|
||||
* @psalm-return array<ReflectionProperty|null>
|
||||
* @phpstan-return array<ReflectionProperty|null>
|
||||
*/
|
||||
public function getReflectionProperties()
|
||||
{
|
||||
@@ -902,7 +896,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Populates the entity identifier of an entity.
|
||||
*
|
||||
* @param object $entity
|
||||
* @psalm-param array<string, mixed> $id
|
||||
* @phpstan-param array<string, mixed> $id
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -1254,7 +1248,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param array{usage?: mixed, region?: mixed} $cache
|
||||
* @phpstan-param array{usage?: mixed, region?: mixed} $cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -1273,7 +1267,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
|
||||
/**
|
||||
* @param string $fieldName
|
||||
* @psalm-param array{usage?: int, region?: string} $cache
|
||||
* @phpstan-param array{usage?: int, region?: string} $cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -1285,10 +1279,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* @param string $fieldName
|
||||
* @param array $cache
|
||||
* @psalm-param array{usage?: int|null, region?: string|null} $cache
|
||||
* @phpstan-param array{usage?: int|null, region?: string|null} $cache
|
||||
*
|
||||
* @return int[]|string[]
|
||||
* @psalm-return array{usage: int, region: string|null}
|
||||
* @phpstan-return array{usage: int, region: string|null}
|
||||
*/
|
||||
public function getAssociationCacheDefaults($fieldName, array $cache)
|
||||
{
|
||||
@@ -1405,6 +1399,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*/
|
||||
public function getColumnName($fieldName)
|
||||
{
|
||||
// @phpstan-ignore property.deprecated
|
||||
return $this->columnNames[$fieldName] ?? $fieldName;
|
||||
}
|
||||
|
||||
@@ -1415,7 +1410,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* @param string $fieldName The field name.
|
||||
*
|
||||
* @return mixed[] The field mapping.
|
||||
* @psalm-return FieldMapping
|
||||
* @phpstan-return FieldMapping
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
@@ -1437,7 +1432,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* the object model.
|
||||
*
|
||||
* @return mixed[] The mapping.
|
||||
* @psalm-return AssociationMapping
|
||||
* @phpstan-return AssociationMapping
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
@@ -1453,7 +1448,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Gets all association mappings of the class.
|
||||
*
|
||||
* @psalm-return array<string, AssociationMapping>
|
||||
* @phpstan-return array<string, AssociationMapping>
|
||||
*/
|
||||
public function getAssociationMappings()
|
||||
{
|
||||
@@ -1497,7 +1492,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Gets all named queries of the class.
|
||||
*
|
||||
* @return mixed[][]
|
||||
* @psalm-return array<string, array<string, mixed>>
|
||||
* @phpstan-return array<string, array<string, mixed>>
|
||||
*/
|
||||
public function getNamedQueries()
|
||||
{
|
||||
@@ -1512,7 +1507,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* @param string $queryName The query name.
|
||||
*
|
||||
* @return mixed[]
|
||||
* @psalm-return array<string, mixed>
|
||||
* @phpstan-return array<string, mixed>
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
@@ -1528,7 +1523,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Gets all named native queries of the class.
|
||||
*
|
||||
* @psalm-return array<string, array<string, mixed>>
|
||||
* @phpstan-return array<string, array<string, mixed>>
|
||||
*/
|
||||
public function getNamedNativeQueries()
|
||||
{
|
||||
@@ -1543,7 +1538,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* @param string $name The result set mapping name.
|
||||
*
|
||||
* @return mixed[]
|
||||
* @psalm-return array{name: string, entities: array, columns: array}
|
||||
* @phpstan-return array{name: string, entities: array, columns: array}
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
@@ -1560,7 +1555,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Gets all sql result set mappings of the class.
|
||||
*
|
||||
* @return mixed[]
|
||||
* @psalm-return array<string, array{name: string, entities: array, columns: array}>
|
||||
* @phpstan-return array<string, array{name: string, entities: array, columns: array}>
|
||||
*/
|
||||
public function getSqlResultSetMappings()
|
||||
{
|
||||
@@ -1621,7 +1616,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Validates & completes the given field mapping.
|
||||
*
|
||||
* @psalm-param array{
|
||||
* @phpstan-param array{
|
||||
* fieldName?: string,
|
||||
* columnName?: string,
|
||||
* id?: bool,
|
||||
@@ -1659,6 +1654,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
$mapping['quoted'] = true;
|
||||
}
|
||||
|
||||
// @phpstan-ignore property.deprecated
|
||||
$this->columnNames[$mapping['fieldName']] = $mapping['columnName'];
|
||||
|
||||
if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn && $this->discriminatorColumn['name'] === $mapping['columnName'])) {
|
||||
@@ -1683,6 +1679,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
}
|
||||
}
|
||||
|
||||
// @phpstan-ignore method.deprecated
|
||||
if (Type::hasType($mapping['type']) && Type::getType($mapping['type'])->canRequireSQLConversion()) {
|
||||
if (isset($mapping['id']) && $mapping['id'] === true) {
|
||||
throw MappingException::sqlConversionNotAllowedForIdentifiers($this->name, $mapping['fieldName'], $mapping['type']);
|
||||
@@ -1722,10 +1719,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Validates & completes the basic mapping information that is common to all
|
||||
* association mappings (one-to-one, many-ot-one, one-to-many, many-to-many).
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The mapping.
|
||||
* @phpstan-param array<string, mixed> $mapping The mapping.
|
||||
*
|
||||
* @return mixed[] The updated mapping.
|
||||
* @psalm-return AssociationMapping
|
||||
* @phpstan-return AssociationMapping
|
||||
*
|
||||
* @throws MappingException If something is wrong with the mapping.
|
||||
*/
|
||||
@@ -1852,10 +1849,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Validates & completes a one-to-one association mapping.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The mapping to validate & complete.
|
||||
* @phpstan-param array<string, mixed> $mapping The mapping to validate & complete.
|
||||
*
|
||||
* @return mixed[] The validated & completed mapping.
|
||||
* @psalm-return AssociationMapping
|
||||
* @phpstan-return AssociationMapping
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws MappingException
|
||||
@@ -1950,10 +1947,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Validates & completes a one-to-many association mapping.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The mapping to validate and complete.
|
||||
* @phpstan-param array<string, mixed> $mapping The mapping to validate and complete.
|
||||
*
|
||||
* @return mixed[] The validated and completed mapping.
|
||||
* @psalm-return AssociationMapping
|
||||
* @phpstan-return AssociationMapping
|
||||
*
|
||||
* @throws MappingException
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1978,10 +1975,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Validates & completes a many-to-many association mapping.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The mapping to validate & complete.
|
||||
* @phpstan-param array<string, mixed> $mapping The mapping to validate & complete.
|
||||
*
|
||||
* @return mixed[] The validated & completed mapping.
|
||||
* @psalm-return AssociationMapping
|
||||
* @phpstan-return AssociationMapping
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -2129,7 +2126,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Sets the mapped identifier/primary key fields of this class.
|
||||
* Mainly used by the ClassMetadataFactory to assign inherited identifiers.
|
||||
*
|
||||
* @psalm-param list<mixed> $identifier
|
||||
* @phpstan-param list<mixed> $identifier
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2158,10 +2155,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Gets an array containing all the column names.
|
||||
*
|
||||
* @psalm-param list<string>|null $fieldNames
|
||||
* @phpstan-param list<string>|null $fieldNames
|
||||
*
|
||||
* @return mixed[]
|
||||
* @psalm-return list<string>
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
public function getColumnNames(?array $fieldNames = null)
|
||||
{
|
||||
@@ -2175,7 +2172,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Returns an array with all the identifier column names.
|
||||
*
|
||||
* @psalm-return list<string>
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
public function getIdentifierColumnNames()
|
||||
{
|
||||
@@ -2204,7 +2201,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Sets the type of Id generator to use for the mapped class.
|
||||
*
|
||||
* @param int $generatorType
|
||||
* @psalm-param self::GENERATOR_TYPE_* $generatorType
|
||||
* @phpstan-param self::GENERATOR_TYPE_* $generatorType
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2285,7 +2282,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*
|
||||
* @return bool TRUE if the class uses the SEQUENCE generator, FALSE otherwise.
|
||||
*
|
||||
* @psalm-assert-if-true !null $this->sequenceGeneratorDefinition
|
||||
* @phpstan-assert-if-true !null $this->sequenceGeneratorDefinition
|
||||
*/
|
||||
public function isIdGeneratorSequence()
|
||||
{
|
||||
@@ -2406,7 +2403,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Sets the mapped subclasses of this class.
|
||||
*
|
||||
* @psalm-param list<string> $subclasses The names of all mapped subclasses.
|
||||
* @phpstan-param list<string> $subclasses The names of all mapped subclasses.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2423,7 +2420,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Assumes that the class names in the passed array are in the order:
|
||||
* directParent -> directParentParent -> directParentParentParent ... -> root.
|
||||
*
|
||||
* @psalm-param list<class-string> $classNames
|
||||
* @param list<class-string> $classNames
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2440,7 +2437,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Sets the inheritance type used by the class and its subclasses.
|
||||
*
|
||||
* @param int $type
|
||||
* @psalm-param self::INHERITANCE_TYPE_* $type
|
||||
* @phpstan-param self::INHERITANCE_TYPE_* $type
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2459,7 +2456,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Sets the association to override association mapping of property for an entity relationship.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @psalm-param array<string, mixed> $overrideMapping
|
||||
* @phpstan-param array<string, mixed> $overrideMapping
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2528,7 +2525,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Sets the override for a mapped field.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @psalm-param array<string, mixed> $overrideMapping
|
||||
* @phpstan-param array<string, mixed> $overrideMapping
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2576,6 +2573,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
|
||||
unset($this->fieldMappings[$fieldName]);
|
||||
unset($this->fieldNames[$mapping['columnName']]);
|
||||
// @phpstan-ignore property.deprecated
|
||||
unset($this->columnNames[$mapping['fieldName']]);
|
||||
|
||||
$overrideMapping = $this->validateAndCompleteFieldMapping($overrideMapping);
|
||||
@@ -2651,7 +2649,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*
|
||||
* If a key is omitted, the current value is kept.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $table The table description.
|
||||
* @phpstan-param array<string, mixed> $table The table description.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2699,6 +2697,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*/
|
||||
private function isInheritanceType(int $type): bool
|
||||
{
|
||||
// @phpstan-ignore classConstant.deprecated
|
||||
if ($type === self::INHERITANCE_TYPE_TABLE_PER_CLASS) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/orm',
|
||||
@@ -2710,13 +2709,14 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
return $type === self::INHERITANCE_TYPE_NONE ||
|
||||
$type === self::INHERITANCE_TYPE_SINGLE_TABLE ||
|
||||
$type === self::INHERITANCE_TYPE_JOINED ||
|
||||
// @phpstan-ignore classConstant.deprecated
|
||||
$type === self::INHERITANCE_TYPE_TABLE_PER_CLASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mapped field to the class.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The field mapping.
|
||||
* @phpstan-param array<string, mixed> $mapping The field mapping.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2739,7 +2739,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Adds an association mapping without completing/validating it.
|
||||
* This is mainly used to add inherited association mappings to derived classes.
|
||||
*
|
||||
* @psalm-param AssociationMapping $mapping
|
||||
* @phpstan-param AssociationMapping $mapping
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2759,15 +2759,16 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Adds a field mapping without completing/validating it.
|
||||
* This is mainly used to add inherited field mappings to derived classes.
|
||||
*
|
||||
* @psalm-param FieldMapping $fieldMapping
|
||||
* @phpstan-param FieldMapping $fieldMapping
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addInheritedFieldMapping(array $fieldMapping)
|
||||
{
|
||||
$this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping;
|
||||
$this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName'];
|
||||
$this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName'];
|
||||
// @phpstan-ignore property.deprecated
|
||||
$this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName'];
|
||||
$this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName'];
|
||||
|
||||
if (isset($fieldMapping['generated'])) {
|
||||
$this->requiresFetchAfterChange = true;
|
||||
@@ -2780,7 +2781,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @psalm-param array<string, mixed> $queryMapping
|
||||
* @phpstan-param array<string, mixed> $queryMapping
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2825,7 +2826,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @psalm-param array<string, mixed> $queryMapping
|
||||
* @phpstan-param array<string, mixed> $queryMapping
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2876,7 +2877,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* INTERNAL:
|
||||
* Adds a sql result set mapping to this class.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $resultMapping
|
||||
* @phpstan-param array<string, mixed> $resultMapping
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2950,7 +2951,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Adds a one-to-many mapping.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The mapping.
|
||||
* @phpstan-param array<string, mixed> $mapping The mapping.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2966,7 +2967,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Adds a many-to-one mapping.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The mapping.
|
||||
* @phpstan-param array<string, mixed> $mapping The mapping.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2983,7 +2984,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Adds a many-to-many mapping.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The mapping.
|
||||
* @phpstan-param array<string, mixed> $mapping The mapping.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -2999,7 +3000,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Stores the association mapping.
|
||||
*
|
||||
* @psalm-param AssociationMapping $assocMapping
|
||||
* @phpstan-param AssociationMapping $assocMapping
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -3017,8 +3018,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Registers a custom repository class for the entity class.
|
||||
*
|
||||
* @param string|null $repositoryClassName The class name of the custom mapper.
|
||||
* @psalm-param class-string<EntityRepository>|null $repositoryClassName
|
||||
* @param class-string<EntityRepository>|null $repositoryClassName The class name of the custom mapper.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -3063,7 +3063,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* @param string $event
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
public function getLifecycleCallbacks($event)
|
||||
{
|
||||
@@ -3101,7 +3101,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Sets the lifecycle callbacks for entities of this class.
|
||||
* Any previously registered callbacks are overwritten.
|
||||
*
|
||||
* @psalm-param array<string, list<string>> $callbacks
|
||||
* @phpstan-param array<string, list<string>> $callbacks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -3151,7 +3151,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* @see getDiscriminatorColumn()
|
||||
*
|
||||
* @param mixed[]|null $columnDef
|
||||
* @psalm-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null, enumType?: class-string<BackedEnum>|null, options?: array<string, mixed>}|null $columnDef
|
||||
* @phpstan-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null, enumType?: class-string<BackedEnum>|null, options?: array<string, mixed>}|null $columnDef
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -3186,7 +3186,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
* @psalm-return DiscriminatorColumnMapping
|
||||
* @phpstan-return DiscriminatorColumnMapping
|
||||
*/
|
||||
final public function getDiscriminatorColumn(): array
|
||||
{
|
||||
@@ -3415,7 +3415,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Sets definition.
|
||||
*
|
||||
* @psalm-param array<string, string|null> $definition
|
||||
* @phpstan-param array<string, string|null> $definition
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -3437,7 +3437,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @psalm-param array{sequenceName?: string, allocationSize?: int|string, initialValue?: int|string, quoted?: mixed} $definition
|
||||
* @phpstan-param array{sequenceName?: string, allocationSize?: int|string, initialValue?: int|string, quoted?: mixed} $definition
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -3472,7 +3472,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* Sets the version field mapping used for versioning. Sets the default
|
||||
* value to use depending on the column type.
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping The version field mapping array.
|
||||
* @phpstan-param array<string, mixed> $mapping The version field mapping array.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -3555,8 +3555,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*
|
||||
* @param string $assocName
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string
|
||||
* @return class-string
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -3585,7 +3584,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* @param AbstractPlatform $platform
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
public function getQuotedIdentifierColumnNames($platform)
|
||||
{
|
||||
@@ -3681,6 +3680,17 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
*/
|
||||
public function getAssociationMappedByTargetField($fieldName)
|
||||
{
|
||||
if (! $this->isAssociationInverseSide($fieldName)) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/orm',
|
||||
'https://github.com/doctrine/orm/pull/11309',
|
||||
'Calling %s with owning side field %s is deprecated and will no longer be supported in Doctrine ORM 3.0. Call %s::isAssociationInverseSide() to check first.',
|
||||
__METHOD__,
|
||||
$fieldName,
|
||||
self::class
|
||||
);
|
||||
}
|
||||
|
||||
return $this->associationMappings[$fieldName]['mappedBy'];
|
||||
}
|
||||
|
||||
@@ -3688,7 +3698,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* @param string $targetClass
|
||||
*
|
||||
* @return mixed[][]
|
||||
* @psalm-return array<string, array<string, mixed>>
|
||||
* @phpstan-return array<string, array<string, mixed>>
|
||||
*/
|
||||
public function getAssociationsByTargetClass($targetClass)
|
||||
{
|
||||
@@ -3707,7 +3717,6 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
* @param string|null $className
|
||||
*
|
||||
* @return string|null null if the input value is null
|
||||
* @psalm-return class-string|null
|
||||
*/
|
||||
public function fullyQualifiedClassName($className)
|
||||
{
|
||||
@@ -3739,7 +3748,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
/**
|
||||
* Map Embedded Class
|
||||
*
|
||||
* @psalm-param array<string, mixed> $mapping
|
||||
* @phpstan-param array<string, mixed> $mapping
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -3849,6 +3858,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
if ($schemaName) {
|
||||
$sequencePrefix = $schemaName . '.' . $tableName;
|
||||
|
||||
// @phpstan-ignore method.deprecated
|
||||
if (! $platform->supportsSchemas() && $platform->canEmulateSchemas()) {
|
||||
$sequencePrefix = $schemaName . '__' . $tableName;
|
||||
}
|
||||
@@ -3857,7 +3867,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
return $sequencePrefix;
|
||||
}
|
||||
|
||||
/** @psalm-param AssociationMapping $mapping */
|
||||
/** @phpstan-param AssociationMapping $mapping */
|
||||
private function assertMappingOrderBy(array $mapping): void
|
||||
{
|
||||
if (isset($mapping['orderBy']) && ! is_array($mapping['orderBy'])) {
|
||||
@@ -3865,7 +3875,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
}
|
||||
}
|
||||
|
||||
/** @psalm-param class-string $class */
|
||||
/** @param class-string $class */
|
||||
private function getAccessibleProperty(ReflectionService $reflService, string $class, string $field): ?ReflectionProperty
|
||||
{
|
||||
$reflectionProperty = $reflService->getAccessibleProperty($class, $field);
|
||||
@@ -3880,6 +3890,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
}
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID >= 80400 && $reflectionProperty !== null && count($reflectionProperty->getHooks()) > 0) {
|
||||
throw new LogicException('Doctrine ORM does not support property hooks in this version. Check https://github.com/doctrine/orm/issues/11624 for details of versions that support property hooks.');
|
||||
}
|
||||
|
||||
return $reflectionProperty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ final class Column implements MappingAttribute
|
||||
/**
|
||||
* @var string|null
|
||||
* @readonly
|
||||
* @psalm-var 'NEVER'|'INSERT'|'ALWAYS'|null
|
||||
* @phpstan-var 'NEVER'|'INSERT'|'ALWAYS'|null
|
||||
* @Enum({"NEVER", "INSERT", "ALWAYS"})
|
||||
*/
|
||||
public $generated;
|
||||
@@ -103,7 +103,7 @@ final class Column implements MappingAttribute
|
||||
/**
|
||||
* @param class-string<BackedEnum>|null $enumType
|
||||
* @param array<string,mixed> $options
|
||||
* @psalm-param 'NEVER'|'INSERT'|'ALWAYS'|null $generated
|
||||
* @phpstan-param 'NEVER'|'INSERT'|'ALWAYS'|null $generated
|
||||
*/
|
||||
public function __construct(
|
||||
?string $name = null,
|
||||
|
||||
@@ -17,7 +17,7 @@ use function trim;
|
||||
*/
|
||||
class DefaultEntityListenerResolver implements EntityListenerResolver
|
||||
{
|
||||
/** @psalm-var array<class-string, object> Map to store entity listener instances. */
|
||||
/** @var array<class-string, object> Map to store entity listener instances. */
|
||||
private $instances = [];
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,6 +42,7 @@ class DefaultQuoteStrategy implements QuoteStrategy
|
||||
if (! empty($class->table['schema'])) {
|
||||
$tableName = $class->table['schema'] . '.' . $class->table['name'];
|
||||
|
||||
// @phpstan-ignore method.deprecated
|
||||
if (! $platform->supportsSchemas() && $platform->canEmulateSchemas()) {
|
||||
$tableName = $class->table['schema'] . '__' . $class->table['name'];
|
||||
}
|
||||
@@ -90,7 +91,8 @@ class DefaultQuoteStrategy implements QuoteStrategy
|
||||
$schema = '';
|
||||
|
||||
if (isset($association['joinTable']['schema'])) {
|
||||
$schema = $association['joinTable']['schema'];
|
||||
$schema = $association['joinTable']['schema'];
|
||||
// @phpstan-ignore method.deprecated
|
||||
$schema .= ! $platform->supportsSchemas() && $platform->canEmulateSchemas() ? '__' : '.';
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user