Skip to content

Commit 4444a29

Browse files
committed
Merge branch '2.15.x' into 3.0.x
* 2.15.x: Ignore the cache dir of PHPUnit 10 (doctrine#10546) Make data providers static (doctrine#10545) Make data providers static (doctrine#10544) Bump dev tools (doctrine#10541) Mark SqlWalker methods as not deprecated (doctrine#10540) docs: consistency order for docblock in association mapping (doctrine#10534) Correct use of PHP attribute fix typo in faq.rst (doctrine#10526) fix: use executeStatement in SchemaTool (doctrine#10516) Write a test in a more specific way Put up a warning sign that mapping may not be inherited from transient classes (doctrine#10392) Avoid unnecessary information in query hints to improve query cache hit ratio
2 parents 9c2c117 + f36a8c8 commit 4444a29

16 files changed

+581
-537
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ vendor/
1515
/tests/Doctrine/Performance/history.db
1616
/.phpcs-cache
1717
composer.lock
18+
.phpunit.cache
1819
.phpunit.result.cache
1920
/*.phpunit.xml

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
"require-dev": {
3939
"doctrine/coding-standard": "^11.0",
4040
"phpbench/phpbench": "^1.0",
41-
"phpstan/phpstan": "1.9.14",
42-
"phpunit/phpunit": "^9.5.28",
41+
"phpstan/phpstan": "1.10.3",
42+
"phpunit/phpunit": "^9.6",
4343
"psr/log": "^1 || ^2 || ^3",
44-
"squizlabs/php_codesniffer": "3.7.1",
44+
"squizlabs/php_codesniffer": "3.7.2",
4545
"symfony/cache": "^5.4 || ^6.0",
4646
"symfony/var-exporter": "^5.4 || ^6.2",
47-
"vimeo/psalm": "5.6.0"
47+
"vimeo/psalm": "5.7.7"
4848
},
4949
"suggest": {
5050
"ext-dom": "Provides support for XSD validation for XML mapping files",

docs/en/cookbook/working-with-datetime.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ these comparisons are always made **BY REFERENCE**. That means the following cha
2121
#[Entity]
2222
class Article
2323
{
24-
#[Column(type='datetime')]
24+
#[Column(type: 'datetime')]
2525
private DateTime $updated;
2626
2727
public function setUpdated(): void

docs/en/reference/association-mapping.rst

+10
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,16 @@ Is essentially the same as following:
916916
#[JoinColumn(name: 'shipment_id', referencedColumnName: 'id', nullable: false)]
917917
private Shipment $shipment;
918918
919+
.. code-block:: annotation
920+
921+
<?php
922+
/**
923+
* One Product has One Shipment.
924+
* @OneToOne(targetEntity="Shipment")
925+
* @JoinColumn(name="shipment_id", referencedColumnName="id", nullable=false)
926+
*/
927+
private Shipment $shipment;
928+
919929
.. code-block:: xml
920930
921931
<doctrine-mapping>

docs/en/reference/faq.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ upon insert:
3838
3939
private string $algorithm = "sha1";
4040
/** @var self::STATUS_* */
41-
private int $status = self:STATUS_DISABLED;
41+
private int $status = self::STATUS_DISABLED;
4242
}
4343
4444
.

docs/en/reference/inheritance-mapping.rst

+13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ need not have an ``#[Id]`` property.
3232
For further support of inheritance, the single or
3333
joined table inheritance features have to be used.
3434

35+
.. warning::
36+
37+
At least when using attributes or annotations to specify your mapping,
38+
it _seems_ as if you could inherit from a base class that is neither
39+
an entity nor a mapped superclass, but has properties with mapping configuration
40+
on them that would also be used in the inheriting class.
41+
42+
This, however, is due to how the corresponding mapping
43+
drivers work and what the PHP reflection API reports for inherited fields.
44+
45+
Such a configuration is explicitly not supported. To give just one example,
46+
it will break for ``private`` properties.
47+
3548
.. note::
3649

3750
You may be tempted to use traits to mix mapped fields or relationships

lib/Doctrine/ORM/Tools/Pagination/Paginator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use function array_map;
2222
use function array_sum;
2323
use function assert;
24-
use function count;
2524
use function is_string;
2625

2726
/**
@@ -134,7 +133,7 @@ public function getIterator(): Traversable
134133
$ids = array_map('current', $foundIdRows);
135134

136135
$this->appendTreeWalker($whereInQuery, WhereInWalker::class);
137-
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, count($ids));
136+
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
138137
$whereInQuery->setFirstResult(0)->setMaxResults(null);
139138
$whereInQuery->setCacheable($this->query->isCacheable());
140139

lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
* The parameter namespace (dpid) is defined by
2929
* the PAGINATOR_ID_ALIAS
3030
*
31-
* The total number of parameters is retrieved from
32-
* the HINT_PAGINATOR_ID_COUNT query hint.
31+
* The HINT_PAGINATOR_HAS_IDS query hint indicates whether there are
32+
* any ids in the parameter at all.
3333
*/
3434
class WhereInWalker extends TreeWalkerAdapter
3535
{
3636
/**
3737
* ID Count hint name.
3838
*/
39-
public const HINT_PAGINATOR_ID_COUNT = 'doctrine.id.count';
39+
public const HINT_PAGINATOR_HAS_IDS = 'doctrine.paginator_has_ids';
4040

4141
/**
4242
* Primary key alias for query.
@@ -65,9 +65,9 @@ public function walkSelectStatement(SelectStatement $selectStatement): void
6565
$pathExpression = new PathExpression(PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $rootAlias, $identifierFieldName);
6666
$pathExpression->type = $pathType;
6767

68-
$count = $this->_getQuery()->getHint(self::HINT_PAGINATOR_ID_COUNT);
68+
$hasIds = $this->_getQuery()->getHint(self::HINT_PAGINATOR_HAS_IDS);
6969

70-
if ($count > 0) {
70+
if ($hasIds) {
7171
$arithmeticExpression = new ArithmeticExpression();
7272
$arithmeticExpression->simpleArithmeticExpression = new SimpleArithmeticExpression(
7373
[$pathExpression],

lib/Doctrine/ORM/Tools/SchemaTool.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function createSchema(array $classes): void
8383

8484
foreach ($createSchemaSql as $sql) {
8585
try {
86-
$conn->executeQuery($sql);
86+
$conn->executeStatement($sql);
8787
} catch (Throwable $e) {
8888
throw ToolsException::schemaToolFailure($sql, $e);
8989
}
@@ -811,7 +811,7 @@ public function dropSchema(array $classes): void
811811

812812
foreach ($dropSchemaSql as $sql) {
813813
try {
814-
$conn->executeQuery($sql);
814+
$conn->executeStatement($sql);
815815
} catch (Throwable) {
816816
// ignored
817817
}
@@ -827,7 +827,7 @@ public function dropDatabase(): void
827827
$conn = $this->em->getConnection();
828828

829829
foreach ($dropSchemaSql as $sql) {
830-
$conn->executeQuery($sql);
830+
$conn->executeStatement($sql);
831831
}
832832
}
833833

@@ -911,7 +911,7 @@ public function updateSchema(array $classes, bool $saveMode = false): void
911911
$conn = $this->em->getConnection();
912912

913913
foreach ($updateSchemaSql as $sql) {
914-
$conn->executeQuery($sql);
914+
$conn->executeStatement($sql);
915915
}
916916
}
917917

phpstan-baseline.neon

-5
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,6 @@ parameters:
295295
count: 1
296296
path: lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php
297297

298-
-
299-
message: "#^Result of \\|\\| is always true\\.$#"
300-
count: 1
301-
path: lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php
302-
303298
-
304299
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
305300
count: 1

0 commit comments

Comments
 (0)