Skip to content

Commit

Permalink
Apply Doctrine CS 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Majkl578 committed Nov 4, 2018
1 parent 72971fd commit 0c2ccec
Show file tree
Hide file tree
Showing 443 changed files with 2,364 additions and 2,044 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"require-dev": {
"ext-pdo": "*",
"doctrine/coding-standard": "^4.0",
"doctrine/coding-standard": "^5.0",
"phpstan/phpstan-shim": "^0.9.2",
"phpunit/phpunit": "^7.0"
},
Expand Down
57 changes: 30 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function getParameters()
public function getParameter($key)
{
$filteredParameters = $this->parameters->filter(
function (Query\Parameter $parameter) use ($key) : bool {
static function (Query\Parameter $parameter) use ($key) : bool {
$parameterName = $parameter->getName();

return $key === $parameterName || (string) $key === (string) $parameterName;
Expand Down Expand Up @@ -438,13 +438,13 @@ protected function getResultSetMapping()
* some form of caching with UnitOfWork registration you should use
* {@see AbstractQuery::setResultCacheProfile()}.
*
* @return static This query instance.
*
* @example
* $lifetime = 100;
* $resultKey = "abc";
* $query->setHydrationCacheProfile(new QueryCacheProfile());
* $query->setHydrationCacheProfile(new QueryCacheProfile($lifetime, $resultKey));
*
* @return static This query instance.
*/
public function setHydrationCacheProfile(?QueryCacheProfile $profile = null)
{
Expand Down Expand Up @@ -557,7 +557,7 @@ public function useResultCache($useCache, $lifetime = null, $resultCacheId = nul
*/
public function setResultCacheLifetime($lifetime)
{
$lifetime = ($lifetime !== null) ? (int) $lifetime : 0;
$lifetime = $lifetime !== null ? (int) $lifetime : 0;

$this->queryCacheProfile = $this->queryCacheProfile
? $this->queryCacheProfile->setLifetime($lifetime)
Expand Down Expand Up @@ -883,11 +883,11 @@ private function executeIgnoreQueryCache($parameters = null, $hydrationMode = nu
$this->setParameters($parameters);
}

$setCacheEntry = function () {
$setCacheEntry = static function () {
};

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

$queryCacheProfile = $this->getHydrationCacheProfile();
$cache = $queryCacheProfile->getResultCacheDriver();
Expand All @@ -901,7 +901,7 @@ private function executeIgnoreQueryCache($parameters = null, $hydrationMode = nu
$result = [];
}

$setCacheEntry = function ($data) use ($cache, $result, $cacheKey, $realCacheKey, $queryCacheProfile) {
$setCacheEntry = static function ($data) use ($cache, $result, $cacheKey, $realCacheKey, $queryCacheProfile) {
$result[$realCacheKey] = $data;

$cache->save($cacheKey, $result, $queryCacheProfile->getLifetime());
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/AssociationOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ final class AssociationOverride implements Annotation
* The fetching strategy to use for the association.
*
* @var string
*
* @Enum({"LAZY", "EAGER", "EXTRA_LAZY"})
*/
public $fetch;
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ final class Cache implements Annotation
{
/**
* @Enum({"READ_ONLY", "NONSTRICT_READ_WRITE", "READ_WRITE"})
*
* @var string The concurrency strategy.
*/
public $usage = 'READ_ONLY';
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/ChangeTrackingPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ final class ChangeTrackingPolicy implements Annotation
* The change tracking policy.
*
* @var string
*
* @Enum({"DEFERRED_IMPLICIT", "DEFERRED_EXPLICIT", "NOTIFY"})
*/
public $value;
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/GeneratedValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ final class GeneratedValue implements Annotation
* The type of Id generator.
*
* @var string
*
* @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "CUSTOM"})
*/
public $strategy = 'AUTO';
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/InheritanceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ final class InheritanceType implements Annotation
* The inheritance type used by the class and its subclasses.
*
* @var string
*
* @Enum({"NONE", "JOINED", "SINGLE_TABLE", "TABLE_PER_CLASS"})
*/
public $value;
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/ManyToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ final class ManyToMany implements Annotation
* The fetching strategy to use for the association.
*
* @var string
*
* @Enum({"LAZY", "EAGER", "EXTRA_LAZY"})
*/
public $fetch = 'LAZY';
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/ManyToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ final class ManyToOne implements Annotation
* The fetching strategy to use for the association.
*
* @var string
*
* @Enum({"LAZY", "EAGER", "EXTRA_LAZY"})
*/
public $fetch = 'LAZY';
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/OneToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ final class OneToMany implements Annotation
* The fetching strategy to use for the association.
*
* @var string
*
* @Enum({"LAZY", "EAGER", "EXTRA_LAZY"})
*/
public $fetch = 'LAZY';
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Annotation/OneToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ final class OneToOne implements Annotation
* The fetching strategy to use for the association.
*
* @var string
*
* @Enum({"LAZY", "EAGER", "EXTRA_LAZY"})
*/
public $fetch = 'LAZY';
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Cache/CollectionHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

/**
* Hydrator cache entry for collections
*
*/
interface CollectionHydrator
{
Expand Down
13 changes: 7 additions & 6 deletions lib/Doctrine/ORM/Cache/DefaultCacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Persisters\Collection\CollectionPersister;
use Doctrine\ORM\Persisters\Entity\EntityPersister;
use InvalidArgumentException;
use LogicException;
use const DIRECTORY_SEPARATOR;
use function sprintf;

Expand Down Expand Up @@ -100,7 +102,7 @@ public function buildCachedEntityPersister(
return new NonStrictReadWriteCachedEntityPersister($persister, $region, $em, $metadata);

default:
throw new \InvalidArgumentException(sprintf('Unrecognized access strategy type [%s]', $usage));
throw new InvalidArgumentException(sprintf('Unrecognized access strategy type [%s]', $usage));
}
}

Expand All @@ -127,7 +129,7 @@ public function buildCachedCollectionPersister(
return new NonStrictReadWriteCachedCollectionPersister($persister, $region, $em, $association);

default:
throw new \InvalidArgumentException(
throw new InvalidArgumentException(
sprintf('Unrecognized access strategy type [%s]', $usage)
);
}
Expand Down Expand Up @@ -175,14 +177,13 @@ public function getRegion(CacheMetadata $cache)

$cacheAdapter = $this->createRegionCache($regionName);
$lifetime = $this->regionsConfig->getLifetime($regionName);
$region = ($cacheAdapter instanceof MultiGetCache)
$region = $cacheAdapter instanceof MultiGetCache
? new DefaultMultiGetRegion($regionName, $cacheAdapter, $lifetime)
: new DefaultRegion($regionName, $cacheAdapter, $lifetime)
;
: new DefaultRegion($regionName, $cacheAdapter, $lifetime);

if ($cache->getUsage() === CacheUsage::READ_WRITE) {
if (! $this->fileLockRegionDirectory) {
throw new \LogicException(
throw new LogicException(
'If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, ' .
'The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory, DefaultCacheFactory#setFileLockRegionDirectory(). '
);
Expand Down
7 changes: 4 additions & 3 deletions lib/Doctrine/ORM/Cache/DefaultQueryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []

$result = [];
$entityName = reset($rsm->aliasMap);
$hasRelation = ( ! empty($rsm->relationMap));
$hasRelation = ! empty($rsm->relationMap);
$unitOfWork = $this->em->getUnitOfWork();
$persister = $unitOfWork->getEntityPersister($entityName);
$region = $persister->getCacheRegion();
$regionName = $region->getName();

$cm = $this->em->getClassMetadata($entityName);

$generateKeys = function (array $entry) use ($cm) : EntityCacheKey {
$generateKeys = static function (array $entry) use ($cm) : EntityCacheKey {
return new EntityCacheKey($cm->getRootClassName(), $entry['identifier']);
};

Expand Down Expand Up @@ -160,7 +160,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []
continue;
}

$generateKeys = function ($id) use ($assocMetadata) : EntityCacheKey {
$generateKeys = static function ($id) use ($assocMetadata) : EntityCacheKey {
return new EntityCacheKey($assocMetadata->getRootClassName(), $id);
};

Expand Down Expand Up @@ -226,6 +226,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []

/**
* {@inheritdoc}
*
* @param mixed[] $hints
*/
public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $hints = [])
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/EntityCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function __set_state(array $values)
*/
public function resolveAssociationEntries(EntityManagerInterface $em)
{
return array_map(function ($value) use ($em) {
return array_map(static function ($value) use ($em) {
if (! ($value instanceof AssociationCacheEntry)) {
return $value;
}
Expand Down
Loading

0 comments on commit 0c2ccec

Please sign in to comment.