Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop relying on underscores to indicate property visibility #10500

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 49 additions & 49 deletions lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,30 @@ abstract class AbstractQuery
/**
* The user-specified ResultSetMapping to use.
*/
protected ResultSetMapping|null $_resultSetMapping = null;
protected ResultSetMapping|null $resultSetMapping = null;

/**
* The map of query hints.
*
* @psalm-var array<string, mixed>
*/
protected array $_hints = [];
protected array $hints = [];

/**
* The hydration mode.
*
* @psalm-var string|AbstractQuery::HYDRATE_*
*/
protected string|int $_hydrationMode = self::HYDRATE_OBJECT;
protected string|int $hydrationMode = self::HYDRATE_OBJECT;

protected QueryCacheProfile|null $_queryCacheProfile = null;
protected QueryCacheProfile|null $queryCacheProfile = null;

/**
* Whether or not expire the result cache.
*/
protected bool $_expireResultCache = false;
protected bool $expireResultCache = false;

protected QueryCacheProfile|null $_hydrationCacheProfile = null;
protected QueryCacheProfile|null $hydrationCacheProfile = null;

/**
* Whether to use second level cache, if available.
Expand Down Expand Up @@ -147,7 +147,7 @@ public function __construct(
protected EntityManagerInterface $em,
) {
$this->parameters = new ArrayCollection();
$this->_hints = $em->getConfiguration()->getDefaultQueryHints();
$this->hints = $em->getConfiguration()->getDefaultQueryHints();
$this->hasCache = $this->em->getConfiguration()->isSecondLevelCacheEnabled();

if ($this->hasCache) {
Expand Down Expand Up @@ -260,7 +260,7 @@ public function free(): void
{
$this->parameters = new ArrayCollection();

$this->_hints = $this->em->getConfiguration()->getDefaultQueryHints();
$this->hints = $this->em->getConfiguration()->getDefaultQueryHints();
}

/**
Expand Down Expand Up @@ -434,7 +434,7 @@ private function processArrayParameterValue(array $value): array
public function setResultSetMapping(ResultSetMapping $rsm): static
{
$this->translateNamespaces($rsm);
$this->_resultSetMapping = $rsm;
$this->resultSetMapping = $rsm;

return $this;
}
Expand All @@ -444,7 +444,7 @@ public function setResultSetMapping(ResultSetMapping $rsm): static
*/
protected function getResultSetMapping(): ResultSetMapping|null
{
return $this->_resultSetMapping;
return $this->resultSetMapping;
}

/**
Expand Down Expand Up @@ -481,7 +481,7 @@ private function translateNamespaces(ResultSetMapping $rsm): void
public function setHydrationCacheProfile(QueryCacheProfile|null $profile): static
{
if ($profile === null) {
$this->_hydrationCacheProfile = null;
$this->hydrationCacheProfile = null;

return $this;
}
Expand All @@ -493,14 +493,14 @@ public function setHydrationCacheProfile(QueryCacheProfile|null $profile): stati
}
}

$this->_hydrationCacheProfile = $profile;
$this->hydrationCacheProfile = $profile;

return $this;
}

public function getHydrationCacheProfile(): QueryCacheProfile|null
{
return $this->_hydrationCacheProfile;
return $this->hydrationCacheProfile;
}

/**
Expand All @@ -514,7 +514,7 @@ public function getHydrationCacheProfile(): QueryCacheProfile|null
public function setResultCacheProfile(QueryCacheProfile|null $profile): static
{
if ($profile === null) {
$this->_queryCacheProfile = null;
$this->queryCacheProfile = null;

return $this;
}
Expand All @@ -526,7 +526,7 @@ public function setResultCacheProfile(QueryCacheProfile|null $profile): static
}
}

$this->_queryCacheProfile = $profile;
$this->queryCacheProfile = $profile;

return $this;
}
Expand All @@ -537,15 +537,15 @@ public function setResultCacheProfile(QueryCacheProfile|null $profile): static
public function setResultCache(CacheItemPoolInterface|null $resultCache): static
{
if ($resultCache === null) {
if ($this->_queryCacheProfile) {
$this->_queryCacheProfile = new QueryCacheProfile($this->_queryCacheProfile->getLifetime(), $this->_queryCacheProfile->getCacheKey());
if ($this->queryCacheProfile) {
$this->queryCacheProfile = new QueryCacheProfile($this->queryCacheProfile->getLifetime(), $this->queryCacheProfile->getCacheKey());
}

return $this;
}

$this->_queryCacheProfile = $this->_queryCacheProfile
? $this->_queryCacheProfile->setResultCache($resultCache)
$this->queryCacheProfile = $this->queryCacheProfile
? $this->queryCacheProfile->setResultCache($resultCache)
: new QueryCacheProfile(0, null, $resultCache);

return $this;
Expand Down Expand Up @@ -575,7 +575,7 @@ public function enableResultCache(int|null $lifetime = null, string|null $result
*/
public function disableResultCache(): static
{
$this->_queryCacheProfile = null;
$this->queryCacheProfile = null;

return $this;
}
Expand All @@ -591,20 +591,20 @@ public function setResultCacheLifetime(int|null $lifetime): static
{
$lifetime = (int) $lifetime;

if ($this->_queryCacheProfile) {
$this->_queryCacheProfile = $this->_queryCacheProfile->setLifetime($lifetime);
if ($this->queryCacheProfile) {
$this->queryCacheProfile = $this->queryCacheProfile->setLifetime($lifetime);

return $this;
}

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

$cache = $this->em->getConfiguration()->getResultCache();
if (! $cache) {
return $this;
}

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

return $this;
}
Expand All @@ -618,7 +618,7 @@ public function setResultCacheLifetime(int|null $lifetime): static
*/
public function expireResultCache(bool $expire = true): static
{
$this->_expireResultCache = $expire;
$this->expireResultCache = $expire;

return $this;
}
Expand All @@ -628,12 +628,12 @@ public function expireResultCache(bool $expire = true): static
*/
public function getExpireResultCache(): bool
{
return $this->_expireResultCache;
return $this->expireResultCache;
}

public function getQueryCacheProfile(): QueryCacheProfile|null
{
return $this->_queryCacheProfile;
return $this->queryCacheProfile;
}

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

return $this;
}
Expand All @@ -660,7 +660,7 @@ public function setFetchMode(string $class, string $assocName, int $fetchMode):
*/
public function setHydrationMode(string|int $hydrationMode): static
{
$this->_hydrationMode = $hydrationMode;
$this->hydrationMode = $hydrationMode;

return $this;
}
Expand All @@ -672,7 +672,7 @@ public function setHydrationMode(string|int $hydrationMode): static
*/
public function getHydrationMode(): string|int
{
return $this->_hydrationMode;
return $this->hydrationMode;
}

/**
Expand Down Expand Up @@ -738,7 +738,7 @@ public function getOneOrNullResult(string|int|null $hydrationMode = null): mixed
return null;
}

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

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

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

Expand Down Expand Up @@ -805,7 +805,7 @@ public function getSingleScalarResult(): mixed
*/
public function setHint(string $name, mixed $value): static
{
$this->_hints[$name] = $value;
$this->hints[$name] = $value;

return $this;
}
Expand All @@ -817,12 +817,12 @@ public function setHint(string $name, mixed $value): static
*/
public function getHint(string $name): mixed
{
return $this->_hints[$name] ?? false;
return $this->hints[$name] ?? false;
}

public function hasHint(string $name): bool
{
return isset($this->_hints[$name]);
return isset($this->hints[$name]);
}

/**
Expand All @@ -832,7 +832,7 @@ public function hasHint(string $name): bool
*/
public function getHints(): array
{
return $this->_hints;
return $this->hints;
}

/**
Expand Down Expand Up @@ -867,7 +867,7 @@ public function toIterable(

$stmt = $this->_doExecute();

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

/**
Expand Down Expand Up @@ -908,7 +908,7 @@ private function executeIgnoreQueryCache(
$setCacheEntry = static function ($data): void {
};

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

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

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

$setCacheEntry($data);

Expand All @@ -950,9 +950,9 @@ private function executeIgnoreQueryCache(

private function getHydrationCache(): CacheItemPoolInterface
{
assert($this->_hydrationCacheProfile !== null);
assert($this->hydrationCacheProfile !== null);

$cache = $this->_hydrationCacheProfile->getResultCache();
$cache = $this->hydrationCacheProfile->getResultCache();
assert($cache !== null);

return $cache;
Expand Down Expand Up @@ -981,7 +981,7 @@ private function executeUsingQueryCache(
$this->getTimestampKey(),
);

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

if ($result !== null) {
if ($this->cacheLogger) {
Expand All @@ -992,7 +992,7 @@ private function executeUsingQueryCache(
}

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

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

private function getTimestampKey(): TimestampCacheKey|null
{
assert($this->_resultSetMapping !== null);
$entityName = reset($this->_resultSetMapping->aliasMap);
assert($this->resultSetMapping !== null);
$entityName = reset($this->resultSetMapping->aliasMap);

if (empty($entityName)) {
return null;
Expand Down Expand Up @@ -1056,11 +1056,11 @@ protected function getHydrationCacheId(): array
*/
public function setResultCacheId(string|null $id): static
{
if (! $this->_queryCacheProfile) {
if (! $this->queryCacheProfile) {
return $this->setResultCacheProfile(new QueryCacheProfile(0, $id));
}

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

return $this;
}
Expand All @@ -1081,8 +1081,8 @@ public function __clone()
{
$this->parameters = new ArrayCollection();

$this->_hints = [];
$this->_hints = $this->em->getConfiguration()->getDefaultQueryHints();
$this->hints = [];
$this->hints = $this->em->getConfiguration()->getDefaultQueryHints();
}

/**
Expand Down
Loading