@@ -89,7 +89,7 @@ abstract class AbstractQuery
89
89
/**
90
90
* The user-specified ResultSetMapping to use.
91
91
*/
92
- protected ? ResultSetMapping $ _resultSetMapping = null ;
92
+ protected ResultSetMapping | null $ _resultSetMapping = null ;
93
93
94
94
/**
95
95
* The map of query hints.
@@ -105,14 +105,14 @@ abstract class AbstractQuery
105
105
*/
106
106
protected string |int $ _hydrationMode = self ::HYDRATE_OBJECT ;
107
107
108
- protected ? QueryCacheProfile $ _queryCacheProfile = null ;
108
+ protected QueryCacheProfile | null $ _queryCacheProfile = null ;
109
109
110
110
/**
111
111
* Whether or not expire the result cache.
112
112
*/
113
113
protected bool $ _expireResultCache = false ;
114
114
115
- protected ? QueryCacheProfile $ _hydrationCacheProfile = null ;
115
+ protected QueryCacheProfile | null $ _hydrationCacheProfile = null ;
116
116
117
117
/**
118
118
* Whether to use second level cache, if available.
@@ -124,16 +124,16 @@ abstract class AbstractQuery
124
124
/**
125
125
* Second level cache region name.
126
126
*/
127
- protected ? string $ cacheRegion = null ;
127
+ protected string | null $ cacheRegion = null ;
128
128
129
129
/**
130
130
* Second level query cache mode.
131
131
*
132
132
* @psalm-var Cache::MODE_*|null
133
133
*/
134
- protected ? int $ cacheMode = null ;
134
+ protected int | null $ cacheMode = null ;
135
135
136
- protected ? CacheLogger $ cacheLogger = null ;
136
+ protected CacheLogger | null $ cacheLogger = null ;
137
137
138
138
protected int $ lifetime = 0 ;
139
139
@@ -144,7 +144,7 @@ public function __construct(
144
144
/**
145
145
* The entity manager used by this query object.
146
146
*/
147
- protected EntityManagerInterface $ em
147
+ protected EntityManagerInterface $ em,
148
148
) {
149
149
$ this ->parameters = new ArrayCollection ();
150
150
$ this ->_hints = $ em ->getConfiguration ()->getDefaultQueryHints ();
@@ -169,17 +169,13 @@ public function setCacheable(bool $cacheable): static
169
169
return $ this ;
170
170
}
171
171
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. */
175
173
public function isCacheable (): bool
176
174
{
177
175
return $ this ->cacheable ;
178
176
}
179
177
180
- /**
181
- * @return $this
182
- */
178
+ /** @return $this */
183
179
public function setCacheRegion (string $ cacheRegion ): static
184
180
{
185
181
$ this ->cacheRegion = $ cacheRegion ;
@@ -192,14 +188,12 @@ public function setCacheRegion(string $cacheRegion): static
192
188
*
193
189
* @return string|null The cache region name; NULL indicates the default region.
194
190
*/
195
- public function getCacheRegion (): ? string
191
+ public function getCacheRegion (): string | null
196
192
{
197
193
return $ this ->cacheRegion ;
198
194
}
199
195
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. */
203
197
protected function isCacheEnabled (): bool
204
198
{
205
199
return $ this ->cacheable && $ this ->hasCache ;
@@ -222,10 +216,8 @@ public function setLifetime(int $lifetime): static
222
216
return $ this ;
223
217
}
224
218
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
229
221
{
230
222
return $ this ->cacheMode ;
231
223
}
@@ -288,7 +280,7 @@ public function getParameters(): ArrayCollection
288
280
*
289
281
* @return Parameter|null The value of the bound parameter, or NULL if not available.
290
282
*/
291
- public function getParameter (int |string $ key ): ? Parameter
283
+ public function getParameter (int |string $ key ): Parameter | null
292
284
{
293
285
$ key = Parameter::normalizeName ($ key );
294
286
@@ -450,7 +442,7 @@ public function setResultSetMapping(ResultSetMapping $rsm): static
450
442
/**
451
443
* Gets the ResultSetMapping used for hydration.
452
444
*/
453
- protected function getResultSetMapping (): ? ResultSetMapping
445
+ protected function getResultSetMapping (): ResultSetMapping | null
454
446
{
455
447
return $ this ->_resultSetMapping ;
456
448
}
@@ -486,7 +478,7 @@ private function translateNamespaces(ResultSetMapping $rsm): void
486
478
* $query->setHydrationCacheProfile(new QueryCacheProfile());
487
479
* $query->setHydrationCacheProfile(new QueryCacheProfile($lifetime, $resultKey));
488
480
*/
489
- public function setHydrationCacheProfile (? QueryCacheProfile $ profile ): static
481
+ public function setHydrationCacheProfile (QueryCacheProfile | null $ profile ): static
490
482
{
491
483
if ($ profile === null ) {
492
484
$ this ->_hydrationCacheProfile = null ;
@@ -506,7 +498,7 @@ public function setHydrationCacheProfile(?QueryCacheProfile $profile): static
506
498
return $ this ;
507
499
}
508
500
509
- public function getHydrationCacheProfile (): ? QueryCacheProfile
501
+ public function getHydrationCacheProfile (): QueryCacheProfile | null
510
502
{
511
503
return $ this ->_hydrationCacheProfile ;
512
504
}
@@ -519,7 +511,7 @@ public function getHydrationCacheProfile(): ?QueryCacheProfile
519
511
*
520
512
* @return $this
521
513
*/
522
- public function setResultCacheProfile (? QueryCacheProfile $ profile ): static
514
+ public function setResultCacheProfile (QueryCacheProfile | null $ profile ): static
523
515
{
524
516
if ($ profile === null ) {
525
517
$ this ->_queryCacheProfile = null ;
@@ -542,7 +534,7 @@ public function setResultCacheProfile(?QueryCacheProfile $profile): static
542
534
/**
543
535
* Defines a cache driver to be used for caching result sets and implicitly enables caching.
544
536
*/
545
- public function setResultCache (? CacheItemPoolInterface $ resultCache ): static
537
+ public function setResultCache (CacheItemPoolInterface | null $ resultCache ): static
546
538
{
547
539
if ($ resultCache === null ) {
548
540
if ($ this ->_queryCacheProfile ) {
@@ -568,7 +560,7 @@ public function setResultCache(?CacheItemPoolInterface $resultCache): static
568
560
*
569
561
* @return $this
570
562
*/
571
- public function enableResultCache (? int $ lifetime = null , ? string $ resultCacheId = null ): static
563
+ public function enableResultCache (int | null $ lifetime = null , string | null $ resultCacheId = null ): static
572
564
{
573
565
$ this ->setResultCacheLifetime ($ lifetime );
574
566
$ this ->setResultCacheId ($ resultCacheId );
@@ -595,7 +587,7 @@ public function disableResultCache(): static
595
587
*
596
588
* @return $this
597
589
*/
598
- public function setResultCacheLifetime (? int $ lifetime ): static
590
+ public function setResultCacheLifetime (int | null $ lifetime ): static
599
591
{
600
592
$ lifetime = (int ) $ lifetime ;
601
593
@@ -639,7 +631,7 @@ public function getExpireResultCache(): bool
639
631
return $ this ->_expireResultCache ;
640
632
}
641
633
642
- public function getQueryCacheProfile (): ? QueryCacheProfile
634
+ public function getQueryCacheProfile (): QueryCacheProfile | null
643
635
{
644
636
return $ this ->_queryCacheProfile ;
645
637
}
@@ -854,7 +846,7 @@ public function getHints(): array
854
846
*/
855
847
public function toIterable (
856
848
ArrayCollection |array $ parameters = [],
857
- string |int |null $ hydrationMode = null
849
+ string |int |null $ hydrationMode = null ,
858
850
): iterable {
859
851
if ($ hydrationMode !== null ) {
860
852
$ this ->setHydrationMode ($ hydrationMode );
@@ -886,7 +878,7 @@ public function toIterable(
886
878
*/
887
879
public function execute (
888
880
ArrayCollection |array |null $ parameters = null ,
889
- string |int |null $ hydrationMode = null
881
+ string |int |null $ hydrationMode = null ,
890
882
): mixed {
891
883
if ($ this ->cacheable && $ this ->isCacheEnabled ()) {
892
884
return $ this ->executeUsingQueryCache ($ parameters , $ hydrationMode );
@@ -903,7 +895,7 @@ public function execute(
903
895
*/
904
896
private function executeIgnoreQueryCache (
905
897
ArrayCollection |array |null $ parameters = null ,
906
- string |int |null $ hydrationMode = null
898
+ string |int |null $ hydrationMode = null ,
907
899
): mixed {
908
900
if ($ hydrationMode !== null ) {
909
901
$ this ->setHydrationMode ($ hydrationMode );
@@ -974,7 +966,7 @@ private function getHydrationCache(): CacheItemPoolInterface
974
966
*/
975
967
private function executeUsingQueryCache (
976
968
ArrayCollection |array |null $ parameters = null ,
977
- string |int |null $ hydrationMode = null
969
+ string |int |null $ hydrationMode = null ,
978
970
): mixed {
979
971
$ rsm = $ this ->getResultSetMapping ();
980
972
if ($ rsm === null ) {
@@ -986,7 +978,7 @@ private function executeUsingQueryCache(
986
978
$ this ->getHash (),
987
979
$ this ->lifetime ,
988
980
$ this ->cacheMode ?: Cache::MODE_NORMAL ,
989
- $ this ->getTimestampKey ()
981
+ $ this ->getTimestampKey (),
990
982
);
991
983
992
984
$ result = $ queryCache ->get ($ queryKey , $ rsm , $ this ->_hints );
@@ -1013,7 +1005,7 @@ private function executeUsingQueryCache(
1013
1005
return $ result ;
1014
1006
}
1015
1007
1016
- private function getTimestampKey (): ? TimestampCacheKey
1008
+ private function getTimestampKey (): TimestampCacheKey | null
1017
1009
{
1018
1010
assert ($ this ->_resultSetMapping !== null );
1019
1011
$ entityName = reset ($ this ->_resultSetMapping ->aliasMap );
@@ -1060,7 +1052,7 @@ protected function getHydrationCacheId(): array
1060
1052
* If this is not explicitly set by the developer then a hash is automatically
1061
1053
* generated for you.
1062
1054
*/
1063
- public function setResultCacheId (? string $ id ): static
1055
+ public function setResultCacheId (string | null $ id ): static
1064
1056
{
1065
1057
if (! $ this ->_queryCacheProfile ) {
1066
1058
return $ this ->setResultCacheProfile (new QueryCacheProfile (0 , $ id ));
0 commit comments