Skip to content

Commit 09caeb2

Browse files
committed
Stop relying on underscores to indicate property visibility
It conflicts with our coding standard.
1 parent 7f9827d commit 09caeb2

16 files changed

+268
-282
lines changed

lib/Doctrine/ORM/AbstractQuery.php

+49-49
Original file line numberDiff line numberDiff line change
@@ -89,30 +89,30 @@ abstract class AbstractQuery
8989
/**
9090
* The user-specified ResultSetMapping to use.
9191
*/
92-
protected ResultSetMapping|null $_resultSetMapping = null;
92+
protected ResultSetMapping|null $resultSetMapping = null;
9393

9494
/**
9595
* The map of query hints.
9696
*
9797
* @psalm-var array<string, mixed>
9898
*/
99-
protected array $_hints = [];
99+
protected array $hints = [];
100100

101101
/**
102102
* The hydration mode.
103103
*
104104
* @psalm-var string|AbstractQuery::HYDRATE_*
105105
*/
106-
protected string|int $_hydrationMode = self::HYDRATE_OBJECT;
106+
protected string|int $hydrationMode = self::HYDRATE_OBJECT;
107107

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

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

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

117117
/**
118118
* Whether to use second level cache, if available.
@@ -147,7 +147,7 @@ public function __construct(
147147
protected EntityManagerInterface $em,
148148
) {
149149
$this->parameters = new ArrayCollection();
150-
$this->_hints = $em->getConfiguration()->getDefaultQueryHints();
150+
$this->hints = $em->getConfiguration()->getDefaultQueryHints();
151151
$this->hasCache = $this->em->getConfiguration()->isSecondLevelCacheEnabled();
152152

153153
if ($this->hasCache) {
@@ -260,7 +260,7 @@ public function free(): void
260260
{
261261
$this->parameters = new ArrayCollection();
262262

263-
$this->_hints = $this->em->getConfiguration()->getDefaultQueryHints();
263+
$this->hints = $this->em->getConfiguration()->getDefaultQueryHints();
264264
}
265265

266266
/**
@@ -434,7 +434,7 @@ private function processArrayParameterValue(array $value): array
434434
public function setResultSetMapping(ResultSetMapping $rsm): static
435435
{
436436
$this->translateNamespaces($rsm);
437-
$this->_resultSetMapping = $rsm;
437+
$this->resultSetMapping = $rsm;
438438

439439
return $this;
440440
}
@@ -444,7 +444,7 @@ public function setResultSetMapping(ResultSetMapping $rsm): static
444444
*/
445445
protected function getResultSetMapping(): ResultSetMapping|null
446446
{
447-
return $this->_resultSetMapping;
447+
return $this->resultSetMapping;
448448
}
449449

450450
/**
@@ -481,7 +481,7 @@ private function translateNamespaces(ResultSetMapping $rsm): void
481481
public function setHydrationCacheProfile(QueryCacheProfile|null $profile): static
482482
{
483483
if ($profile === null) {
484-
$this->_hydrationCacheProfile = null;
484+
$this->hydrationCacheProfile = null;
485485

486486
return $this;
487487
}
@@ -493,14 +493,14 @@ public function setHydrationCacheProfile(QueryCacheProfile|null $profile): stati
493493
}
494494
}
495495

496-
$this->_hydrationCacheProfile = $profile;
496+
$this->hydrationCacheProfile = $profile;
497497

498498
return $this;
499499
}
500500

501501
public function getHydrationCacheProfile(): QueryCacheProfile|null
502502
{
503-
return $this->_hydrationCacheProfile;
503+
return $this->hydrationCacheProfile;
504504
}
505505

506506
/**
@@ -514,7 +514,7 @@ public function getHydrationCacheProfile(): QueryCacheProfile|null
514514
public function setResultCacheProfile(QueryCacheProfile|null $profile): static
515515
{
516516
if ($profile === null) {
517-
$this->_queryCacheProfile = null;
517+
$this->queryCacheProfile = null;
518518

519519
return $this;
520520
}
@@ -526,7 +526,7 @@ public function setResultCacheProfile(QueryCacheProfile|null $profile): static
526526
}
527527
}
528528

529-
$this->_queryCacheProfile = $profile;
529+
$this->queryCacheProfile = $profile;
530530

531531
return $this;
532532
}
@@ -537,15 +537,15 @@ public function setResultCacheProfile(QueryCacheProfile|null $profile): static
537537
public function setResultCache(CacheItemPoolInterface|null $resultCache): static
538538
{
539539
if ($resultCache === null) {
540-
if ($this->_queryCacheProfile) {
541-
$this->_queryCacheProfile = new QueryCacheProfile($this->_queryCacheProfile->getLifetime(), $this->_queryCacheProfile->getCacheKey());
540+
if ($this->queryCacheProfile) {
541+
$this->queryCacheProfile = new QueryCacheProfile($this->queryCacheProfile->getLifetime(), $this->queryCacheProfile->getCacheKey());
542542
}
543543

544544
return $this;
545545
}
546546

547-
$this->_queryCacheProfile = $this->_queryCacheProfile
548-
? $this->_queryCacheProfile->setResultCache($resultCache)
547+
$this->queryCacheProfile = $this->queryCacheProfile
548+
? $this->queryCacheProfile->setResultCache($resultCache)
549549
: new QueryCacheProfile(0, null, $resultCache);
550550

551551
return $this;
@@ -575,7 +575,7 @@ public function enableResultCache(int|null $lifetime = null, string|null $result
575575
*/
576576
public function disableResultCache(): static
577577
{
578-
$this->_queryCacheProfile = null;
578+
$this->queryCacheProfile = null;
579579

580580
return $this;
581581
}
@@ -591,20 +591,20 @@ public function setResultCacheLifetime(int|null $lifetime): static
591591
{
592592
$lifetime = (int) $lifetime;
593593

594-
if ($this->_queryCacheProfile) {
595-
$this->_queryCacheProfile = $this->_queryCacheProfile->setLifetime($lifetime);
594+
if ($this->queryCacheProfile) {
595+
$this->queryCacheProfile = $this->queryCacheProfile->setLifetime($lifetime);
596596

597597
return $this;
598598
}
599599

600-
$this->_queryCacheProfile = new QueryCacheProfile($lifetime);
600+
$this->queryCacheProfile = new QueryCacheProfile($lifetime);
601601

602602
$cache = $this->em->getConfiguration()->getResultCache();
603603
if (! $cache) {
604604
return $this;
605605
}
606606

607-
$this->_queryCacheProfile = $this->_queryCacheProfile->setResultCache($cache);
607+
$this->queryCacheProfile = $this->queryCacheProfile->setResultCache($cache);
608608

609609
return $this;
610610
}
@@ -618,7 +618,7 @@ public function setResultCacheLifetime(int|null $lifetime): static
618618
*/
619619
public function expireResultCache(bool $expire = true): static
620620
{
621-
$this->_expireResultCache = $expire;
621+
$this->expireResultCache = $expire;
622622

623623
return $this;
624624
}
@@ -628,12 +628,12 @@ public function expireResultCache(bool $expire = true): static
628628
*/
629629
public function getExpireResultCache(): bool
630630
{
631-
return $this->_expireResultCache;
631+
return $this->expireResultCache;
632632
}
633633

634634
public function getQueryCacheProfile(): QueryCacheProfile|null
635635
{
636-
return $this->_queryCacheProfile;
636+
return $this->queryCacheProfile;
637637
}
638638

639639
/**
@@ -644,7 +644,7 @@ public function getQueryCacheProfile(): QueryCacheProfile|null
644644
*/
645645
public function setFetchMode(string $class, string $assocName, int $fetchMode): static
646646
{
647-
$this->_hints['fetchMode'][$class][$assocName] = $fetchMode;
647+
$this->hints['fetchMode'][$class][$assocName] = $fetchMode;
648648

649649
return $this;
650650
}
@@ -660,7 +660,7 @@ public function setFetchMode(string $class, string $assocName, int $fetchMode):
660660
*/
661661
public function setHydrationMode(string|int $hydrationMode): static
662662
{
663-
$this->_hydrationMode = $hydrationMode;
663+
$this->hydrationMode = $hydrationMode;
664664

665665
return $this;
666666
}
@@ -672,7 +672,7 @@ public function setHydrationMode(string|int $hydrationMode): static
672672
*/
673673
public function getHydrationMode(): string|int
674674
{
675-
return $this->_hydrationMode;
675+
return $this->hydrationMode;
676676
}
677677

678678
/**
@@ -738,7 +738,7 @@ public function getOneOrNullResult(string|int|null $hydrationMode = null): mixed
738738
return null;
739739
}
740740

741-
if ($this->_hydrationMode !== self::HYDRATE_SINGLE_SCALAR && ! $result) {
741+
if ($this->hydrationMode !== self::HYDRATE_SINGLE_SCALAR && ! $result) {
742742
return null;
743743
}
744744

@@ -770,7 +770,7 @@ public function getSingleResult(string|int|null $hydrationMode = null): mixed
770770
{
771771
$result = $this->execute(null, $hydrationMode);
772772

773-
if ($this->_hydrationMode !== self::HYDRATE_SINGLE_SCALAR && ! $result) {
773+
if ($this->hydrationMode !== self::HYDRATE_SINGLE_SCALAR && ! $result) {
774774
throw new NoResultException();
775775
}
776776

@@ -805,7 +805,7 @@ public function getSingleScalarResult(): mixed
805805
*/
806806
public function setHint(string $name, mixed $value): static
807807
{
808-
$this->_hints[$name] = $value;
808+
$this->hints[$name] = $value;
809809

810810
return $this;
811811
}
@@ -817,12 +817,12 @@ public function setHint(string $name, mixed $value): static
817817
*/
818818
public function getHint(string $name): mixed
819819
{
820-
return $this->_hints[$name] ?? false;
820+
return $this->hints[$name] ?? false;
821821
}
822822

823823
public function hasHint(string $name): bool
824824
{
825-
return isset($this->_hints[$name]);
825+
return isset($this->hints[$name]);
826826
}
827827

828828
/**
@@ -832,7 +832,7 @@ public function hasHint(string $name): bool
832832
*/
833833
public function getHints(): array
834834
{
835-
return $this->_hints;
835+
return $this->hints;
836836
}
837837

838838
/**
@@ -867,7 +867,7 @@ public function toIterable(
867867

868868
$stmt = $this->_doExecute();
869869

870-
return $this->em->newHydrator($this->_hydrationMode)->toIterable($stmt, $rsm, $this->_hints);
870+
return $this->em->newHydrator($this->hydrationMode)->toIterable($stmt, $rsm, $this->hints);
871871
}
872872

873873
/**
@@ -908,7 +908,7 @@ private function executeIgnoreQueryCache(
908908
$setCacheEntry = static function ($data): void {
909909
};
910910

911-
if ($this->_hydrationCacheProfile !== null) {
911+
if ($this->hydrationCacheProfile !== null) {
912912
[$cacheKey, $realCacheKey] = $this->getHydrationCacheId();
913913

914914
$cache = $this->getHydrationCache();
@@ -941,7 +941,7 @@ private function executeIgnoreQueryCache(
941941
throw new LogicException('Uninitialized result set mapping.');
942942
}
943943

944-
$data = $this->em->newHydrator($this->_hydrationMode)->hydrateAll($stmt, $rsm, $this->_hints);
944+
$data = $this->em->newHydrator($this->hydrationMode)->hydrateAll($stmt, $rsm, $this->hints);
945945

946946
$setCacheEntry($data);
947947

@@ -950,9 +950,9 @@ private function executeIgnoreQueryCache(
950950

951951
private function getHydrationCache(): CacheItemPoolInterface
952952
{
953-
assert($this->_hydrationCacheProfile !== null);
953+
assert($this->hydrationCacheProfile !== null);
954954

955-
$cache = $this->_hydrationCacheProfile->getResultCache();
955+
$cache = $this->hydrationCacheProfile->getResultCache();
956956
assert($cache !== null);
957957

958958
return $cache;
@@ -981,7 +981,7 @@ private function executeUsingQueryCache(
981981
$this->getTimestampKey(),
982982
);
983983

984-
$result = $queryCache->get($queryKey, $rsm, $this->_hints);
984+
$result = $queryCache->get($queryKey, $rsm, $this->hints);
985985

986986
if ($result !== null) {
987987
if ($this->cacheLogger) {
@@ -992,7 +992,7 @@ private function executeUsingQueryCache(
992992
}
993993

994994
$result = $this->executeIgnoreQueryCache($parameters, $hydrationMode);
995-
$cached = $queryCache->put($queryKey, $rsm, $result, $this->_hints);
995+
$cached = $queryCache->put($queryKey, $rsm, $result, $this->hints);
996996

997997
if ($this->cacheLogger) {
998998
$this->cacheLogger->queryCacheMiss($queryCache->getRegion()->getName(), $queryKey);
@@ -1007,8 +1007,8 @@ private function executeUsingQueryCache(
10071007

10081008
private function getTimestampKey(): TimestampCacheKey|null
10091009
{
1010-
assert($this->_resultSetMapping !== null);
1011-
$entityName = reset($this->_resultSetMapping->aliasMap);
1010+
assert($this->resultSetMapping !== null);
1011+
$entityName = reset($this->resultSetMapping->aliasMap);
10121012

10131013
if (empty($entityName)) {
10141014
return null;
@@ -1056,11 +1056,11 @@ protected function getHydrationCacheId(): array
10561056
*/
10571057
public function setResultCacheId(string|null $id): static
10581058
{
1059-
if (! $this->_queryCacheProfile) {
1059+
if (! $this->queryCacheProfile) {
10601060
return $this->setResultCacheProfile(new QueryCacheProfile(0, $id));
10611061
}
10621062

1063-
$this->_queryCacheProfile = $this->_queryCacheProfile->setCacheKey($id);
1063+
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey($id);
10641064

10651065
return $this;
10661066
}
@@ -1081,8 +1081,8 @@ public function __clone()
10811081
{
10821082
$this->parameters = new ArrayCollection();
10831083

1084-
$this->_hints = [];
1085-
$this->_hints = $this->em->getConfiguration()->getDefaultQueryHints();
1084+
$this->hints = [];
1085+
$this->hints = $this->em->getConfiguration()->getDefaultQueryHints();
10861086
}
10871087

10881088
/**

0 commit comments

Comments
 (0)