Skip to content

Commit 52b9653

Browse files
authored
Merge pull request #10011 from greg0ire/cs10-on-3.0
Upgrade to doctrine/coding-standard 10.0 on 3.0.x
2 parents 28b5dfd + 4aa3c63 commit 52b9653

File tree

882 files changed

+4227
-7924
lines changed

Some content is hidden

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

882 files changed

+4227
-7924
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"require-dev": {
3939
"doctrine/annotations": "^1.13",
40-
"doctrine/coding-standard": "^9.0.2",
40+
"doctrine/coding-standard": "^10.0",
4141
"phpbench/phpbench": "^1.0",
4242
"phpstan/phpstan": "1.8.2",
4343
"phpunit/phpunit": "^9.5",

lib/Doctrine/ORM/AbstractQuery.php

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ abstract class AbstractQuery
8989
/**
9090
* The user-specified ResultSetMapping to use.
9191
*/
92-
protected ?ResultSetMapping $_resultSetMapping = null;
92+
protected ResultSetMapping|null $_resultSetMapping = null;
9393

9494
/**
9595
* The map of query hints.
@@ -105,14 +105,14 @@ abstract class AbstractQuery
105105
*/
106106
protected string|int $_hydrationMode = self::HYDRATE_OBJECT;
107107

108-
protected ?QueryCacheProfile $_queryCacheProfile = null;
108+
protected QueryCacheProfile|null $_queryCacheProfile = null;
109109

110110
/**
111111
* Whether or not expire the result cache.
112112
*/
113113
protected bool $_expireResultCache = false;
114114

115-
protected ?QueryCacheProfile $_hydrationCacheProfile = null;
115+
protected QueryCacheProfile|null $_hydrationCacheProfile = null;
116116

117117
/**
118118
* Whether to use second level cache, if available.
@@ -124,16 +124,16 @@ abstract class AbstractQuery
124124
/**
125125
* Second level cache region name.
126126
*/
127-
protected ?string $cacheRegion = null;
127+
protected string|null $cacheRegion = null;
128128

129129
/**
130130
* Second level query cache mode.
131131
*
132132
* @psalm-var Cache::MODE_*|null
133133
*/
134-
protected ?int $cacheMode = null;
134+
protected int|null $cacheMode = null;
135135

136-
protected ?CacheLogger $cacheLogger = null;
136+
protected CacheLogger|null $cacheLogger = null;
137137

138138
protected int $lifetime = 0;
139139

@@ -144,7 +144,7 @@ public function __construct(
144144
/**
145145
* The entity manager used by this query object.
146146
*/
147-
protected EntityManagerInterface $em
147+
protected EntityManagerInterface $em,
148148
) {
149149
$this->parameters = new ArrayCollection();
150150
$this->_hints = $em->getConfiguration()->getDefaultQueryHints();
@@ -169,17 +169,13 @@ public function setCacheable(bool $cacheable): static
169169
return $this;
170170
}
171171

172-
/**
173-
* @return bool TRUE if the query results are enabled for second level cache, FALSE otherwise.
174-
*/
172+
/** @return bool TRUE if the query results are enabled for second level cache, FALSE otherwise. */
175173
public function isCacheable(): bool
176174
{
177175
return $this->cacheable;
178176
}
179177

180-
/**
181-
* @return $this
182-
*/
178+
/** @return $this */
183179
public function setCacheRegion(string $cacheRegion): static
184180
{
185181
$this->cacheRegion = $cacheRegion;
@@ -192,14 +188,12 @@ public function setCacheRegion(string $cacheRegion): static
192188
*
193189
* @return string|null The cache region name; NULL indicates the default region.
194190
*/
195-
public function getCacheRegion(): ?string
191+
public function getCacheRegion(): string|null
196192
{
197193
return $this->cacheRegion;
198194
}
199195

200-
/**
201-
* @return bool TRUE if the query cache and second level cache are enabled, FALSE otherwise.
202-
*/
196+
/** @return bool TRUE if the query cache and second level cache are enabled, FALSE otherwise. */
203197
protected function isCacheEnabled(): bool
204198
{
205199
return $this->cacheable && $this->hasCache;
@@ -222,10 +216,8 @@ public function setLifetime(int $lifetime): static
222216
return $this;
223217
}
224218

225-
/**
226-
* @psalm-return Cache::MODE_*|null
227-
*/
228-
public function getCacheMode(): ?int
219+
/** @psalm-return Cache::MODE_*|null */
220+
public function getCacheMode(): int|null
229221
{
230222
return $this->cacheMode;
231223
}
@@ -288,7 +280,7 @@ public function getParameters(): ArrayCollection
288280
*
289281
* @return Parameter|null The value of the bound parameter, or NULL if not available.
290282
*/
291-
public function getParameter(int|string $key): ?Parameter
283+
public function getParameter(int|string $key): Parameter|null
292284
{
293285
$key = Parameter::normalizeName($key);
294286

@@ -450,7 +442,7 @@ public function setResultSetMapping(ResultSetMapping $rsm): static
450442
/**
451443
* Gets the ResultSetMapping used for hydration.
452444
*/
453-
protected function getResultSetMapping(): ?ResultSetMapping
445+
protected function getResultSetMapping(): ResultSetMapping|null
454446
{
455447
return $this->_resultSetMapping;
456448
}
@@ -486,7 +478,7 @@ private function translateNamespaces(ResultSetMapping $rsm): void
486478
* $query->setHydrationCacheProfile(new QueryCacheProfile());
487479
* $query->setHydrationCacheProfile(new QueryCacheProfile($lifetime, $resultKey));
488480
*/
489-
public function setHydrationCacheProfile(?QueryCacheProfile $profile): static
481+
public function setHydrationCacheProfile(QueryCacheProfile|null $profile): static
490482
{
491483
if ($profile === null) {
492484
$this->_hydrationCacheProfile = null;
@@ -506,7 +498,7 @@ public function setHydrationCacheProfile(?QueryCacheProfile $profile): static
506498
return $this;
507499
}
508500

509-
public function getHydrationCacheProfile(): ?QueryCacheProfile
501+
public function getHydrationCacheProfile(): QueryCacheProfile|null
510502
{
511503
return $this->_hydrationCacheProfile;
512504
}
@@ -519,7 +511,7 @@ public function getHydrationCacheProfile(): ?QueryCacheProfile
519511
*
520512
* @return $this
521513
*/
522-
public function setResultCacheProfile(?QueryCacheProfile $profile): static
514+
public function setResultCacheProfile(QueryCacheProfile|null $profile): static
523515
{
524516
if ($profile === null) {
525517
$this->_queryCacheProfile = null;
@@ -542,7 +534,7 @@ public function setResultCacheProfile(?QueryCacheProfile $profile): static
542534
/**
543535
* Defines a cache driver to be used for caching result sets and implicitly enables caching.
544536
*/
545-
public function setResultCache(?CacheItemPoolInterface $resultCache): static
537+
public function setResultCache(CacheItemPoolInterface|null $resultCache): static
546538
{
547539
if ($resultCache === null) {
548540
if ($this->_queryCacheProfile) {
@@ -568,7 +560,7 @@ public function setResultCache(?CacheItemPoolInterface $resultCache): static
568560
*
569561
* @return $this
570562
*/
571-
public function enableResultCache(?int $lifetime = null, ?string $resultCacheId = null): static
563+
public function enableResultCache(int|null $lifetime = null, string|null $resultCacheId = null): static
572564
{
573565
$this->setResultCacheLifetime($lifetime);
574566
$this->setResultCacheId($resultCacheId);
@@ -595,7 +587,7 @@ public function disableResultCache(): static
595587
*
596588
* @return $this
597589
*/
598-
public function setResultCacheLifetime(?int $lifetime): static
590+
public function setResultCacheLifetime(int|null $lifetime): static
599591
{
600592
$lifetime = (int) $lifetime;
601593

@@ -639,7 +631,7 @@ public function getExpireResultCache(): bool
639631
return $this->_expireResultCache;
640632
}
641633

642-
public function getQueryCacheProfile(): ?QueryCacheProfile
634+
public function getQueryCacheProfile(): QueryCacheProfile|null
643635
{
644636
return $this->_queryCacheProfile;
645637
}
@@ -854,7 +846,7 @@ public function getHints(): array
854846
*/
855847
public function toIterable(
856848
ArrayCollection|array $parameters = [],
857-
string|int|null $hydrationMode = null
849+
string|int|null $hydrationMode = null,
858850
): iterable {
859851
if ($hydrationMode !== null) {
860852
$this->setHydrationMode($hydrationMode);
@@ -886,7 +878,7 @@ public function toIterable(
886878
*/
887879
public function execute(
888880
ArrayCollection|array|null $parameters = null,
889-
string|int|null $hydrationMode = null
881+
string|int|null $hydrationMode = null,
890882
): mixed {
891883
if ($this->cacheable && $this->isCacheEnabled()) {
892884
return $this->executeUsingQueryCache($parameters, $hydrationMode);
@@ -903,7 +895,7 @@ public function execute(
903895
*/
904896
private function executeIgnoreQueryCache(
905897
ArrayCollection|array|null $parameters = null,
906-
string|int|null $hydrationMode = null
898+
string|int|null $hydrationMode = null,
907899
): mixed {
908900
if ($hydrationMode !== null) {
909901
$this->setHydrationMode($hydrationMode);
@@ -974,7 +966,7 @@ private function getHydrationCache(): CacheItemPoolInterface
974966
*/
975967
private function executeUsingQueryCache(
976968
ArrayCollection|array|null $parameters = null,
977-
string|int|null $hydrationMode = null
969+
string|int|null $hydrationMode = null,
978970
): mixed {
979971
$rsm = $this->getResultSetMapping();
980972
if ($rsm === null) {
@@ -986,7 +978,7 @@ private function executeUsingQueryCache(
986978
$this->getHash(),
987979
$this->lifetime,
988980
$this->cacheMode ?: Cache::MODE_NORMAL,
989-
$this->getTimestampKey()
981+
$this->getTimestampKey(),
990982
);
991983

992984
$result = $queryCache->get($queryKey, $rsm, $this->_hints);
@@ -1013,7 +1005,7 @@ private function executeUsingQueryCache(
10131005
return $result;
10141006
}
10151007

1016-
private function getTimestampKey(): ?TimestampCacheKey
1008+
private function getTimestampKey(): TimestampCacheKey|null
10171009
{
10181010
assert($this->_resultSetMapping !== null);
10191011
$entityName = reset($this->_resultSetMapping->aliasMap);
@@ -1060,7 +1052,7 @@ protected function getHydrationCacheId(): array
10601052
* If this is not explicitly set by the developer then a hash is automatically
10611053
* generated for you.
10621054
*/
1063-
public function setResultCacheId(?string $id): static
1055+
public function setResultCacheId(string|null $id): static
10641056
{
10651057
if (! $this->_queryCacheProfile) {
10661058
return $this->setResultCacheProfile(new QueryCacheProfile(0, $id));

lib/Doctrine/ORM/Cache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ interface Cache
3838
*/
3939
public const MODE_REFRESH = 4;
4040

41-
public function getEntityCacheRegion(string $className): ?Region;
41+
public function getEntityCacheRegion(string $className): Region|null;
4242

43-
public function getCollectionCacheRegion(string $className, string $association): ?Region;
43+
public function getCollectionCacheRegion(string $className, string $association): Region|null;
4444

4545
/**
4646
* Determine whether the cache contains data for the given entity "instance".
@@ -90,7 +90,7 @@ public function containsQuery(string $regionName): bool;
9090
/**
9191
* Evicts all cached query results under the given name, or default query cache if the region name is NULL.
9292
*/
93-
public function evictQueryRegion(?string $regionName = null): void;
93+
public function evictQueryRegion(string|null $regionName = null): void;
9494

9595
/**
9696
* Evict data from all query regions.
@@ -102,5 +102,5 @@ public function evictQueryRegions(): void;
102102
*
103103
* @param string|null $regionName Query cache region name, or default query cache if the region name is NULL.
104104
*/
105-
public function getQueryCache(?string $regionName = null): QueryCache;
105+
public function getQueryCache(string|null $regionName = null): QueryCache;
106106
}

lib/Doctrine/ORM/Cache/CacheConfiguration.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
*/
1212
class CacheConfiguration
1313
{
14-
private ?CacheFactory $cacheFactory = null;
15-
private ?RegionsConfiguration $regionsConfig = null;
16-
private ?CacheLogger $cacheLogger = null;
17-
private ?QueryCacheValidator $queryValidator = null;
14+
private CacheFactory|null $cacheFactory = null;
15+
private RegionsConfiguration|null $regionsConfig = null;
16+
private CacheLogger|null $cacheLogger = null;
17+
private QueryCacheValidator|null $queryValidator = null;
1818

19-
public function getCacheFactory(): ?CacheFactory
19+
public function getCacheFactory(): CacheFactory|null
2020
{
2121
return $this->cacheFactory;
2222
}
@@ -26,7 +26,7 @@ public function setCacheFactory(CacheFactory $factory): void
2626
$this->cacheFactory = $factory;
2727
}
2828

29-
public function getCacheLogger(): ?CacheLogger
29+
public function getCacheLogger(): CacheLogger|null
3030
{
3131
return $this->cacheLogger;
3232
}
@@ -49,7 +49,7 @@ public function setRegionsConfiguration(RegionsConfiguration $regionsConfig): vo
4949
public function getQueryValidator(): QueryCacheValidator
5050
{
5151
return $this->queryValidator ??= new TimestampQueryCacheValidator(
52-
$this->cacheFactory->getTimestampRegion()
52+
$this->cacheFactory->getTimestampRegion(),
5353
);
5454
}
5555

lib/Doctrine/ORM/Cache/CacheFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function buildCachedCollectionPersister(EntityManagerInterface $em, Colle
3232
/**
3333
* Build a query cache based on the given region name
3434
*/
35-
public function buildQueryCache(EntityManagerInterface $em, ?string $regionName = null): QueryCache;
35+
public function buildQueryCache(EntityManagerInterface $em, string|null $regionName = null): QueryCache;
3636

3737
/**
3838
* Build an entity hydrator

lib/Doctrine/ORM/Cache/CollectionCacheEntry.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ class CollectionCacheEntry implements CacheEntry
1717
*/
1818
public array $identifiers;
1919

20-
/**
21-
* @param CacheKey[] $identifiers List of entity identifiers hold by the collection
22-
*/
20+
/** @param CacheKey[] $identifiers List of entity identifiers hold by the collection */
2321
public function __construct(array $identifiers)
2422
{
2523
$this->identifiers = $identifiers;

lib/Doctrine/ORM/Cache/CollectionHydrator.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
*/
1414
interface CollectionHydrator
1515
{
16-
/**
17-
* @param mixed[]|Collection $collection The collection.
18-
*/
16+
/** @param mixed[]|Collection $collection The collection. */
1917
public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, array|Collection $collection): CollectionCacheEntry;
2018

21-
/**
22-
* @return mixed[]|null
23-
*/
24-
public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): ?array;
19+
/** @return mixed[]|null */
20+
public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): array|null;
2521
}

lib/Doctrine/ORM/Cache/ConcurrentRegion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface ConcurrentRegion extends Region
2222
*
2323
* @throws LockException Indicates a problem accessing the region.
2424
*/
25-
public function lock(CacheKey $key): ?Lock;
25+
public function lock(CacheKey $key): Lock|null;
2626

2727
/**
2828
* Attempts to read unlock the mapping for the given key.

0 commit comments

Comments
 (0)