diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 5f4248b5f..8d901d514 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -96,7 +96,7 @@ abstract class AbstractQuery * * @var array */ - protected $_hints = array(); + protected $_hints = []; /** * The hydration mode. @@ -955,7 +955,7 @@ abstract class AbstractQuery } if ( ! $result) { - $result = array(); + $result = []; } $setCacheEntry = function($data) use ($cache, $result, $cacheKey, $realCacheKey, $queryCacheProfile) { @@ -1049,7 +1049,7 @@ abstract class AbstractQuery */ protected function getHydrationCacheId() { - $parameters = array(); + $parameters = []; foreach ($this->getParameters() as $parameter) { $parameters[$parameter->getName()] = $this->processParameterValue($parameter->getValue()); @@ -1111,7 +1111,7 @@ abstract class AbstractQuery { $this->parameters = new ArrayCollection(); - $this->_hints = array(); + $this->_hints = []; $this->_hints = $this->_em->getConfiguration()->getDefaultQueryHints(); } diff --git a/lib/Doctrine/ORM/Cache/DefaultCache.php b/lib/Doctrine/ORM/Cache/DefaultCache.php index 2557da4c1..80fbd8143 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultCache.php @@ -53,7 +53,7 @@ class DefaultCache implements Cache /** * @var \Doctrine\ORM\Cache\QueryCache[] */ - private $queryCaches = array(); + private $queryCaches = []; /** * @var \Doctrine\ORM\Cache\QueryCache @@ -336,7 +336,7 @@ class DefaultCache implements Cache } } - return array($metadata->identifier[0] => $identifier); + return [$metadata->identifier[0] => $identifier]; } } diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 98ece43c7..151009632 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -64,7 +64,7 @@ class DefaultCacheFactory implements CacheFactory /** * @var \Doctrine\ORM\Cache\Region[] */ - private $regions = array(); + private $regions = []; /** * @var string|null @@ -167,10 +167,10 @@ class DefaultCacheFactory implements CacheFactory return new DefaultQueryCache( $em, $this->getRegion( - array( + [ 'region' => $regionName ?: Cache::DEFAULT_QUERY_REGION_NAME, 'usage' => ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE - ) + ] ) ); } diff --git a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php index f6583cbd2..7ff11e4ad 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php @@ -46,7 +46,7 @@ class DefaultCollectionHydrator implements CollectionHydrator /** * @var array */ - private static $hints = array(Query::HINT_CACHE_ENABLED => true); + private static $hints = [Query::HINT_CACHE_ENABLED => true]; /** * @param \Doctrine\ORM\EntityManagerInterface $em The entity manager. @@ -62,7 +62,7 @@ class DefaultCollectionHydrator implements CollectionHydrator */ public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, $collection) { - $data = array(); + $data = []; foreach ($collection as $index => $entity) { $data[$index] = new EntityCacheKey($metadata->name, $this->uow->getEntityIdentifier($entity)); @@ -79,7 +79,7 @@ class DefaultCollectionHydrator implements CollectionHydrator /* @var $targetPersister \Doctrine\ORM\Cache\Persister\CachedPersister */ $targetPersister = $this->uow->getEntityPersister($assoc['targetEntity']); $targetRegion = $targetPersister->getCacheRegion(); - $list = array(); + $list = []; $entityEntries = $targetRegion->getMultiple($entry); diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 9ecb18e92..99a98bddc 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -55,7 +55,7 @@ class DefaultEntityHydrator implements EntityHydrator /** * @var array */ - private static $hints = array(Query::HINT_CACHE_ENABLED => true); + private static $hints = [Query::HINT_CACHE_ENABLED => true]; /** * @param \Doctrine\ORM\EntityManagerInterface $em The entity manager. @@ -138,7 +138,7 @@ class DefaultEntityHydrator implements EntityHydrator $data[reset($assoc['joinColumnFieldNames'])] = $targetId; $targetEntity = $this->em->getClassMetadata($assoc['targetEntity']); - $targetId = array($targetEntity->identifier[0] => $targetId); + $targetId = [$targetEntity->identifier[0] => $targetId]; } $data[$name] = new AssociationCacheEntry($assoc['targetEntity'], $targetId); diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index dabf1721e..88e594213 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -66,7 +66,7 @@ class DefaultQueryCache implements QueryCache /** * @var array */ - private static $hints = array(Query::HINT_CACHE_ENABLED => true); + private static $hints = [Query::HINT_CACHE_ENABLED => true]; /** * @param \Doctrine\ORM\EntityManagerInterface $em The entity manager. @@ -86,7 +86,7 @@ class DefaultQueryCache implements QueryCache /** * {@inheritdoc} */ - public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = array()) + public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []) { if ( ! ($key->cacheMode & Cache::MODE_GET)) { return null; @@ -104,7 +104,7 @@ class DefaultQueryCache implements QueryCache return null; } - $result = array(); + $result = []; $entityName = reset($rsm->aliasMap); $hasRelation = ( ! empty($rsm->relationMap)); $persister = $this->uow->getEntityPersister($entityName); @@ -209,7 +209,7 @@ class DefaultQueryCache implements QueryCache /** * {@inheritdoc} */ - public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $hints = array()) + public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $hints = []) { if ($rsm->scalarMappings) { throw new CacheException("Second level cache does not support scalar results."); @@ -231,7 +231,7 @@ class DefaultQueryCache implements QueryCache return false; } - $data = array(); + $data = []; $entityName = reset($rsm->aliasMap); $rootAlias = key($rsm->aliasMap); $hasRelation = ( ! empty($rsm->relationMap)); @@ -247,7 +247,7 @@ class DefaultQueryCache implements QueryCache $identifier = $this->uow->getEntityIdentifier($entity); $entityKey = new EntityCacheKey($entityName, $identifier); $data[$index]['identifier'] = $identifier; - $data[$index]['associations'] = array(); + $data[$index]['associations'] = []; if (($key->cacheMode & Cache::MODE_REFRESH) || ! $region->contains($entityKey)) { // Cancel put result if entity put fail @@ -332,15 +332,15 @@ class DefaultQueryCache implements QueryCache } } - return array( + return [ 'targetEntity' => $assocMetadata->rootEntityName, 'identifier' => $assocIdentifier, 'type' => $assoc['type'] - ); + ]; } // Handle *-to-many associations - $list = array(); + $list = []; foreach ($assocValue as $assocItemIndex => $assocItem) { $assocIdentifier = $this->uow->getEntityIdentifier($assocItem); @@ -356,11 +356,11 @@ class DefaultQueryCache implements QueryCache $list[$assocItemIndex] = $assocIdentifier; } - return array( + return [ 'targetEntity' => $assocMetadata->rootEntityName, 'type' => $assoc['type'], 'list' => $list, - ); + ]; } /** @@ -372,7 +372,7 @@ class DefaultQueryCache implements QueryCache */ private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity) { - $path = array(); + $path = []; $alias = $assocAlias; while (isset($rsm->parentAliasMap[$alias])) { @@ -380,10 +380,11 @@ class DefaultQueryCache implements QueryCache $field = $rsm->relationMap[$alias]; $class = $rsm->aliasMap[$parent]; - array_unshift($path, array( + array_unshift($path, [ 'field' => $field, 'class' => $class - )); + ] + ); $alias = $parent; } @@ -417,7 +418,7 @@ class DefaultQueryCache implements QueryCache return $this->getAssociationPathValue($value, $path); } - $values = array(); + $values = []; foreach ($value as $item) { $values[] = $this->getAssociationPathValue($item, $path); diff --git a/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php b/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php index 694b35ca5..28a8125c9 100644 --- a/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php +++ b/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php @@ -35,7 +35,7 @@ class CacheLoggerChain implements CacheLogger /** * @var array<\Doctrine\ORM\Cache\Logging\CacheLogger> */ - private $loggers = array(); + private $loggers = []; /** * @param string $name diff --git a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php b/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php index 2fbba40be..122e3534a 100644 --- a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php +++ b/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php @@ -35,17 +35,17 @@ class StatisticsCacheLogger implements CacheLogger /** * @var array */ - private $cacheMissCountMap = array(); + private $cacheMissCountMap = []; /** * @var array */ - private $cacheHitCountMap = array(); + private $cacheHitCountMap = []; /** * @var array */ - private $cachePutCountMap = array(); + private $cachePutCountMap = []; /** * {@inheritdoc} @@ -214,9 +214,9 @@ class StatisticsCacheLogger implements CacheLogger */ public function clearStats() { - $this->cachePutCountMap = array(); - $this->cacheHitCountMap = array(); - $this->cacheMissCountMap = array(); + $this->cachePutCountMap = []; + $this->cacheHitCountMap = []; + $this->cacheMissCountMap = []; } /** diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index abaef17a6..7a10d17d9 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -70,7 +70,7 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister /** * @var array */ - protected $queuedCache = array(); + protected $queuedCache = []; /** * @var \Doctrine\ORM\Cache\Region diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php index 86e5c8f9f..fbd46f6ea 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php @@ -46,7 +46,7 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPers } } - $this->queuedCache = array(); + $this->queuedCache = []; } /** @@ -54,7 +54,7 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPers */ public function afterTransactionRolledBack() { - $this->queuedCache = array(); + $this->queuedCache = []; } /** @@ -96,9 +96,9 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPers $this->persister->update($collection); - $this->queuedCache['update'][spl_object_hash($collection)] = array( + $this->queuedCache['update'][spl_object_hash($collection)] = [ 'key' => $key, 'list' => $collection - ); + ]; } } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php index a92ed20d3..74bb04445 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php @@ -60,7 +60,7 @@ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister } } - $this->queuedCache = array(); + $this->queuedCache = []; } /** @@ -80,7 +80,7 @@ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister } } - $this->queuedCache = array(); + $this->queuedCache = []; } /** @@ -98,10 +98,10 @@ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister return; } - $this->queuedCache['delete'][spl_object_hash($collection)] = array( + $this->queuedCache['delete'][spl_object_hash($collection)] = [ 'key' => $key, 'lock' => $lock - ); + ]; } /** @@ -126,9 +126,9 @@ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister return; } - $this->queuedCache['update'][spl_object_hash($collection)] = array( + $this->queuedCache['update'][spl_object_hash($collection)] = [ 'key' => $key, 'lock' => $lock - ); + ]; } } diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index c1e2d50ad..a6e2b3480 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -64,7 +64,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister /** * @var array */ - protected $queuedCache = array(); + protected $queuedCache = []; /** * @var \Doctrine\ORM\Cache\Region @@ -160,7 +160,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister /** * {@inheritDoc} */ - public function getCountSQL($criteria = array()) + public function getCountSQL($criteria = []) { return $this->persister->getCountSQL($criteria); } @@ -249,7 +249,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister private function storeJoinedAssociations($entity) { if ($this->joinedAssociations === null) { - $associations = array(); + $associations = []; foreach ($this->class->associationMappings as $name => $assoc) { if (isset($assoc['cache']) && @@ -360,7 +360,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister /** * {@inheritdoc} */ - public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = null, $limit = null, array $orderBy = null) + public function load(array $criteria, $entity = null, $assoc = null, array $hints = [], $lockMode = null, $limit = null, array $orderBy = null) { if ($entity !== null || $assoc !== null || ! empty($hints) || $lockMode !== null) { return $this->persister->load($criteria, $entity, $assoc, $hints, $lockMode, $limit, $orderBy); @@ -386,7 +386,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister return null; } - $cached = $queryCache->put($queryKey, $rsm, array($result)); + $cached = $queryCache->put($queryKey, $rsm, [$result]); if ($this->cacheLogger) { if ($result) { @@ -404,7 +404,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister /** * {@inheritdoc} */ - public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null) + public function loadAll(array $criteria = [], array $orderBy = null, $limit = null, $offset = null) { $query = $this->persister->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy); $hash = $this->getHash($query, $criteria, null, null, null); @@ -494,7 +494,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister /** * {@inheritDoc} */ - public function count($criteria = array()) + public function count($criteria = []) { return $this->persister->count($criteria); } @@ -612,7 +612,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister /** * {@inheritdoc} */ - public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = array()) + public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = []) { return $this->persister->loadOneToOneEntity($assoc, $sourceEntity, $identifier); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php index 54c814a9a..a2844673b 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php @@ -62,7 +62,7 @@ class NonStrictReadWriteCachedEntityPersister extends AbstractEntityPersister $this->timestampRegion->update($this->timestampKey); } - $this->queuedCache = array(); + $this->queuedCache = []; } /** @@ -70,7 +70,7 @@ class NonStrictReadWriteCachedEntityPersister extends AbstractEntityPersister */ public function afterTransactionRolledBack() { - $this->queuedCache = array(); + $this->queuedCache = []; } /** diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php index 07cac510d..79a4c8c3d 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php @@ -73,7 +73,7 @@ class ReadWriteCachedEntityPersister extends AbstractEntityPersister $this->timestampRegion->update($this->timestampKey); } - $this->queuedCache = array(); + $this->queuedCache = []; } /** @@ -93,7 +93,7 @@ class ReadWriteCachedEntityPersister extends AbstractEntityPersister } } - $this->queuedCache = array(); + $this->queuedCache = []; } /** @@ -113,10 +113,10 @@ class ReadWriteCachedEntityPersister extends AbstractEntityPersister return $deleted; } - $this->queuedCache['delete'][] = array( + $this->queuedCache['delete'][] = [ 'lock' => $lock, 'key' => $key - ); + ]; return $deleted; } @@ -135,9 +135,9 @@ class ReadWriteCachedEntityPersister extends AbstractEntityPersister return; } - $this->queuedCache['update'][] = array( + $this->queuedCache['update'][] = [ 'lock' => $lock, 'key' => $key - ); + ]; } } diff --git a/lib/Doctrine/ORM/Cache/QueryCache.php b/lib/Doctrine/ORM/Cache/QueryCache.php index dd5ef3bf5..de2496253 100644 --- a/lib/Doctrine/ORM/Cache/QueryCache.php +++ b/lib/Doctrine/ORM/Cache/QueryCache.php @@ -44,7 +44,7 @@ interface QueryCache * * @return boolean */ - public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $hints = array()); + public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $hints = []); /** * @param \Doctrine\ORM\Cache\QueryCacheKey $key @@ -53,7 +53,7 @@ interface QueryCache * * @return array|null */ - public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = array()); + public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []); /** * @return \Doctrine\ORM\Cache\Region diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php index 7ecf73311..1df073c3e 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php @@ -56,7 +56,7 @@ class DefaultMultiGetRegion extends DefaultRegion */ public function getMultiple(CollectionCacheEntry $collection) { - $keysToRetrieve = array(); + $keysToRetrieve = []; foreach ($collection->identifiers as $index => $key) { $keysToRetrieve[$index] = $this->getCacheEntryKey($key); @@ -67,7 +67,7 @@ class DefaultMultiGetRegion extends DefaultRegion return null; } - $returnableItems = array(); + $returnableItems = []; foreach ($keysToRetrieve as $index => $key) { $returnableItems[$index] = $items[$key]; } diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php index 3f214d0b0..be62a6fb9 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php @@ -102,7 +102,7 @@ class DefaultRegion implements Region */ public function getMultiple(CollectionCacheEntry $collection) { - $result = array(); + $result = []; foreach ($collection->identifiers as $key) { $entryKey = $this->getCacheEntryKey($key); diff --git a/lib/Doctrine/ORM/Cache/RegionsConfiguration.php b/lib/Doctrine/ORM/Cache/RegionsConfiguration.php index 0d060636c..d79c5b1af 100644 --- a/lib/Doctrine/ORM/Cache/RegionsConfiguration.php +++ b/lib/Doctrine/ORM/Cache/RegionsConfiguration.php @@ -31,12 +31,12 @@ class RegionsConfiguration /** * @var array */ - private $lifetimes = array(); + private $lifetimes = []; /** * @var array */ - private $lockLifetimes = array(); + private $lockLifetimes = []; /** * @var integer diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 872050cb0..fa1d1dde7 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -149,7 +149,7 @@ class Configuration extends \Doctrine\DBAL\Configuration * * @return AnnotationDriver */ - public function newDefaultAnnotationDriver($paths = array(), $useSimpleAnnotationReader = true) + public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true) { AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); @@ -349,7 +349,7 @@ class Configuration extends \Doctrine\DBAL\Configuration */ public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm) { - $this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm); + $this->_attributes['namedNativeQueries'][$name] = [$sql, $rsm]; } /** @@ -590,7 +590,7 @@ class Configuration extends \Doctrine\DBAL\Configuration */ public function setCustomHydrationModes($modes) { - $this->_attributes['customHydrationModes'] = array(); + $this->_attributes['customHydrationModes'] = []; foreach ($modes as $modeName => $hydrator) { $this->addCustomHydrationMode($modeName, $hydrator); @@ -881,7 +881,7 @@ class Configuration extends \Doctrine\DBAL\Configuration */ public function getDefaultQueryHints() { - return isset($this->_attributes['defaultQueryHints']) ? $this->_attributes['defaultQueryHints'] : array(); + return isset($this->_attributes['defaultQueryHints']) ? $this->_attributes['defaultQueryHints'] : []; } /** diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index b61a2557b..53573c25c 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -386,7 +386,7 @@ use Doctrine\Common\Util\ClassUtils; throw ORMInvalidArgumentException::invalidCompositeIdentifier(); } - $id = array($class->identifier[0] => $id); + $id = [$class->identifier[0] => $id]; } foreach ($id as $i => $value) { @@ -399,7 +399,7 @@ use Doctrine\Common\Util\ClassUtils; } } - $sortedId = array(); + $sortedId = []; foreach ($class->identifier as $identifier) { if ( ! isset($id[$identifier])) { @@ -458,7 +458,7 @@ use Doctrine\Common\Util\ClassUtils; throw TransactionRequiredException::transactionRequired(); } - return $persister->load($sortedId, null, null, array(), $lockMode); + return $persister->load($sortedId, null, null, [], $lockMode); default: return $persister->loadById($sortedId); @@ -473,10 +473,10 @@ use Doctrine\Common\Util\ClassUtils; $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); if ( ! is_array($id)) { - $id = array($class->identifier[0] => $id); + $id = [$class->identifier[0] => $id]; } - $sortedId = array(); + $sortedId = []; foreach ($class->identifier as $identifier) { if ( ! isset($id[$identifier])) { @@ -502,7 +502,7 @@ use Doctrine\Common\Util\ClassUtils; $entity = $this->proxyFactory->getProxy($class->name, $sortedId); - $this->unitOfWork->registerManaged($entity, $sortedId, array()); + $this->unitOfWork->registerManaged($entity, $sortedId, []); return $entity; } @@ -520,14 +520,14 @@ use Doctrine\Common\Util\ClassUtils; } if ( ! is_array($identifier)) { - $identifier = array($class->identifier[0] => $identifier); + $identifier = [$class->identifier[0] => $identifier]; } $entity = $class->newInstance(); $class->setIdentifierValues($entity, $identifier); - $this->unitOfWork->registerManaged($entity, $identifier, array()); + $this->unitOfWork->registerManaged($entity, $identifier, []); $this->unitOfWork->markReadOnly($entity); return $entity; diff --git a/lib/Doctrine/ORM/EntityNotFoundException.php b/lib/Doctrine/ORM/EntityNotFoundException.php index afe2f2242..5b21e15c2 100644 --- a/lib/Doctrine/ORM/EntityNotFoundException.php +++ b/lib/Doctrine/ORM/EntityNotFoundException.php @@ -37,7 +37,7 @@ class EntityNotFoundException extends ORMException */ public static function fromClassNameAndIdentifier($className, array $id) { - $ids = array(); + $ids = []; foreach ($id as $key => $value) { $ids[] = $key . '(' . $value . ')'; diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 1934a18d0..6be570ba3 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -161,7 +161,7 @@ class EntityRepository implements ObjectRepository, Selectable */ public function findAll() { - return $this->findBy(array()); + return $this->findBy([]); } /** @@ -193,7 +193,7 @@ class EntityRepository implements ObjectRepository, Selectable { $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName); - return $persister->load($criteria, null, null, array(), null, 1, $orderBy); + return $persister->load($criteria, null, null, [], null, 1, $orderBy); } /** diff --git a/lib/Doctrine/ORM/Id/AssignedGenerator.php b/lib/Doctrine/ORM/Id/AssignedGenerator.php index 447dbd6d5..691eaee42 100644 --- a/lib/Doctrine/ORM/Id/AssignedGenerator.php +++ b/lib/Doctrine/ORM/Id/AssignedGenerator.php @@ -44,7 +44,7 @@ class AssignedGenerator extends AbstractIdGenerator { $class = $em->getClassMetadata(get_class($entity)); $idFields = $class->getIdentifierFieldNames(); - $identifier = array(); + $identifier = []; foreach ($idFields as $idField) { $value = $class->getFieldValue($entity, $idField); diff --git a/lib/Doctrine/ORM/Id/SequenceGenerator.php b/lib/Doctrine/ORM/Id/SequenceGenerator.php index 1f3c9541b..a27edae90 100644 --- a/lib/Doctrine/ORM/Id/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Id/SequenceGenerator.php @@ -108,10 +108,12 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable */ public function serialize() { - return serialize(array( + return serialize( + [ 'allocationSize' => $this->_allocationSize, 'sequenceName' => $this->_sequenceName - )); + ] + ); } /** diff --git a/lib/Doctrine/ORM/Id/TableGenerator.php b/lib/Doctrine/ORM/Id/TableGenerator.php index abf3ab8ac..02385f511 100644 --- a/lib/Doctrine/ORM/Id/TableGenerator.php +++ b/lib/Doctrine/ORM/Id/TableGenerator.php @@ -92,7 +92,7 @@ class TableGenerator extends AbstractIdGenerator $this->_tableName, $this->_sequenceName, $this->_allocationSize ); - if ($conn->executeUpdate($updateSql, array(1 => $currentLevel, 2 => $currentLevel+1)) !== 1) { + if ($conn->executeUpdate($updateSql, [1 => $currentLevel, 2 => $currentLevel+1]) !== 1) { // no affected rows, concurrency issue, throw exception } } else { diff --git a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php index e1331da47..067a8c577 100644 --- a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php +++ b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php @@ -54,14 +54,14 @@ class CommitOrderCalculator * * @var array */ - private $nodeList = array(); + private $nodeList = []; /** * Volatile variable holding calculated nodes during sorting process. * * @var array */ - private $sortedNodeList = array(); + private $sortedNodeList = []; /** * Checks for node (vertex) existence in graph. @@ -90,7 +90,7 @@ class CommitOrderCalculator $vertex->hash = $hash; $vertex->state = self::NOT_VISITED; $vertex->value = $node; - $vertex->dependencyList = array(); + $vertex->dependencyList = []; $this->nodeList[$hash] = $vertex; } @@ -136,8 +136,8 @@ class CommitOrderCalculator $sortedList = $this->sortedNodeList; - $this->nodeList = array(); - $this->sortedNodeList = array(); + $this->nodeList = []; + $this->sortedNodeList = []; return array_reverse($sortedList); } @@ -162,7 +162,7 @@ class CommitOrderCalculator break; case self::IN_PROGRESS: - if (isset($adjacentVertex->dependencyList[$vertex->hash]) && + if (isset($adjacentVertex->dependencyList[$vertex->hash]) && $adjacentVertex->dependencyList[$vertex->hash]->weight < $edge->weight) { $adjacentVertex->state = self::VISITED; diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index ff142fc35..ee9385c81 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -69,14 +69,14 @@ abstract class AbstractHydrator * * @var array */ - protected $_metadataCache = array(); + protected $_metadataCache = []; /** * The cache used during row-by-row hydration. * * @var array */ - protected $_cache = array(); + protected $_cache = []; /** * The statement that provides the data to hydrate. @@ -113,7 +113,7 @@ abstract class AbstractHydrator * * @return IterableResult */ - public function iterate($stmt, $resultSetMapping, array $hints = array()) + public function iterate($stmt, $resultSetMapping, array $hints = []) { $this->_stmt = $stmt; $this->_rsm = $resultSetMapping; @@ -121,7 +121,7 @@ abstract class AbstractHydrator $evm = $this->_em->getEventManager(); - $evm->addEventListener(array(Events::onClear), $this); + $evm->addEventListener([Events::onClear], $this); $this->prepare(); @@ -137,7 +137,7 @@ abstract class AbstractHydrator * * @return array */ - public function hydrateAll($stmt, $resultSetMapping, array $hints = array()) + public function hydrateAll($stmt, $resultSetMapping, array $hints = []) { $this->_stmt = $stmt; $this->_rsm = $resultSetMapping; @@ -168,7 +168,7 @@ abstract class AbstractHydrator return false; } - $result = array(); + $result = []; $this->hydrateRowData($row, $result); @@ -209,8 +209,8 @@ abstract class AbstractHydrator $this->_stmt = null; $this->_rsm = null; - $this->_cache = array(); - $this->_metadataCache = array(); + $this->_cache = []; + $this->_metadataCache = []; } /** @@ -255,7 +255,7 @@ abstract class AbstractHydrator */ protected function gatherRowData(array $data, array &$id, array &$nonemptyComponents) { - $rowData = array('data' => array()); + $rowData = ['data' => []]; foreach ($data as $key => $value) { if (($cacheKeyInfo = $this->hydrateColumnInfo($key)) === null) { @@ -323,7 +323,7 @@ abstract class AbstractHydrator */ protected function gatherScalarRowData(&$data) { - $rowData = array(); + $rowData = []; foreach ($data as $key => $value) { if (($cacheKeyInfo = $this->hydrateColumnInfo($key)) === null) { @@ -369,18 +369,18 @@ abstract class AbstractHydrator $fieldName = $this->_rsm->fieldMappings[$key]; $fieldMapping = $classMetadata->fieldMappings[$fieldName]; - return $this->_cache[$key] = array( + return $this->_cache[$key] = [ 'isIdentifier' => in_array($fieldName, $classMetadata->identifier), 'fieldName' => $fieldName, 'type' => Type::getType($fieldMapping['type']), 'dqlAlias' => $this->_rsm->columnOwnerMap[$key], - ); + ]; case (isset($this->_rsm->newObjectMappings[$key])): // WARNING: A NEW object is also a scalar, so it must be declared before! $mapping = $this->_rsm->newObjectMappings[$key]; - return $this->_cache[$key] = array( + return $this->_cache[$key] = [ 'isScalar' => true, 'isNewObjectParameter' => true, 'fieldName' => $this->_rsm->scalarMappings[$key], @@ -388,14 +388,14 @@ abstract class AbstractHydrator 'argIndex' => $mapping['argIndex'], 'objIndex' => $mapping['objIndex'], 'class' => new \ReflectionClass($mapping['className']), - ); + ]; case (isset($this->_rsm->scalarMappings[$key])): - return $this->_cache[$key] = array( + return $this->_cache[$key] = [ 'isScalar' => true, 'fieldName' => $this->_rsm->scalarMappings[$key], 'type' => Type::getType($this->_rsm->typeMappings[$key]), - ); + ]; case (isset($this->_rsm->metaMappings[$key])): // Meta column (has meaning in relational schema only, i.e. foreign keys or discriminator columns). @@ -408,13 +408,13 @@ abstract class AbstractHydrator // Cache metadata fetch $this->getClassMetadata($this->_rsm->aliasMap[$dqlAlias]); - return $this->_cache[$key] = array( + return $this->_cache[$key] = [ 'isIdentifier' => isset($this->_rsm->isIdentifierColumn[$dqlAlias][$key]), 'isMetaColumn' => true, 'fieldName' => $fieldName, 'type' => $type, 'dqlAlias' => $dqlAlias, - ); + ]; } // this column is a left over, maybe from a LIMIT query hack for example in Oracle or DB2 @@ -452,7 +452,7 @@ abstract class AbstractHydrator protected function registerManaged(ClassMetadata $class, $entity, array $data) { if ($class->isIdentifierComposite) { - $id = array(); + $id = []; foreach ($class->identifier as $fieldName) { $id[$fieldName] = isset($class->associationMappings[$fieldName]) @@ -461,11 +461,11 @@ abstract class AbstractHydrator } } else { $fieldName = $class->identifier[0]; - $id = array( + $id = [ $fieldName => isset($class->associationMappings[$fieldName]) ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] : $data[$fieldName] - ); + ]; } $this->_em->getUnitOfWork()->registerManaged($entity, $id, $data); diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index f3e4376f7..c26b99be3 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -35,7 +35,7 @@ class ArrayHydrator extends AbstractHydrator /** * @var array */ - private $_rootAliases = array(); + private $_rootAliases = []; /** * @var bool @@ -45,17 +45,17 @@ class ArrayHydrator extends AbstractHydrator /** * @var array */ - private $_identifierMap = array(); + private $_identifierMap = []; /** * @var array */ - private $_resultPointers = array(); + private $_resultPointers = []; /** * @var array */ - private $_idTemplate = array(); + private $_idTemplate = []; /** * @var int @@ -70,8 +70,8 @@ class ArrayHydrator extends AbstractHydrator $this->_isSimpleQuery = count($this->_rsm->aliasMap) <= 1; foreach ($this->_rsm->aliasMap as $dqlAlias => $className) { - $this->_identifierMap[$dqlAlias] = array(); - $this->_resultPointers[$dqlAlias] = array(); + $this->_identifierMap[$dqlAlias] = []; + $this->_resultPointers[$dqlAlias] = []; $this->_idTemplate[$dqlAlias] = ''; } } @@ -81,7 +81,7 @@ class ArrayHydrator extends AbstractHydrator */ protected function hydrateAllData() { - $result = array(); + $result = []; while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { $this->hydrateRowData($data, $result); @@ -97,7 +97,7 @@ class ArrayHydrator extends AbstractHydrator { // 1) Initialize $id = $this->_idTemplate; // initialize the id-memory - $nonemptyComponents = array(); + $nonemptyComponents = []; $rowData = $this->gatherRowData($row, $id, $nonemptyComponents); // 2) Now hydrate the data found in the current row. @@ -138,7 +138,7 @@ class ArrayHydrator extends AbstractHydrator $oneToOne = false; if ( ! isset($baseElement[$relationAlias])) { - $baseElement[$relationAlias] = array(); + $baseElement[$relationAlias] = []; } if (isset($nonemptyComponents[$dqlAlias])) { @@ -187,7 +187,7 @@ class ArrayHydrator extends AbstractHydrator // if this row has a NULL value for the root result id then make it a null result. if ( ! isset($nonemptyComponents[$dqlAlias]) ) { $result[] = $this->_rsm->isMixed - ? array($entityKey => null) + ? [$entityKey => null] : null; $resultKey = $this->_resultCounter; @@ -199,7 +199,7 @@ class ArrayHydrator extends AbstractHydrator // Check for an existing element if ($this->_isSimpleQuery || ! isset($this->_identifierMap[$dqlAlias][$id[$dqlAlias]])) { $element = $this->_rsm->isMixed - ? array($entityKey => $data) + ? [$entityKey => $data] : $data; if (isset($this->_rsm->indexByMap[$dqlAlias])) { diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index d2d23a252..9d8ee329a 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -42,17 +42,17 @@ class ObjectHydrator extends AbstractHydrator /** * @var array */ - private $identifierMap = array(); + private $identifierMap = []; /** * @var array */ - private $resultPointers = array(); + private $resultPointers = []; /** * @var array */ - private $idTemplate = array(); + private $idTemplate = []; /** * @var integer @@ -62,17 +62,17 @@ class ObjectHydrator extends AbstractHydrator /** * @var array */ - private $rootAliases = array(); + private $rootAliases = []; /** * @var array */ - private $initializedCollections = array(); + private $initializedCollections = []; /** * @var array */ - private $existingCollections = array(); + private $existingCollections = []; /** * {@inheritdoc} @@ -84,7 +84,7 @@ class ObjectHydrator extends AbstractHydrator } foreach ($this->_rsm->aliasMap as $dqlAlias => $className) { - $this->identifierMap[$dqlAlias] = array(); + $this->identifierMap[$dqlAlias] = []; $this->idTemplate[$dqlAlias] = ''; // Remember which associations are "fetch joined", so that we know where to inject @@ -142,7 +142,7 @@ class ObjectHydrator extends AbstractHydrator $this->identifierMap = $this->initializedCollections = $this->existingCollections = - $this->resultPointers = array(); + $this->resultPointers = []; if ($eagerLoad) { $this->_uow->triggerEagerLoads(); @@ -156,7 +156,7 @@ class ObjectHydrator extends AbstractHydrator */ protected function hydrateAllData() { - $result = array(); + $result = []; while ($row = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { $this->hydrateRowData($row, $result); @@ -326,7 +326,7 @@ class ObjectHydrator extends AbstractHydrator { // Initialize $id = $this->idTemplate; // initialize the id-memory - $nonemptyComponents = array(); + $nonemptyComponents = []; // Split the row data into chunks of class data. $rowData = $this->gatherRowData($row, $id, $nonemptyComponents); @@ -478,7 +478,7 @@ class ObjectHydrator extends AbstractHydrator // if this row has a NULL value for the root result id then make it a null result. if ( ! isset($nonemptyComponents[$dqlAlias]) ) { if ($this->_rsm->isMixed) { - $result[] = array($entityKey => null); + $result[] = [$entityKey => null]; } else { $result[] = null; } @@ -492,7 +492,7 @@ class ObjectHydrator extends AbstractHydrator $element = $this->getEntity($data, $dqlAlias); if ($this->_rsm->isMixed) { - $element = array($entityKey => $element); + $element = [$entityKey => $element]; } if (isset($this->_rsm->indexByMap[$dqlAlias])) { diff --git a/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php index 024ee3b66..093e89c4e 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php @@ -35,7 +35,7 @@ class ScalarHydrator extends AbstractHydrator */ protected function hydrateAllData() { - $result = array(); + $result = []; while ($data = $this->_stmt->fetch(\PDO::FETCH_ASSOC)) { $this->hydrateRowData($data, $result); diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 785a2b796..bf2beaba3 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -62,7 +62,7 @@ class SimpleObjectHydrator extends AbstractHydrator */ protected function hydrateAllData() { - $result = array(); + $result = []; while ($row = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { $this->hydrateRowData($row, $result); @@ -79,7 +79,7 @@ class SimpleObjectHydrator extends AbstractHydrator protected function hydrateRowData(array $sqlResult, array &$result) { $entityName = $this->class->name; - $data = array(); + $data = []; // We need to find the correct entity class name if we have inheritance in resultset if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { diff --git a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php index 4da71cefa..72a0c7034 100644 --- a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php +++ b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php @@ -47,7 +47,7 @@ final class HydrationCompleteHandler /** * @var array[] */ - private $deferredPostLoadInvocations = array(); + private $deferredPostLoadInvocations = []; /** * Constructor for this object @@ -75,7 +75,7 @@ final class HydrationCompleteHandler return; } - $this->deferredPostLoadInvocations[] = array($class, $invoke, $entity); + $this->deferredPostLoadInvocations[] = [$class, $invoke, $entity]; } /** @@ -86,7 +86,7 @@ final class HydrationCompleteHandler public function hydrationComplete() { $toInvoke = $this->deferredPostLoadInvocations; - $this->deferredPostLoadInvocations = array(); + $this->deferredPostLoadInvocations = []; foreach ($toInvoke as $classAndEntity) { list($class, $invoke, $entity) = $classAndEntity; diff --git a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php index 5abfe21bb..7f4fddc96 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php @@ -84,7 +84,7 @@ class AssociationBuilder */ public function cascadeAll() { - $this->mapping['cascade'] = array("ALL"); + $this->mapping['cascade'] = ["ALL"]; return $this; } @@ -183,14 +183,14 @@ class AssociationBuilder */ public function addJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null) { - $this->joinColumns[] = array( + $this->joinColumns[] = [ 'name' => $columnName, 'referencedColumnName' => $referencedColumnName, 'nullable' => $nullable, 'unique' => $unique, 'onDelete' => $onDelete, 'columnDefinition' => $columnDef, - ); + ]; return $this; } diff --git a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php index 7d771d3f9..c08b374fe 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php @@ -91,11 +91,13 @@ class ClassMetadataBuilder */ public function addEmbedded($fieldName, $class, $columnPrefix = null) { - $this->cm->mapEmbedded(array( - 'fieldName' => $fieldName, - 'class' => $class, - 'columnPrefix' => $columnPrefix - )); + $this->cm->mapEmbedded( + [ + 'fieldName' => $fieldName, + 'class' => $class, + 'columnPrefix' => $columnPrefix + ] + ); return $this; } @@ -135,7 +137,7 @@ class ClassMetadataBuilder */ public function setTable($name) { - $this->cm->setPrimaryTable(array('name' => $name)); + $this->cm->setPrimaryTable(['name' => $name]); return $this; } @@ -151,10 +153,10 @@ class ClassMetadataBuilder public function addIndex(array $columns, $name) { if (!isset($this->cm->table['indexes'])) { - $this->cm->table['indexes'] = array(); + $this->cm->table['indexes'] = []; } - $this->cm->table['indexes'][$name] = array('columns' => $columns); + $this->cm->table['indexes'][$name] = ['columns' => $columns]; return $this; } @@ -170,10 +172,10 @@ class ClassMetadataBuilder public function addUniqueConstraint(array $columns, $name) { if ( ! isset($this->cm->table['uniqueConstraints'])) { - $this->cm->table['uniqueConstraints'] = array(); + $this->cm->table['uniqueConstraints'] = []; } - $this->cm->table['uniqueConstraints'][$name] = array('columns' => $columns); + $this->cm->table['uniqueConstraints'][$name] = ['columns' => $columns]; return $this; } @@ -188,10 +190,12 @@ class ClassMetadataBuilder */ public function addNamedQuery($name, $dqlQuery) { - $this->cm->addNamedQuery(array( - 'name' => $name, - 'query' => $dqlQuery, - )); + $this->cm->addNamedQuery( + [ + 'name' => $name, + 'query' => $dqlQuery, + ] + ); return $this; } @@ -231,11 +235,13 @@ class ClassMetadataBuilder */ public function setDiscriminatorColumn($name, $type = 'string', $length = 255) { - $this->cm->setDiscriminatorColumn(array( - 'name' => $name, - 'type' => $type, - 'length' => $length, - )); + $this->cm->setDiscriminatorColumn( + [ + 'name' => $name, + 'type' => $type, + 'length' => $length, + ] + ); return $this; } @@ -303,7 +309,7 @@ class ClassMetadataBuilder * * @return ClassMetadataBuilder */ - public function addField($name, $type, array $mapping = array()) + public function addField($name, $type, array $mapping = []) { $mapping['fieldName'] = $name; $mapping['type'] = $type; @@ -325,10 +331,10 @@ class ClassMetadataBuilder { return new FieldBuilder( $this, - array( + [ 'fieldName' => $name, 'type' => $type - ) + ] ); } @@ -344,11 +350,11 @@ class ClassMetadataBuilder { return new EmbeddedBuilder( $this, - array( + [ 'fieldName' => $fieldName, 'class' => $class, 'columnPrefix' => null - ) + ] ); } @@ -386,10 +392,10 @@ class ClassMetadataBuilder { return new AssociationBuilder( $this, - array( + [ 'fieldName' => $name, 'targetEntity' => $targetEntity - ), + ], ClassMetadata::MANY_TO_ONE ); } @@ -406,10 +412,10 @@ class ClassMetadataBuilder { return new AssociationBuilder( $this, - array( + [ 'fieldName' => $name, 'targetEntity' => $targetEntity - ), + ], ClassMetadata::ONE_TO_ONE ); } @@ -463,10 +469,10 @@ class ClassMetadataBuilder { return new ManyToManyAssociationBuilder( $this, - array( + [ 'fieldName' => $name, 'targetEntity' => $targetEntity - ), + ], ClassMetadata::MANY_TO_MANY ); } @@ -520,10 +526,10 @@ class ClassMetadataBuilder { return new OneToManyAssociationBuilder( $this, - array( + [ 'fieldName' => $name, 'targetEntity' => $targetEntity - ), + ], ClassMetadata::ONE_TO_MANY ); } diff --git a/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php index d17abeac5..e96272609 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php @@ -34,7 +34,7 @@ class EntityListenerBuilder /** * @var array Hash-map to handle event names. */ - static private $events = array( + static private $events = [ Events::preRemove => true, Events::postRemove => true, Events::prePersist => true, @@ -43,7 +43,7 @@ class EntityListenerBuilder Events::postUpdate => true, Events::postLoad => true, Events::preFlush => true - ); + ]; /** * Lookup the entity class to find methods that match to event lifecycle names @@ -69,4 +69,4 @@ class EntityListenerBuilder $metadata->addEntityListener($method, $class, $method); } } -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php index 5a8966781..d0128d4a9 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php @@ -226,11 +226,11 @@ class FieldBuilder */ public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initialValue = 1) { - $this->sequenceDef = array( + $this->sequenceDef = [ 'sequenceName' => $sequenceName, 'allocationSize' => $allocationSize, 'initialValue' => $initialValue, - ); + ]; return $this; } diff --git a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php index 8b167d996..a71859dfd 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php @@ -37,7 +37,7 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder /** * @var array */ - private $inverseJoinColumns = array(); + private $inverseJoinColumns = []; /** * @param string $name @@ -65,14 +65,14 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder */ public function addInverseJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null) { - $this->inverseJoinColumns[] = array( + $this->inverseJoinColumns[] = [ 'name' => $columnName, 'referencedColumnName' => $referencedColumnName, 'nullable' => $nullable, 'unique' => $unique, 'onDelete' => $onDelete, 'columnDefinition' => $columnDef, - ); + ]; return $this; } @@ -83,7 +83,7 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder public function build() { $mapping = $this->mapping; - $mapping['joinTable'] = array(); + $mapping['joinTable'] = []; if ($this->joinColumns) { $mapping['joinTable']['joinColumns'] = $this->joinColumns; } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index b42b8b567..a1412d2f1 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -68,7 +68,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory /** * @var array */ - private $embeddablesActiveNesting = array(); + private $embeddablesActiveNesting = []; /** * {@inheritDoc} @@ -350,9 +350,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory { $allClasses = $this->driver->getAllClassNames(); $fqcn = $class->getName(); - $map = array($this->getShortName($class->name) => $fqcn); + $map = [$this->getShortName($class->name) => $fqcn]; - $duplicates = array(); + $duplicates = []; foreach ($allClasses as $subClassCandidate) { if (is_subclass_of($subClassCandidate, $fqcn)) { $shortName = $this->getShortName($subClassCandidate); @@ -475,15 +475,17 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $embeddableMetadata = $this->getMetadataFor($embeddableClass['class']); - $parentClass->mapEmbedded(array( - 'fieldName' => $prefix . '.' . $property, - 'class' => $embeddableMetadata->name, - 'columnPrefix' => $embeddableClass['columnPrefix'], - 'declaredField' => $embeddableClass['declaredField'] - ? $prefix . '.' . $embeddableClass['declaredField'] - : $prefix, - 'originalField' => $embeddableClass['originalField'] ?: $property, - )); + $parentClass->mapEmbedded( + [ + 'fieldName' => $prefix . '.' . $property, + 'class' => $embeddableMetadata->name, + 'columnPrefix' => $embeddableClass['columnPrefix'], + 'declaredField' => $embeddableClass['declaredField'] + ? $prefix . '.' . $embeddableClass['declaredField'] + : $prefix, + 'originalField' => $embeddableClass['originalField'] ?: $property, + ] + ); } } @@ -501,7 +503,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory return; } - foreach (array('uniqueConstraints', 'indexes') as $indexType) { + foreach (['uniqueConstraints', 'indexes'] as $indexType) { if (isset($parentClass->table[$indexType])) { foreach ($parentClass->table[$indexType] as $indexName => $index) { if (isset($subClass->table[$indexType][$indexName])) { @@ -528,10 +530,12 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory { foreach ($parentClass->namedQueries as $name => $query) { if ( ! isset ($subClass->namedQueries[$name])) { - $subClass->addNamedQuery(array( - 'name' => $query['name'], - 'query' => $query['query'] - )); + $subClass->addNamedQuery( + [ + 'name' => $query['name'], + 'query' => $query['query'] + ] + ); } } } @@ -550,13 +554,15 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory { foreach ($parentClass->namedNativeQueries as $name => $query) { if ( ! isset ($subClass->namedNativeQueries[$name])) { - $subClass->addNamedNativeQuery(array( - 'name' => $query['name'], - 'query' => $query['query'], - 'isSelfClass' => $query['isSelfClass'], - 'resultSetMapping' => $query['resultSetMapping'], - 'resultClass' => $query['isSelfClass'] ? $subClass->name : $query['resultClass'], - )); + $subClass->addNamedNativeQuery( + [ + 'name' => $query['name'], + 'query' => $query['query'], + 'isSelfClass' => $query['isSelfClass'], + 'resultSetMapping' => $query['resultSetMapping'], + 'resultClass' => $query['isSelfClass'] ? $subClass->name : $query['resultClass'], + ] + ); } } } @@ -575,21 +581,23 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory { foreach ($parentClass->sqlResultSetMappings as $name => $mapping) { if ( ! isset ($subClass->sqlResultSetMappings[$name])) { - $entities = array(); + $entities = []; foreach ($mapping['entities'] as $entity) { - $entities[] = array( + $entities[] = [ 'fields' => $entity['fields'], 'isSelfClass' => $entity['isSelfClass'], 'discriminatorColumn' => $entity['discriminatorColumn'], 'entityClass' => $entity['isSelfClass'] ? $subClass->name : $entity['entityClass'], - ); + ]; } - $subClass->addSqlResultSetMapping(array( - 'name' => $mapping['name'], - 'columns' => $mapping['columns'], - 'entities' => $entities, - )); + $subClass->addSqlResultSetMapping( + [ + 'name' => $mapping['name'], + 'columns' => $mapping['columns'], + 'entities' => $entities, + ] + ); } } } @@ -629,9 +637,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']); $sequencePrefix = $class->getSequencePrefix($this->getTargetPlatform()); $sequenceName = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName); - $definition = array( + $definition = [ 'sequenceName' => $this->getTargetPlatform()->fixSchemaElementName($sequenceName) - ); + ]; if ($quoted) { $definition['quoted'] = true; @@ -661,11 +669,11 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $sequenceName = $class->getSequenceName($this->getTargetPlatform()); $quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']); - $definition = array( + $definition = [ 'sequenceName' => $this->getTargetPlatform()->fixSchemaElementName($sequenceName), 'allocationSize' => 1, 'initialValue' => 1, - ); + ]; if ($quoted) { $definition['quoted'] = true; diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 3058a2eda..9a5811163 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -275,28 +275,28 @@ class ClassMetadataInfo implements ClassMetadata * * @var array */ - public $parentClasses = array(); + public $parentClasses = []; /** * READ-ONLY: The names of all subclasses (descendants). * * @var array */ - public $subClasses = array(); + public $subClasses = []; /** * READ-ONLY: The names of all embedded classes based on properties. * * @var array */ - public $embeddedClasses = array(); + public $embeddedClasses = []; /** * READ-ONLY: The named queries allowed to be called directly from Repository. * * @var array */ - public $namedQueries = array(); + public $namedQueries = []; /** * READ-ONLY: The named native queries allowed to be called directly from Repository. @@ -313,7 +313,7 @@ class ClassMetadataInfo implements ClassMetadata * * @var array */ - public $namedNativeQueries = array(); + public $namedNativeQueries = []; /** * READ-ONLY: The mappings of the results of native SQL queries. @@ -329,7 +329,7 @@ class ClassMetadataInfo implements ClassMetadata * * @var array */ - public $sqlResultSetMappings = array(); + public $sqlResultSetMappings = []; /** * READ-ONLY: The field names of all fields that are part of the identifier/primary key @@ -337,7 +337,7 @@ class ClassMetadataInfo implements ClassMetadata * * @var array */ - public $identifier = array(); + public $identifier = []; /** * READ-ONLY: The inheritance mapping type used by the class. @@ -394,7 +394,7 @@ class ClassMetadataInfo implements ClassMetadata * * @var array */ - public $fieldMappings = array(); + public $fieldMappings = []; /** * READ-ONLY: An array of field names. Used to look up field names from column names. @@ -402,7 +402,7 @@ class ClassMetadataInfo implements ClassMetadata * * @var array */ - public $fieldNames = array(); + public $fieldNames = []; /** * READ-ONLY: A map of field names to column names. Keys are field names and values column names. @@ -413,7 +413,7 @@ class ClassMetadataInfo implements ClassMetadata * * @deprecated 3.0 Remove this. */ - public $columnNames = array(); + public $columnNames = []; /** * READ-ONLY: The discriminator value of this class. @@ -437,7 +437,7 @@ class ClassMetadataInfo implements ClassMetadata * * @see discriminatorColumn */ - public $discriminatorMap = array(); + public $discriminatorMap = []; /** * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE @@ -465,14 +465,14 @@ class ClassMetadataInfo implements ClassMetadata * * @var array[] */ - public $lifecycleCallbacks = array(); + public $lifecycleCallbacks = []; /** * READ-ONLY: The registered entity listeners. * * @var array */ - public $entityListeners = array(); + public $entityListeners = []; /** * READ-ONLY: The association mappings of this class. @@ -529,7 +529,7 @@ class ClassMetadataInfo implements ClassMetadata * * @var array */ - public $associationMappings = array(); + public $associationMappings = []; /** * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. @@ -642,7 +642,7 @@ class ClassMetadataInfo implements ClassMetadata * * @var \ReflectionProperty[] */ - public $reflFields = array(); + public $reflFields = []; /** * @var \Doctrine\Instantiator\InstantiatorInterface|null @@ -715,7 +715,7 @@ class ClassMetadataInfo implements ClassMetadata public function getIdentifierValues($entity) { if ($this->isIdentifierComposite) { - $id = array(); + $id = []; foreach ($this->identifier as $idField) { $value = $this->reflFields[$idField]->getValue($entity); @@ -732,10 +732,10 @@ class ClassMetadataInfo implements ClassMetadata $value = $this->reflFields[$id]->getValue($entity); if (null === $value) { - return array(); + return []; } - return array($id => $value); + return [$id => $value]; } /** @@ -810,7 +810,7 @@ class ClassMetadataInfo implements ClassMetadata public function __sleep() { // This metadata is always serialized/cached. - $serialized = array( + $serialized = [ 'associationMappings', 'columnNames', //TODO: 3.0 Remove this. Can use fieldMappings[$fieldName]['columnName'] 'fieldMappings', @@ -823,7 +823,7 @@ class ClassMetadataInfo implements ClassMetadata 'table', 'rootEntityName', 'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime. - ); + ]; // The rest of the metadata is only serialized if necessary. if ($this->changeTrackingPolicy != self::CHANGETRACKING_DEFERRED_IMPLICIT) { @@ -925,7 +925,7 @@ class ClassMetadataInfo implements ClassMetadata $this->reflClass = $reflService->getClass($this->name); $this->instantiator = $this->instantiator ?: new Instantiator(); - $parentReflFields = array(); + $parentReflFields = []; foreach ($this->embeddedClasses as $property => $embeddedClass) { if (isset($embeddedClass['declaredField'])) { @@ -1533,9 +1533,9 @@ class ClassMetadataInfo implements ClassMetadata } // Cascades - $cascades = isset($mapping['cascade']) ? array_map('strtolower', $mapping['cascade']) : array(); + $cascades = isset($mapping['cascade']) ? array_map('strtolower', $mapping['cascade']) : []; - $allCascades = array('remove', 'persist', 'refresh', 'merge', 'detach'); + $allCascades = ['remove', 'persist', 'refresh', 'merge', 'detach']; if (in_array('all', $cascades)) { $cascades = $allCascades; } elseif (count($cascades) !== count(array_intersect($cascades, $allCascades))) { @@ -1577,15 +1577,15 @@ class ClassMetadataInfo implements ClassMetadata if ($mapping['isOwningSide']) { if (empty($mapping['joinColumns'])) { // Apply default join column - $mapping['joinColumns'] = array( - array( + $mapping['joinColumns'] = [ + [ 'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name), 'referencedColumnName' => $this->namingStrategy->referenceColumnName() - ) - ); + ] + ]; } - $uniqueConstraintColumns = array(); + $uniqueConstraintColumns = []; foreach ($mapping['joinColumns'] as &$joinColumn) { if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { @@ -1627,9 +1627,9 @@ class ClassMetadataInfo implements ClassMetadata throw new RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship."); } - $this->table['uniqueConstraints'][$mapping['fieldName'] . "_uniq"] = array( + $this->table['uniqueConstraints'][$mapping['fieldName'] . "_uniq"] = [ 'columns' => $uniqueConstraintColumns - ); + ]; } $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']); @@ -1699,26 +1699,26 @@ class ClassMetadataInfo implements ClassMetadata && (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns']))); if ( ! isset($mapping['joinTable']['joinColumns'])) { - $mapping['joinTable']['joinColumns'] = array( - array( + $mapping['joinTable']['joinColumns'] = [ + [ 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null), 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), 'onDelete' => 'CASCADE' - ) - ); + ] + ]; } if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) { - $mapping['joinTable']['inverseJoinColumns'] = array( - array( + $mapping['joinTable']['inverseJoinColumns'] = [ + [ 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null), 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), 'onDelete' => 'CASCADE' - ) - ); + ] + ]; } - $mapping['joinTableColumns'] = array(); + $mapping['joinTableColumns'] = []; foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) { if (empty($joinColumn['name'])) { @@ -1874,7 +1874,7 @@ class ClassMetadataInfo implements ClassMetadata */ public function getIdentifierColumnNames() { - $columnNames = array(); + $columnNames = []; foreach ($this->identifier as $idProperty) { if (isset($this->fieldMappings[$idProperty])) { @@ -2411,11 +2411,11 @@ class ClassMetadataInfo implements ClassMetadata $query = $queryMapping['query']; $dql = str_replace('__CLASS__', $this->name, $query); - $this->namedQueries[$name] = array( + $this->namedQueries[$name] = [ 'name' => $name, 'query' => $query, 'dql' => $dql, - ); + ]; } /** @@ -2657,7 +2657,7 @@ class ClassMetadataInfo implements ClassMetadata */ public function getLifecycleCallbacks($event) { - return isset($this->lifecycleCallbacks[$event]) ? $this->lifecycleCallbacks[$event] : array(); + return isset($this->lifecycleCallbacks[$event]) ? $this->lifecycleCallbacks[$event] : []; } /** @@ -2703,10 +2703,10 @@ class ClassMetadataInfo implements ClassMetadata { $class = $this->fullyQualifiedClassName($class); - $listener = array( + $listener = [ 'class' => $class, 'method' => $method, - ); + ]; if ( ! class_exists($class)) { throw MappingException::entityListenerClassNotFound($class, $this->name); @@ -2753,7 +2753,7 @@ class ClassMetadataInfo implements ClassMetadata $columnDef['type'] = "string"; } - if (in_array($columnDef['type'], array("boolean", "array", "object", "datetime", "time", "date"))) { + if (in_array($columnDef['type'], ["boolean", "array", "object", "datetime", "time", "date"])) { throw MappingException::invalidDiscriminatorColumnType($this->name, $columnDef['type']); } @@ -3021,7 +3021,7 @@ class ClassMetadataInfo implements ClassMetadata $this->versionField = $mapping['fieldName']; if ( ! isset($mapping['default'])) { - if (in_array($mapping['type'], array('integer', 'bigint', 'smallint'))) { + if (in_array($mapping['type'], ['integer', 'bigint', 'smallint'])) { $mapping['default'] = 1; } else if ($mapping['type'] == 'datetime') { $mapping['default'] = 'CURRENT_TIMESTAMP'; @@ -3115,7 +3115,7 @@ class ClassMetadataInfo implements ClassMetadata */ public function getQuotedIdentifierColumnNames($platform) { - $quotedColumnNames = array(); + $quotedColumnNames = []; foreach ($this->identifier as $idProperty) { if (isset($this->fieldMappings[$idProperty])) { @@ -3217,7 +3217,7 @@ class ClassMetadataInfo implements ClassMetadata */ public function getAssociationsByTargetClass($targetClass) { - $relations = array(); + $relations = []; foreach ($this->associationMappings as $mapping) { if ($mapping['targetEntity'] == $targetClass) { @@ -3273,12 +3273,12 @@ class ClassMetadataInfo implements ClassMetadata { $this->assertFieldNotMapped($mapping['fieldName']); - $this->embeddedClasses[$mapping['fieldName']] = array( + $this->embeddedClasses[$mapping['fieldName']] = [ 'class' => $this->fullyQualifiedClassName($mapping['class']), 'columnPrefix' => $mapping['columnPrefix'], 'declaredField' => isset($mapping['declaredField']) ? $mapping['declaredField'] : null, 'originalField' => isset($mapping['originalField']) ? $mapping['originalField'] : null, - ); + ]; } /** diff --git a/lib/Doctrine/ORM/Mapping/Column.php b/lib/Doctrine/ORM/Mapping/Column.php index 70337323f..711590be6 100644 --- a/lib/Doctrine/ORM/Mapping/Column.php +++ b/lib/Doctrine/ORM/Mapping/Column.php @@ -67,7 +67,7 @@ final class Column implements Annotation /** * @var array */ - public $options = array(); + public $options = []; /** * @var string diff --git a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php b/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php index 75658547e..a8ee2dc78 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php +++ b/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php @@ -31,7 +31,7 @@ class DefaultEntityListenerResolver implements EntityListenerResolver /** * @var array Map to store entity listener instances. */ - private $instances = array(); + private $instances = []; /** * {@inheritdoc} @@ -39,7 +39,7 @@ class DefaultEntityListenerResolver implements EntityListenerResolver public function clear($className = null) { if ($className === null) { - $this->instances = array(); + $this->instances = []; return; } @@ -72,4 +72,4 @@ class DefaultEntityListenerResolver implements EntityListenerResolver return $this->instances[$className] = new $className(); } -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index dfbded8a4..6929edfe4 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -116,7 +116,7 @@ class DefaultQuoteStrategy implements QuoteStrategy */ public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform) { - $quotedColumnNames = array(); + $quotedColumnNames = []; foreach ($class->identifier as $fieldName) { if (isset($class->fieldMappings[$fieldName])) { diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 9dd64bbd3..0ed36d895 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -42,10 +42,10 @@ class AnnotationDriver extends AbstractAnnotationDriver /** * {@inheritDoc} */ - protected $entityAnnotationClasses = array( + protected $entityAnnotationClasses = [ 'Doctrine\ORM\Mapping\Entity' => 1, 'Doctrine\ORM\Mapping\MappedSuperclass' => 2, - ); + ]; /** * {@inheritDoc} @@ -97,14 +97,14 @@ class AnnotationDriver extends AbstractAnnotationDriver // Evaluate Table annotation if (isset($classAnnotations['Doctrine\ORM\Mapping\Table'])) { $tableAnnot = $classAnnotations['Doctrine\ORM\Mapping\Table']; - $primaryTable = array( + $primaryTable = [ 'name' => $tableAnnot->name, 'schema' => $tableAnnot->schema - ); + ]; if ($tableAnnot->indexes !== null) { foreach ($tableAnnot->indexes as $indexAnnot) { - $index = array('columns' => $indexAnnot->columns); + $index = ['columns' => $indexAnnot->columns]; if ( ! empty($indexAnnot->flags)) { $index['flags'] = $indexAnnot->flags; @@ -124,7 +124,7 @@ class AnnotationDriver extends AbstractAnnotationDriver if ($tableAnnot->uniqueConstraints !== null) { foreach ($tableAnnot->uniqueConstraints as $uniqueConstraintAnnot) { - $uniqueConstraint = array('columns' => $uniqueConstraintAnnot->columns); + $uniqueConstraint = ['columns' => $uniqueConstraintAnnot->columns]; if ( ! empty($uniqueConstraintAnnot->options)) { $uniqueConstraint['options'] = $uniqueConstraintAnnot->options; @@ -148,10 +148,10 @@ class AnnotationDriver extends AbstractAnnotationDriver // Evaluate @Cache annotation if (isset($classAnnotations['Doctrine\ORM\Mapping\Cache'])) { $cacheAnnot = $classAnnotations['Doctrine\ORM\Mapping\Cache']; - $cacheMap = array( + $cacheMap = [ 'region' => $cacheAnnot->region, 'usage' => constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), - ); + ]; $metadata->enableCache($cacheMap); } @@ -161,12 +161,14 @@ class AnnotationDriver extends AbstractAnnotationDriver $namedNativeQueriesAnnot = $classAnnotations['Doctrine\ORM\Mapping\NamedNativeQueries']; foreach ($namedNativeQueriesAnnot->value as $namedNativeQuery) { - $metadata->addNamedNativeQuery(array( - 'name' => $namedNativeQuery->name, - 'query' => $namedNativeQuery->query, - 'resultClass' => $namedNativeQuery->resultClass, - 'resultSetMapping' => $namedNativeQuery->resultSetMapping, - )); + $metadata->addNamedNativeQuery( + [ + 'name' => $namedNativeQuery->name, + 'query' => $namedNativeQuery->query, + 'resultClass' => $namedNativeQuery->resultClass, + 'resultSetMapping' => $namedNativeQuery->resultSetMapping, + ] + ); } } @@ -175,36 +177,38 @@ class AnnotationDriver extends AbstractAnnotationDriver $sqlResultSetMappingsAnnot = $classAnnotations['Doctrine\ORM\Mapping\SqlResultSetMappings']; foreach ($sqlResultSetMappingsAnnot->value as $resultSetMapping) { - $entities = array(); - $columns = array(); + $entities = []; + $columns = []; foreach ($resultSetMapping->entities as $entityResultAnnot) { - $entityResult = array( - 'fields' => array(), + $entityResult = [ + 'fields' => [], 'entityClass' => $entityResultAnnot->entityClass, 'discriminatorColumn' => $entityResultAnnot->discriminatorColumn, - ); + ]; foreach ($entityResultAnnot->fields as $fieldResultAnnot) { - $entityResult['fields'][] = array( + $entityResult['fields'][] = [ 'name' => $fieldResultAnnot->name, 'column' => $fieldResultAnnot->column - ); + ]; } $entities[] = $entityResult; } foreach ($resultSetMapping->columns as $columnResultAnnot) { - $columns[] = array( + $columns[] = [ 'name' => $columnResultAnnot->name, - ); + ]; } - $metadata->addSqlResultSetMapping(array( - 'name' => $resultSetMapping->name, - 'entities' => $entities, - 'columns' => $columns - )); + $metadata->addSqlResultSetMapping( + [ + 'name' => $resultSetMapping->name, + 'entities' => $entities, + 'columns' => $columns + ] + ); } } @@ -220,10 +224,12 @@ class AnnotationDriver extends AbstractAnnotationDriver if ( ! ($namedQuery instanceof \Doctrine\ORM\Mapping\NamedQuery)) { throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations."); } - $metadata->addNamedQuery(array( - 'name' => $namedQuery->name, - 'query' => $namedQuery->query - )); + $metadata->addNamedQuery( + [ + 'name' => $namedQuery->name, + 'query' => $namedQuery->query + ] + ); } } @@ -240,14 +246,16 @@ class AnnotationDriver extends AbstractAnnotationDriver if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'])) { $discrColumnAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn']; - $metadata->setDiscriminatorColumn(array( - 'name' => $discrColumnAnnot->name, - 'type' => $discrColumnAnnot->type ?: 'string', - 'length' => $discrColumnAnnot->length ?: 255, - 'columnDefinition' => $discrColumnAnnot->columnDefinition, - )); + $metadata->setDiscriminatorColumn( + [ + 'name' => $discrColumnAnnot->name, + 'type' => $discrColumnAnnot->type ?: 'string', + 'length' => $discrColumnAnnot->length ?: 255, + 'columnDefinition' => $discrColumnAnnot->columnDefinition, + ] + ); } else { - $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); + $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]); } // Evaluate DiscriminatorMap annotation @@ -278,18 +286,21 @@ class AnnotationDriver extends AbstractAnnotationDriver continue; } - $mapping = array(); + $mapping = []; $mapping['fieldName'] = $property->getName(); // Evaluate @Cache annotation if (($cacheAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Cache')) !== null) { - $mapping['cache'] = $metadata->getAssociationCacheDefaults($mapping['fieldName'], array( - 'usage' => constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), - 'region' => $cacheAnnot->region, - )); + $mapping['cache'] = $metadata->getAssociationCacheDefaults( + $mapping['fieldName'], + [ + 'usage' => constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), + 'region' => $cacheAnnot->region, + ] + ); } // Check for JoinColumn/JoinColumns annotations - $joinColumns = array(); + $joinColumns = []; if ($joinColumnAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinColumn')) { $joinColumns[] = $this->joinColumnToArray($joinColumnAnnot); @@ -324,17 +335,21 @@ class AnnotationDriver extends AbstractAnnotationDriver // Check for SequenceGenerator/TableGenerator definition if ($seqGeneratorAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\SequenceGenerator')) { - $metadata->setSequenceGeneratorDefinition(array( - 'sequenceName' => $seqGeneratorAnnot->sequenceName, - 'allocationSize' => $seqGeneratorAnnot->allocationSize, - 'initialValue' => $seqGeneratorAnnot->initialValue - )); + $metadata->setSequenceGeneratorDefinition( + [ + 'sequenceName' => $seqGeneratorAnnot->sequenceName, + 'allocationSize' => $seqGeneratorAnnot->allocationSize, + 'initialValue' => $seqGeneratorAnnot->initialValue + ] + ); } else if ($this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\TableGenerator')) { throw MappingException::tableIdGeneratorNotImplemented($className); } else if ($customGeneratorAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\CustomIdGenerator')) { - $metadata->setCustomGeneratorDefinition(array( - 'class' => $customGeneratorAnnot->class - )); + $metadata->setCustomGeneratorDefinition( + [ + 'class' => $customGeneratorAnnot->class + ] + ); } } else if ($oneToOneAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\OneToOne')) { if ($idAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Id')) { @@ -374,13 +389,13 @@ class AnnotationDriver extends AbstractAnnotationDriver $mapping['fetch'] = $this->getFetchMode($className, $manyToOneAnnot->fetch); $metadata->mapManyToOne($mapping); } else if ($manyToManyAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\ManyToMany')) { - $joinTable = array(); + $joinTable = []; if ($joinTableAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinTable')) { - $joinTable = array( + $joinTable = [ 'name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema - ); + ]; foreach ($joinTableAnnot->joinColumns as $joinColumn) { $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn); @@ -418,12 +433,12 @@ class AnnotationDriver extends AbstractAnnotationDriver $associationOverridesAnnot = $classAnnotations['Doctrine\ORM\Mapping\AssociationOverrides']; foreach ($associationOverridesAnnot->value as $associationOverride) { - $override = array(); + $override = []; $fieldName = $associationOverride->name; // Check for JoinColumn/JoinColumns annotations if ($associationOverride->joinColumns) { - $joinColumns = array(); + $joinColumns = []; foreach ($associationOverride->joinColumns as $joinColumn) { $joinColumns[] = $this->joinColumnToArray($joinColumn); @@ -435,10 +450,10 @@ class AnnotationDriver extends AbstractAnnotationDriver // Check for JoinTable annotations if ($associationOverride->joinTable) { $joinTableAnnot = $associationOverride->joinTable; - $joinTable = array( + $joinTable = [ 'name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema - ); + ]; foreach ($joinTableAnnot->joinColumns as $joinColumn) { $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn); @@ -542,40 +557,40 @@ class AnnotationDriver extends AbstractAnnotationDriver */ private function getMethodCallbacks(\ReflectionMethod $method) { - $callbacks = array(); + $callbacks = []; $annotations = $this->reader->getMethodAnnotations($method); foreach ($annotations as $annot) { if ($annot instanceof \Doctrine\ORM\Mapping\PrePersist) { - $callbacks[] = array($method->name, Events::prePersist); + $callbacks[] = [$method->name, Events::prePersist]; } if ($annot instanceof \Doctrine\ORM\Mapping\PostPersist) { - $callbacks[] = array($method->name, Events::postPersist); + $callbacks[] = [$method->name, Events::postPersist]; } if ($annot instanceof \Doctrine\ORM\Mapping\PreUpdate) { - $callbacks[] = array($method->name, Events::preUpdate); + $callbacks[] = [$method->name, Events::preUpdate]; } if ($annot instanceof \Doctrine\ORM\Mapping\PostUpdate) { - $callbacks[] = array($method->name, Events::postUpdate); + $callbacks[] = [$method->name, Events::postUpdate]; } if ($annot instanceof \Doctrine\ORM\Mapping\PreRemove) { - $callbacks[] = array($method->name, Events::preRemove); + $callbacks[] = [$method->name, Events::preRemove]; } if ($annot instanceof \Doctrine\ORM\Mapping\PostRemove) { - $callbacks[] = array($method->name, Events::postRemove); + $callbacks[] = [$method->name, Events::postRemove]; } if ($annot instanceof \Doctrine\ORM\Mapping\PostLoad) { - $callbacks[] = array($method->name, Events::postLoad); + $callbacks[] = [$method->name, Events::postLoad]; } if ($annot instanceof \Doctrine\ORM\Mapping\PreFlush) { - $callbacks[] = array($method->name, Events::preFlush); + $callbacks[] = [$method->name, Events::preFlush]; } } @@ -590,14 +605,14 @@ class AnnotationDriver extends AbstractAnnotationDriver */ private function joinColumnToArray(JoinColumn $joinColumn) { - return array( + return [ 'name' => $joinColumn->name, 'unique' => $joinColumn->unique, 'nullable' => $joinColumn->nullable, 'onDelete' => $joinColumn->onDelete, 'columnDefinition' => $joinColumn->columnDefinition, 'referencedColumnName' => $joinColumn->referencedColumnName, - ); + ]; } /** @@ -610,7 +625,7 @@ class AnnotationDriver extends AbstractAnnotationDriver */ private function columnToArray($fieldName, Column $column) { - $mapping = array( + $mapping = [ 'fieldName' => $fieldName, 'type' => $column->type, 'scale' => $column->scale, @@ -618,7 +633,7 @@ class AnnotationDriver extends AbstractAnnotationDriver 'unique' => $column->unique, 'nullable' => $column->nullable, 'precision' => $column->precision - ); + ]; if ($column->options) { $mapping['options'] = $column->options; @@ -643,7 +658,7 @@ class AnnotationDriver extends AbstractAnnotationDriver * * @return AnnotationDriver */ - static public function create($paths = array(), AnnotationReader $reader = null) + static public function create($paths = [], AnnotationReader $reader = null) { if ($reader == null) { $reader = new AnnotationReader(); diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index d6ddaf2d0..9389feb81 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -54,22 +54,22 @@ class DatabaseDriver implements MappingDriver /** * @var array */ - private $classToTableNames = array(); + private $classToTableNames = []; /** * @var array */ - private $manyToManyTables = array(); + private $manyToManyTables = []; /** * @var array */ - private $classNamesForTables = array(); + private $classNamesForTables = []; /** * @var array */ - private $fieldNamesForColumns = array(); + private $fieldNamesForColumns = []; /** * The namespace for the generated entities. @@ -153,7 +153,7 @@ class DatabaseDriver implements MappingDriver */ public function setTables($entityTables, $manyToManyTables) { - $this->tables = $this->manyToManyTables = $this->classToTableNames = array(); + $this->tables = $this->manyToManyTables = $this->classToTableNames = []; foreach ($entityTables as $table) { $className = $this->getClassNameForTable($table->getName()); @@ -212,36 +212,36 @@ class DatabaseDriver implements MappingDriver $localColumn = current($myFk->getColumns()); - $associationMapping = array(); + $associationMapping = []; $associationMapping['fieldName'] = $this->getFieldNameForColumn($manyTable->getName(), current($otherFk->getColumns()), true); $associationMapping['targetEntity'] = $this->getClassNameForTable($otherFk->getForeignTableName()); if (current($manyTable->getColumns())->getName() == $localColumn) { $associationMapping['inversedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true); - $associationMapping['joinTable'] = array( + $associationMapping['joinTable'] = [ 'name' => strtolower($manyTable->getName()), - 'joinColumns' => array(), - 'inverseJoinColumns' => array(), - ); + 'joinColumns' => [], + 'inverseJoinColumns' => [], + ]; $fkCols = $myFk->getForeignColumns(); $cols = $myFk->getColumns(); for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) { - $associationMapping['joinTable']['joinColumns'][] = array( + $associationMapping['joinTable']['joinColumns'][] = [ 'name' => $cols[$i], 'referencedColumnName' => $fkCols[$i], - ); + ]; } $fkCols = $otherFk->getForeignColumns(); $cols = $otherFk->getColumns(); for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) { - $associationMapping['joinTable']['inverseJoinColumns'][] = array( + $associationMapping['joinTable']['inverseJoinColumns'][] = [ 'name' => $cols[$i], 'referencedColumnName' => $fkCols[$i], - ); + ]; } } else { $associationMapping['mappedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true); @@ -265,20 +265,20 @@ class DatabaseDriver implements MappingDriver return; } - $tables = array(); + $tables = []; foreach ($this->_sm->listTableNames() as $tableName) { $tables[$tableName] = $this->_sm->listTableDetails($tableName); } - $this->tables = $this->manyToManyTables = $this->classToTableNames = array(); + $this->tables = $this->manyToManyTables = $this->classToTableNames = []; foreach ($tables as $tableName => $table) { $foreignKeys = ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) ? $table->getForeignKeys() - : array(); + : []; - $allForeignKeyColumns = array(); + $allForeignKeyColumns = []; foreach ($foreignKeys as $foreignKey) { $allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns()); @@ -345,14 +345,14 @@ class DatabaseDriver implements MappingDriver $columns = $this->tables[$tableName]->getColumns(); $primaryKeys = $this->getTablePrimaryKeys($this->tables[$tableName]); $foreignKeys = $this->getTableForeignKeys($this->tables[$tableName]); - $allForeignKeys = array(); + $allForeignKeys = []; foreach ($foreignKeys as $foreignKey) { $allForeignKeys = array_merge($allForeignKeys, $foreignKey->getLocalColumns()); } - $ids = array(); - $fieldMappings = array(); + $ids = []; + $fieldMappings = []; foreach ($columns as $column) { if (in_array($column->getName(), $allForeignKeys)) { @@ -389,12 +389,12 @@ class DatabaseDriver implements MappingDriver */ private function buildFieldMapping($tableName, Column $column) { - $fieldMapping = array( + $fieldMapping = [ 'fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false), 'columnName' => $column->getName(), 'type' => $column->getType()->getName(), 'nullable' => ( ! $column->getNotNull()), - ); + ]; // Type specific elements switch ($fieldMapping['type']) { @@ -452,10 +452,10 @@ class DatabaseDriver implements MappingDriver $fkColumns = $foreignKey->getColumns(); $fkForeignColumns = $foreignKey->getForeignColumns(); $localColumn = current($fkColumns); - $associationMapping = array( + $associationMapping = [ 'fieldName' => $this->getFieldNameForColumn($tableName, $localColumn, true), 'targetEntity' => $this->getClassNameForTable($foreignTableName), - ); + ]; if (isset($metadata->fieldMappings[$associationMapping['fieldName']])) { $associationMapping['fieldName'] .= '2'; // "foo" => "foo2" @@ -466,10 +466,10 @@ class DatabaseDriver implements MappingDriver } for ($i = 0, $fkColumnsCount = count($fkColumns); $i < $fkColumnsCount; $i++) { - $associationMapping['joinColumns'][] = array( + $associationMapping['joinColumns'][] = [ 'name' => $fkColumns[$i], 'referencedColumnName' => $fkForeignColumns[$i], - ); + ]; } // Here we need to check if $fkColumns are the same as $primaryKeys @@ -492,7 +492,7 @@ class DatabaseDriver implements MappingDriver { return ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) ? $table->getForeignKeys() - : array(); + : []; } /** @@ -510,7 +510,7 @@ class DatabaseDriver implements MappingDriver // Do nothing } - return array(); + return []; } /** diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 3d8499180..d7099663f 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -76,7 +76,7 @@ class XmlDriver extends FileDriver } // Evaluate attributes - $primaryTable = array(); + $primaryTable = []; if (isset($xmlRoot['table'])) { $primaryTable['name'] = (string) $xmlRoot['table']; @@ -96,44 +96,48 @@ class XmlDriver extends FileDriver // Evaluate named queries if (isset($xmlRoot->{'named-queries'})) { foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) { - $metadata->addNamedQuery(array( - 'name' => (string) $namedQueryElement['name'], - 'query' => (string) $namedQueryElement['query'] - )); + $metadata->addNamedQuery( + [ + 'name' => (string) $namedQueryElement['name'], + 'query' => (string) $namedQueryElement['query'] + ] + ); } } // Evaluate native named queries if (isset($xmlRoot->{'named-native-queries'})) { foreach ($xmlRoot->{'named-native-queries'}->{'named-native-query'} as $nativeQueryElement) { - $metadata->addNamedNativeQuery(array( - 'name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null, - 'query' => isset($nativeQueryElement->query) ? (string) $nativeQueryElement->query : null, - 'resultClass' => isset($nativeQueryElement['result-class']) ? (string) $nativeQueryElement['result-class'] : null, - 'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string) $nativeQueryElement['result-set-mapping'] : null, - )); + $metadata->addNamedNativeQuery( + [ + 'name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null, + 'query' => isset($nativeQueryElement->query) ? (string) $nativeQueryElement->query : null, + 'resultClass' => isset($nativeQueryElement['result-class']) ? (string) $nativeQueryElement['result-class'] : null, + 'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string) $nativeQueryElement['result-set-mapping'] : null, + ] + ); } } // Evaluate sql result set mapping if (isset($xmlRoot->{'sql-result-set-mappings'})) { foreach ($xmlRoot->{'sql-result-set-mappings'}->{'sql-result-set-mapping'} as $rsmElement) { - $entities = array(); - $columns = array(); + $entities = []; + $columns = []; foreach ($rsmElement as $entityElement) { // if (isset($entityElement['entity-class'])) { - $entityResult = array( - 'fields' => array(), + $entityResult = [ + 'fields' => [], 'entityClass' => (string) $entityElement['entity-class'], 'discriminatorColumn' => isset($entityElement['discriminator-column']) ? (string) $entityElement['discriminator-column'] : null, - ); + ]; foreach ($entityElement as $fieldElement) { - $entityResult['fields'][] = array( + $entityResult['fields'][] = [ 'name' => isset($fieldElement['name']) ? (string) $fieldElement['name'] : null, 'column' => isset($fieldElement['column']) ? (string) $fieldElement['column'] : null, - ); + ]; } $entities[] = $entityResult; @@ -141,17 +145,19 @@ class XmlDriver extends FileDriver // if (isset($entityElement['name'])) { - $columns[] = array( + $columns[] = [ 'name' => (string) $entityElement['name'], - ); + ]; } } - $metadata->addSqlResultSetMapping(array( - 'name' => (string) $rsmElement['name'], - 'entities' => $entities, - 'columns' => $columns - )); + $metadata->addSqlResultSetMapping( + [ + 'name' => (string) $rsmElement['name'], + 'entities' => $entities, + 'columns' => $columns + ] + ); } } @@ -163,19 +169,21 @@ class XmlDriver extends FileDriver // Evaluate if (isset($xmlRoot->{'discriminator-column'})) { $discrColumn = $xmlRoot->{'discriminator-column'}; - $metadata->setDiscriminatorColumn(array( - 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, - 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string', - 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255, - 'columnDefinition' => isset($discrColumn['column-definition']) ? (string) $discrColumn['column-definition'] : null - )); + $metadata->setDiscriminatorColumn( + [ + 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, + 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string', + 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255, + 'columnDefinition' => isset($discrColumn['column-definition']) ? (string) $discrColumn['column-definition'] : null + ] + ); } else { - $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); + $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]); } // Evaluate if (isset($xmlRoot->{'discriminator-map'})) { - $map = array(); + $map = []; foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} as $discrMapElement) { $map[(string) $discrMapElement['value']] = (string) $discrMapElement['class']; } @@ -193,9 +201,9 @@ class XmlDriver extends FileDriver // Evaluate if (isset($xmlRoot->indexes)) { - $metadata->table['indexes'] = array(); + $metadata->table['indexes'] = []; foreach ($xmlRoot->indexes->index as $indexXml) { - $index = array('columns' => explode(',', (string) $indexXml['columns'])); + $index = ['columns' => explode(',', (string) $indexXml['columns'])]; if (isset($indexXml['flags'])) { $index['flags'] = explode(',', (string) $indexXml['flags']); @@ -215,10 +223,9 @@ class XmlDriver extends FileDriver // Evaluate if (isset($xmlRoot->{'unique-constraints'})) { - $metadata->table['uniqueConstraints'] = array(); + $metadata->table['uniqueConstraints'] = []; foreach ($xmlRoot->{'unique-constraints'}->{'unique-constraint'} as $uniqueXml) { - $unique = array('columns' => explode(',', (string) $uniqueXml['columns'])); - + $unique = ['columns' => explode(',', (string) $uniqueXml['columns'])]; if (isset($uniqueXml->options)) { $unique['options'] = $this->_parseOptions($uniqueXml->options->children()); @@ -238,7 +245,7 @@ class XmlDriver extends FileDriver // The mapping assignment is done in 2 times as a bug might occurs on some php/xml lib versions // The internal SimpleXmlIterator get resetted, to this generate a duplicate field exception - $mappings = array(); + $mappings = []; // Evaluate mappings if (isset($xmlRoot->field)) { foreach ($xmlRoot->field as $fieldMapping) { @@ -263,11 +270,11 @@ class XmlDriver extends FileDriver ? $this->evaluateBoolean($embeddedMapping['use-column-prefix']) : true; - $mapping = array( + $mapping = [ 'fieldName' => (string) $embeddedMapping['name'], 'class' => (string) $embeddedMapping['class'], 'columnPrefix' => $useColumnPrefix ? $columnPrefix : false - ); + ]; $metadata->mapEmbedded($mapping); } @@ -282,17 +289,17 @@ class XmlDriver extends FileDriver } // Evaluate mappings - $associationIds = array(); + $associationIds = []; foreach ($xmlRoot->id as $idElement) { if (isset($idElement['association-key']) && $this->evaluateBoolean($idElement['association-key'])) { $associationIds[(string) $idElement['name']] = true; continue; } - $mapping = array( + $mapping = [ 'id' => true, 'fieldName' => (string) $idElement['name'] - ); + ]; if (isset($idElement['type'])) { $mapping['type'] = (string) $idElement['type']; @@ -326,16 +333,20 @@ class XmlDriver extends FileDriver // Check for SequenceGenerator/TableGenerator definition if (isset($idElement->{'sequence-generator'})) { $seqGenerator = $idElement->{'sequence-generator'}; - $metadata->setSequenceGeneratorDefinition(array( - 'sequenceName' => (string) $seqGenerator['sequence-name'], - 'allocationSize' => (string) $seqGenerator['allocation-size'], - 'initialValue' => (string) $seqGenerator['initial-value'] - )); + $metadata->setSequenceGeneratorDefinition( + [ + 'sequenceName' => (string) $seqGenerator['sequence-name'], + 'allocationSize' => (string) $seqGenerator['allocation-size'], + 'initialValue' => (string) $seqGenerator['initial-value'] + ] + ); } else if (isset($idElement->{'custom-id-generator'})) { $customGenerator = $idElement->{'custom-id-generator'}; - $metadata->setCustomGeneratorDefinition(array( - 'class' => (string) $customGenerator['class'] - )); + $metadata->setCustomGeneratorDefinition( + [ + 'class' => (string) $customGenerator['class'] + ] + ); } else if (isset($idElement->{'table-generator'})) { throw MappingException::tableIdGeneratorNotImplemented($className); } @@ -344,10 +355,10 @@ class XmlDriver extends FileDriver // Evaluate mappings if (isset($xmlRoot->{'one-to-one'})) { foreach ($xmlRoot->{'one-to-one'} as $oneToOneElement) { - $mapping = array( + $mapping = [ 'fieldName' => (string) $oneToOneElement['field'], 'targetEntity' => (string) $oneToOneElement['target-entity'] - ); + ]; if (isset($associationIds[$mapping['fieldName']])) { $mapping['id'] = true; @@ -363,7 +374,7 @@ class XmlDriver extends FileDriver if (isset($oneToOneElement['inversed-by'])) { $mapping['inversedBy'] = (string) $oneToOneElement['inversed-by']; } - $joinColumns = array(); + $joinColumns = []; if (isset($oneToOneElement->{'join-column'})) { $joinColumns[] = $this->joinColumnToArray($oneToOneElement->{'join-column'}); @@ -396,11 +407,11 @@ class XmlDriver extends FileDriver // Evaluate mappings if (isset($xmlRoot->{'one-to-many'})) { foreach ($xmlRoot->{'one-to-many'} as $oneToManyElement) { - $mapping = array( + $mapping = [ 'fieldName' => (string) $oneToManyElement['field'], 'targetEntity' => (string) $oneToManyElement['target-entity'], 'mappedBy' => (string) $oneToManyElement['mapped-by'] - ); + ]; if (isset($oneToManyElement['fetch'])) { $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string) $oneToManyElement['fetch']); @@ -415,7 +426,7 @@ class XmlDriver extends FileDriver } if (isset($oneToManyElement->{'order-by'})) { - $orderBy = array(); + $orderBy = []; foreach ($oneToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) { $orderBy[(string) $orderByField['name']] = (string) $orderByField['direction']; } @@ -440,10 +451,10 @@ class XmlDriver extends FileDriver // Evaluate mappings if (isset($xmlRoot->{'many-to-one'})) { foreach ($xmlRoot->{'many-to-one'} as $manyToOneElement) { - $mapping = array( + $mapping = [ 'fieldName' => (string) $manyToOneElement['field'], 'targetEntity' => (string) $manyToOneElement['target-entity'] - ); + ]; if (isset($associationIds[$mapping['fieldName']])) { $mapping['id'] = true; @@ -457,7 +468,7 @@ class XmlDriver extends FileDriver $mapping['inversedBy'] = (string) $manyToOneElement['inversed-by']; } - $joinColumns = array(); + $joinColumns = []; if (isset($manyToOneElement->{'join-column'})) { $joinColumns[] = $this->joinColumnToArray($manyToOneElement->{'join-column'}); @@ -486,10 +497,10 @@ class XmlDriver extends FileDriver // Evaluate mappings if (isset($xmlRoot->{'many-to-many'})) { foreach ($xmlRoot->{'many-to-many'} as $manyToManyElement) { - $mapping = array( + $mapping = [ 'fieldName' => (string) $manyToManyElement['field'], 'targetEntity' => (string) $manyToManyElement['target-entity'] - ); + ]; if (isset($manyToManyElement['fetch'])) { $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string) $manyToManyElement['fetch']); @@ -507,9 +518,9 @@ class XmlDriver extends FileDriver } $joinTableElement = $manyToManyElement->{'join-table'}; - $joinTable = array( + $joinTable = [ 'name' => (string) $joinTableElement['name'] - ); + ]; if (isset($joinTableElement['schema'])) { $joinTable['schema'] = (string) $joinTableElement['schema']; @@ -531,7 +542,7 @@ class XmlDriver extends FileDriver } if (isset($manyToManyElement->{'order-by'})) { - $orderBy = array(); + $orderBy = []; foreach ($manyToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) { $orderBy[(string) $orderByField['name']] = (string) $orderByField['direction']; } @@ -569,11 +580,11 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'association-overrides'})) { foreach ($xmlRoot->{'association-overrides'}->{'association-override'} as $overrideElement) { $fieldName = (string) $overrideElement['name']; - $override = array(); + $override = []; // Check for join-columns if (isset($overrideElement->{'join-columns'})) { - $joinColumns = array(); + $joinColumns = []; foreach ($overrideElement->{'join-columns'}->{'join-column'} as $joinColumnElement) { $joinColumns[] = $this->joinColumnToArray($joinColumnElement); } @@ -585,10 +596,10 @@ class XmlDriver extends FileDriver $joinTable = null; $joinTableElement = $overrideElement->{'join-table'}; - $joinTable = array( + $joinTable = [ 'name' => (string) $joinTableElement['name'], 'schema' => (string) $joinTableElement['schema'] - ); + ]; if (isset($joinTableElement->{'join-columns'})) { foreach ($joinTableElement->{'join-columns'}->{'join-column'} as $joinColumnElement) { @@ -651,7 +662,7 @@ class XmlDriver extends FileDriver */ private function _parseOptions(SimpleXMLElement $options) { - $array = array(); + $array = []; /* @var $option SimpleXMLElement */ foreach ($options as $option) { @@ -686,10 +697,10 @@ class XmlDriver extends FileDriver */ private function joinColumnToArray(SimpleXMLElement $joinColumnElement) { - $joinColumn = array( + $joinColumn = [ 'name' => (string) $joinColumnElement['name'], 'referencedColumnName' => (string) $joinColumnElement['referenced-column-name'] - ); + ]; if (isset($joinColumnElement['unique'])) { $joinColumn['unique'] = $this->evaluateBoolean($joinColumnElement['unique']); @@ -719,9 +730,9 @@ class XmlDriver extends FileDriver */ private function columnToArray(SimpleXMLElement $fieldMapping) { - $mapping = array( + $mapping = [ 'fieldName' => (string) $fieldMapping['name'], - ); + ]; if (isset($fieldMapping['type'])) { $mapping['type'] = (string) $fieldMapping['type']; @@ -786,10 +797,10 @@ class XmlDriver extends FileDriver $usage = constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $usage); } - return array( + return [ 'usage' => $usage, 'region' => $region, - ); + ]; } /** @@ -801,7 +812,7 @@ class XmlDriver extends FileDriver */ private function _getCascadeMappings(SimpleXMLElement $cascadeElement) { - $cascades = array(); + $cascades = []; /* @var $action SimpleXmlElement */ foreach ($cascadeElement->children() as $action) { // According to the JPA specifications, XML uses "cascade-persist" @@ -820,7 +831,7 @@ class XmlDriver extends FileDriver */ protected function loadMappingFile($file) { - $result = array(); + $result = []; $xmlElement = simplexml_load_file($file); if (isset($xmlElement->entity)) { diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php index fe406785f..8793c070b 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -73,7 +73,7 @@ class YamlDriver extends FileDriver } // Evaluate root level properties - $primaryTable = array(); + $primaryTable = []; if (isset($element['table'])) { $primaryTable['name'] = $element['table']; @@ -94,7 +94,7 @@ class YamlDriver extends FileDriver if (isset($element['namedQueries'])) { foreach ($element['namedQueries'] as $name => $queryMapping) { if (is_string($queryMapping)) { - $queryMapping = array('query' => $queryMapping); + $queryMapping = ['query' => $queryMapping]; } if ( ! isset($queryMapping['name'])) { @@ -111,12 +111,14 @@ class YamlDriver extends FileDriver if (!isset($mappingElement['name'])) { $mappingElement['name'] = $name; } - $metadata->addNamedNativeQuery(array( - 'name' => $mappingElement['name'], - 'query' => isset($mappingElement['query']) ? $mappingElement['query'] : null, - 'resultClass' => isset($mappingElement['resultClass']) ? $mappingElement['resultClass'] : null, - 'resultSetMapping' => isset($mappingElement['resultSetMapping']) ? $mappingElement['resultSetMapping'] : null, - )); + $metadata->addNamedNativeQuery( + [ + 'name' => $mappingElement['name'], + 'query' => isset($mappingElement['query']) ? $mappingElement['query'] : null, + 'resultClass' => isset($mappingElement['resultClass']) ? $mappingElement['resultClass'] : null, + 'resultSetMapping' => isset($mappingElement['resultSetMapping']) ? $mappingElement['resultSetMapping'] : null, + ] + ); } } @@ -127,22 +129,22 @@ class YamlDriver extends FileDriver $resultSetMapping['name'] = $name; } - $entities = array(); - $columns = array(); + $entities = []; + $columns = []; if (isset($resultSetMapping['entityResult'])) { foreach ($resultSetMapping['entityResult'] as $entityResultElement) { - $entityResult = array( - 'fields' => array(), + $entityResult = [ + 'fields' => [], 'entityClass' => isset($entityResultElement['entityClass']) ? $entityResultElement['entityClass'] : null, 'discriminatorColumn' => isset($entityResultElement['discriminatorColumn']) ? $entityResultElement['discriminatorColumn'] : null, - ); + ]; if (isset($entityResultElement['fieldResult'])) { foreach ($entityResultElement['fieldResult'] as $fieldResultElement) { - $entityResult['fields'][] = array( + $entityResult['fields'][] = [ 'name' => isset($fieldResultElement['name']) ? $fieldResultElement['name'] : null, 'column' => isset($fieldResultElement['column']) ? $fieldResultElement['column'] : null, - ); + ]; } } @@ -153,17 +155,19 @@ class YamlDriver extends FileDriver if (isset($resultSetMapping['columnResult'])) { foreach ($resultSetMapping['columnResult'] as $columnResultAnnot) { - $columns[] = array( + $columns[] = [ 'name' => isset($columnResultAnnot['name']) ? $columnResultAnnot['name'] : null, - ); + ]; } } - $metadata->addSqlResultSetMapping(array( - 'name' => $resultSetMapping['name'], - 'entities' => $entities, - 'columns' => $columns - )); + $metadata->addSqlResultSetMapping( + [ + 'name' => $resultSetMapping['name'], + 'entities' => $entities, + 'columns' => $columns + ] + ); } } @@ -174,14 +178,16 @@ class YamlDriver extends FileDriver // Evaluate discriminatorColumn if (isset($element['discriminatorColumn'])) { $discrColumn = $element['discriminatorColumn']; - $metadata->setDiscriminatorColumn(array( - 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, - 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string', - 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255, - 'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string) $discrColumn['columnDefinition'] : null - )); + $metadata->setDiscriminatorColumn( + [ + 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, + 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string', + 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255, + 'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string) $discrColumn['columnDefinition'] : null + ] + ); } else { - $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); + $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]); } // Evaluate discriminatorMap @@ -206,9 +212,9 @@ class YamlDriver extends FileDriver } if (is_string($indexYml['columns'])) { - $index = array('columns' => array_map('trim', explode(',', $indexYml['columns']))); + $index = ['columns' => array_map('trim', explode(',', $indexYml['columns']))]; } else { - $index = array('columns' => $indexYml['columns']); + $index = ['columns' => $indexYml['columns']]; } if (isset($indexYml['flags'])) { @@ -235,9 +241,9 @@ class YamlDriver extends FileDriver } if (is_string($uniqueYml['columns'])) { - $unique = array('columns' => array_map('trim', explode(',', $uniqueYml['columns']))); + $unique = ['columns' => array_map('trim', explode(',', $uniqueYml['columns']))]; } else { - $unique = array('columns' => $uniqueYml['columns']); + $unique = ['columns' => $uniqueYml['columns']]; } if (isset($uniqueYml['options'])) { @@ -252,7 +258,7 @@ class YamlDriver extends FileDriver $metadata->table['options'] = $element['options']; } - $associationIds = array(); + $associationIds = []; if (isset($element['id'])) { // Evaluate identifier settings foreach ($element['id'] as $name => $idElement) { @@ -261,10 +267,10 @@ class YamlDriver extends FileDriver continue; } - $mapping = array( + $mapping = [ 'id' => true, 'fieldName' => $name - ); + ]; if (isset($idElement['type'])) { $mapping['type'] = $idElement['type']; @@ -297,9 +303,11 @@ class YamlDriver extends FileDriver $metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']); } else if (isset($idElement['customIdGenerator'])) { $customGenerator = $idElement['customIdGenerator']; - $metadata->setCustomGeneratorDefinition(array( - 'class' => (string) $customGenerator['class'] - )); + $metadata->setCustomGeneratorDefinition( + [ + 'class' => (string) $customGenerator['class'] + ] + ); } else if (isset($idElement['tableGenerator'])) { throw MappingException::tableIdGeneratorNotImplemented($className); } @@ -331,11 +339,11 @@ class YamlDriver extends FileDriver if (isset($element['embedded'])) { foreach ($element['embedded'] as $name => $embeddedMapping) { - $mapping = array( + $mapping = [ 'fieldName' => $name, 'class' => $embeddedMapping['class'], 'columnPrefix' => isset($embeddedMapping['columnPrefix']) ? $embeddedMapping['columnPrefix'] : null, - ); + ]; $metadata->mapEmbedded($mapping); } } @@ -343,10 +351,10 @@ class YamlDriver extends FileDriver // Evaluate oneToOne relationships if (isset($element['oneToOne'])) { foreach ($element['oneToOne'] as $name => $oneToOneElement) { - $mapping = array( + $mapping = [ 'fieldName' => $name, 'targetEntity' => $oneToOneElement['targetEntity'] - ); + ]; if (isset($associationIds[$mapping['fieldName']])) { $mapping['id'] = true; @@ -363,7 +371,7 @@ class YamlDriver extends FileDriver $mapping['inversedBy'] = $oneToOneElement['inversedBy']; } - $joinColumns = array(); + $joinColumns = []; if (isset($oneToOneElement['joinColumn'])) { $joinColumns[] = $this->joinColumnToArray($oneToOneElement['joinColumn']); @@ -400,11 +408,11 @@ class YamlDriver extends FileDriver // Evaluate oneToMany relationships if (isset($element['oneToMany'])) { foreach ($element['oneToMany'] as $name => $oneToManyElement) { - $mapping = array( + $mapping = [ 'fieldName' => $name, 'targetEntity' => $oneToManyElement['targetEntity'], 'mappedBy' => $oneToManyElement['mappedBy'] - ); + ]; if (isset($oneToManyElement['fetch'])) { $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $oneToManyElement['fetch']); @@ -439,10 +447,10 @@ class YamlDriver extends FileDriver // Evaluate manyToOne relationships if (isset($element['manyToOne'])) { foreach ($element['manyToOne'] as $name => $manyToOneElement) { - $mapping = array( + $mapping = [ 'fieldName' => $name, 'targetEntity' => $manyToOneElement['targetEntity'] - ); + ]; if (isset($associationIds[$mapping['fieldName']])) { $mapping['id'] = true; @@ -456,7 +464,7 @@ class YamlDriver extends FileDriver $mapping['inversedBy'] = $manyToOneElement['inversedBy']; } - $joinColumns = array(); + $joinColumns = []; if (isset($manyToOneElement['joinColumn'])) { $joinColumns[] = $this->joinColumnToArray($manyToOneElement['joinColumn']); @@ -488,10 +496,10 @@ class YamlDriver extends FileDriver // Evaluate manyToMany relationships if (isset($element['manyToMany'])) { foreach ($element['manyToMany'] as $name => $manyToManyElement) { - $mapping = array( + $mapping = [ 'fieldName' => $name, 'targetEntity' => $manyToManyElement['targetEntity'] - ); + ]; if (isset($manyToManyElement['fetch'])) { $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $manyToManyElement['fetch']); @@ -502,9 +510,9 @@ class YamlDriver extends FileDriver } else if (isset($manyToManyElement['joinTable'])) { $joinTableElement = $manyToManyElement['joinTable']; - $joinTable = array( + $joinTable = [ 'name' => $joinTableElement['name'] - ); + ]; if (isset($joinTableElement['schema'])) { $joinTable['schema'] = $joinTableElement['schema']; @@ -564,11 +572,11 @@ class YamlDriver extends FileDriver if (isset($element['associationOverride']) && is_array($element['associationOverride'])) { foreach ($element['associationOverride'] as $fieldName => $associationOverrideElement) { - $override = array(); + $override = []; // Check for joinColumn if (isset($associationOverrideElement['joinColumn'])) { - $joinColumns = array(); + $joinColumns = []; foreach ($associationOverrideElement['joinColumn'] as $name => $joinColumnElement) { if ( ! isset($joinColumnElement['name'])) { $joinColumnElement['name'] = $name; @@ -582,9 +590,9 @@ class YamlDriver extends FileDriver if (isset($associationOverrideElement['joinTable'])) { $joinTableElement = $associationOverrideElement['joinTable']; - $joinTable = array( + $joinTable = [ 'name' => $joinTableElement['name'] - ); + ]; if (isset($joinTableElement['schema'])) { $joinTable['schema'] = $joinTableElement['schema']; @@ -665,7 +673,7 @@ class YamlDriver extends FileDriver */ private function joinColumnToArray($joinColumnElement) { - $joinColumn = array(); + $joinColumn = []; if (isset($joinColumnElement['referencedColumnName'])) { $joinColumn['referencedColumnName'] = (string) $joinColumnElement['referencedColumnName']; } @@ -707,9 +715,9 @@ class YamlDriver extends FileDriver */ private function columnToArray($fieldName, $column) { - $mapping = array( + $mapping = [ 'fieldName' => $fieldName - ); + ]; if (isset($column['type'])) { $params = explode('(', $column['type']); @@ -781,10 +789,10 @@ class YamlDriver extends FileDriver $usage = constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $usage); } - return array( + return [ 'usage' => $usage, 'region' => $region, - ); + ]; } /** diff --git a/lib/Doctrine/ORM/Mapping/EntityListeners.php b/lib/Doctrine/ORM/Mapping/EntityListeners.php index d9478a497..ae6c9126b 100644 --- a/lib/Doctrine/ORM/Mapping/EntityListeners.php +++ b/lib/Doctrine/ORM/Mapping/EntityListeners.php @@ -37,5 +37,5 @@ final class EntityListeners implements Annotation * * @var array */ - public $value = array(); -} \ No newline at end of file + public $value = []; +} diff --git a/lib/Doctrine/ORM/Mapping/EntityResult.php b/lib/Doctrine/ORM/Mapping/EntityResult.php index 63bbed22f..d8b05730a 100644 --- a/lib/Doctrine/ORM/Mapping/EntityResult.php +++ b/lib/Doctrine/ORM/Mapping/EntityResult.php @@ -45,7 +45,7 @@ final class EntityResult implements Annotation * * @var array<\Doctrine\ORM\Mapping\FieldResult> */ - public $fields = array(); + public $fields = []; /** * Specifies the column name of the column in the SELECT list that is used to determine the type of the entity instance. diff --git a/lib/Doctrine/ORM/Mapping/JoinTable.php b/lib/Doctrine/ORM/Mapping/JoinTable.php index 8a440c614..879316a28 100644 --- a/lib/Doctrine/ORM/Mapping/JoinTable.php +++ b/lib/Doctrine/ORM/Mapping/JoinTable.php @@ -38,10 +38,10 @@ final class JoinTable implements Annotation /** * @var array<\Doctrine\ORM\Mapping\JoinColumn> */ - public $joinColumns = array(); + public $joinColumns = []; /** * @var array<\Doctrine\ORM\Mapping\JoinColumn> */ - public $inverseJoinColumns = array(); + public $inverseJoinColumns = []; } diff --git a/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php b/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php index 7f5460a81..2539107af 100644 --- a/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php +++ b/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php @@ -25,7 +25,7 @@ namespace Doctrine\ORM\Mapping; * * @author Fabio B. Silva * @since 2.3 - * + * * @Annotation * @Target("CLASS") */ @@ -36,5 +36,5 @@ final class NamedNativeQueries implements Annotation * * @var array<\Doctrine\ORM\Mapping\NamedNativeQuery> */ - public $value = array(); + public $value = []; } diff --git a/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php b/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php index f5ead7c0f..cb78c9a40 100644 --- a/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php +++ b/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php @@ -33,22 +33,22 @@ final class SqlResultSetMapping implements Annotation { /** * The name given to the result set mapping, and used to refer to it in the methods of the Query API. - * + * * @var string */ public $name; /** * Specifies the result set mapping to entities. - * + * * @var array<\Doctrine\ORM\Mapping\EntityResult> */ - public $entities = array(); + public $entities = []; /** * Specifies the result set mapping to scalar values. * * @var array<\Doctrine\ORM\Mapping\ColumnResult> */ - public $columns = array(); + public $columns = []; } diff --git a/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php b/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php index c21b2ab82..0b74f2d95 100644 --- a/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php +++ b/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php @@ -25,7 +25,7 @@ namespace Doctrine\ORM\Mapping; * * @author Fabio B. Silva * @since 2.3 - * + * * @Annotation * @Target("CLASS") */ @@ -36,5 +36,5 @@ final class SqlResultSetMappings implements Annotation * * @var array<\Doctrine\ORM\Mapping\SqlResultSetMapping> */ - public $value = array(); + public $value = []; } diff --git a/lib/Doctrine/ORM/Mapping/Table.php b/lib/Doctrine/ORM/Mapping/Table.php index f9f8d4a65..6ed703750 100644 --- a/lib/Doctrine/ORM/Mapping/Table.php +++ b/lib/Doctrine/ORM/Mapping/Table.php @@ -48,5 +48,5 @@ final class Table implements Annotation /** * @var array */ - public $options = array(); + public $options = []; } diff --git a/lib/Doctrine/ORM/NativeQuery.php b/lib/Doctrine/ORM/NativeQuery.php index b19f81805..ddc5418d6 100644 --- a/lib/Doctrine/ORM/NativeQuery.php +++ b/lib/Doctrine/ORM/NativeQuery.php @@ -63,8 +63,8 @@ final class NativeQuery extends AbstractQuery */ protected function _doExecute() { - $parameters = array(); - $types = array(); + $parameters = []; + $types = []; foreach ($this->getParameters() as $parameter) { $name = $parameter->getName(); diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index b5948149a..11205df04 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -49,7 +49,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec * * @var array */ - private $snapshot = array(); + private $snapshot = []; /** * The entity that owns this collection. @@ -585,7 +585,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec */ public function __sleep() { - return array('collection', 'initialized'); + return ['collection', 'initialized']; } /** @@ -633,7 +633,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec $this->initialize(); $this->owner = null; - $this->snapshot = array(); + $this->snapshot = []; $this->changed(); } @@ -695,7 +695,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec protected function doInitialize() { // Has NEW objects added through add(). Remember them. - $newObjects = array(); + $newObjects = []; if ($this->isDirty) { $newObjects = $this->collection->toArray(); diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 525ab34b3..ca8575d2a 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -47,7 +47,7 @@ class ManyToManyPersister extends AbstractCollectionPersister return; // ignore inverse side } - $types = array(); + $types = []; $class = $this->em->getClassMetadata($mapping['sourceEntity']); foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { @@ -104,7 +104,7 @@ class ManyToManyPersister extends AbstractCollectionPersister ? $mapping['inversedBy'] : $mapping['mappedBy']; - return $persister->load(array($mappedKey => $collection->getOwner(), $mapping['indexBy'] => $index), null, $mapping, array(), 0, 1); + return $persister->load([$mappedKey => $collection->getOwner(), $mapping['indexBy'] => $index], null, $mapping, [], 0, 1); } /** @@ -112,9 +112,9 @@ class ManyToManyPersister extends AbstractCollectionPersister */ public function count(PersistentCollection $collection) { - $conditions = array(); - $params = array(); - $types = array(); + $conditions = []; + $params = []; + $types = []; $mapping = $collection->getMapping(); $id = $this->uow->getEntityIdentifier($collection->getOwner()); $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); @@ -238,7 +238,7 @@ class ManyToManyPersister extends AbstractCollectionPersister $id = $this->uow->getEntityIdentifier($owner); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $onConditions = $this->getOnConditionSQL($mapping); - $whereClauses = $params = array(); + $whereClauses = $params = []; if ( ! $mapping['isOwningSide']) { $associationSourceClass = $targetClass; @@ -311,7 +311,7 @@ class ManyToManyPersister extends AbstractCollectionPersister $filterSql = $this->generateFilterConditionSQL($rootClass, 'te'); if ('' === $filterSql) { - return array('', ''); + return ['', '']; } // A join is needed if there is filtering on the target entity @@ -319,7 +319,7 @@ class ManyToManyPersister extends AbstractCollectionPersister $joinSql = ' JOIN ' . $tableName . ' te' . ' ON' . implode(' AND ', $this->getOnConditionSQL($mapping)); - return array($joinSql, $filterSql); + return [$joinSql, $filterSql]; } /** @@ -332,7 +332,7 @@ class ManyToManyPersister extends AbstractCollectionPersister */ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) { - $filterClauses = array(); + $filterClauses = []; foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { if ($filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { @@ -363,7 +363,7 @@ class ManyToManyPersister extends AbstractCollectionPersister ? $association['joinTable']['inverseJoinColumns'] : $association['joinTable']['joinColumns']; - $conditions = array(); + $conditions = []; foreach ($joinColumns as $joinColumn) { $joinColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); @@ -382,7 +382,7 @@ class ManyToManyPersister extends AbstractCollectionPersister */ protected function getDeleteSQL(PersistentCollection $collection) { - $columns = array(); + $columns = []; $mapping = $collection->getMapping(); $class = $this->em->getClassMetadata(get_class($collection->getOwner())); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); @@ -408,12 +408,12 @@ class ManyToManyPersister extends AbstractCollectionPersister // Optimization for single column identifier if (count($mapping['relationToSourceKeyColumns']) === 1) { - return array(reset($identifier)); + return [reset($identifier)]; } // Composite identifier $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); - $params = array(); + $params = []; foreach ($mapping['relationToSourceKeyColumns'] as $columnName => $refColumnName) { $params[] = isset($sourceClass->fieldNames[$refColumnName]) @@ -437,8 +437,8 @@ class ManyToManyPersister extends AbstractCollectionPersister $mapping = $collection->getMapping(); $class = $this->em->getClassMetadata($mapping['sourceEntity']); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); - $columns = array(); - $types = array(); + $columns = []; + $types = []; foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); @@ -450,11 +450,11 @@ class ManyToManyPersister extends AbstractCollectionPersister $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); } - return array( + return [ 'DELETE FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform) . ' WHERE ' . implode(' = ? AND ', $columns) . ' = ?', $types, - ); + ]; } /** @@ -483,8 +483,8 @@ class ManyToManyPersister extends AbstractCollectionPersister */ protected function getInsertRowSQL(PersistentCollection $collection) { - $columns = array(); - $types = array(); + $columns = []; + $types = []; $mapping = $collection->getMapping(); $class = $this->em->getClassMetadata($mapping['sourceEntity']); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); @@ -499,13 +499,13 @@ class ManyToManyPersister extends AbstractCollectionPersister $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); } - return array( + return [ 'INSERT INTO ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform) . ' (' . implode(', ', $columns) . ')' . ' VALUES' . ' (' . implode(', ', array_fill(0, count($columns), '?')) . ')', $types, - ); + ]; } /** @@ -535,7 +535,7 @@ class ManyToManyPersister extends AbstractCollectionPersister */ private function collectJoinTableColumnParameters(PersistentCollection $collection, $element) { - $params = array(); + $params = []; $mapping = $collection->getMapping(); $isComposite = count($mapping['joinTableColumns']) > 2; @@ -602,14 +602,14 @@ class ManyToManyPersister extends AbstractCollectionPersister } $quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $associationSourceClass, $this->platform). ' t'; - $whereClauses = array(); - $params = array(); - $types = array(); + $whereClauses = []; + $params = []; + $types = []; $joinNeeded = ! in_array($indexBy, $targetClass->identifier); if ($joinNeeded) { // extra join needed if indexBy is not a @id - $joinConditions = array(); + $joinConditions = []; foreach ($joinColumns as $joinTableColumn) { $joinConditions[] = 't.' . $joinTableColumn['name'] . ' = tr.' . $joinTableColumn['referencedColumnName']; @@ -650,7 +650,7 @@ class ManyToManyPersister extends AbstractCollectionPersister } } - return array($quotedJoinTable, $whereClauses, $params, $types); + return [$quotedJoinTable, $whereClauses, $params, $types]; } /** @@ -684,9 +684,9 @@ class ManyToManyPersister extends AbstractCollectionPersister } $quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $sourceClass, $this->platform); - $whereClauses = array(); - $params = array(); - $types = array(); + $whereClauses = []; + $params = []; + $types = []; foreach ($mapping['joinTableColumns'] as $joinTableColumn) { $whereClauses[] = ($addFilters ? 't.' : '') . $joinTableColumn . ' = ?'; @@ -716,7 +716,7 @@ class ManyToManyPersister extends AbstractCollectionPersister } } - return array($quotedJoinTable, $whereClauses, $params, $types); + return [$quotedJoinTable, $whereClauses, $params, $types]; } /** @@ -732,7 +732,7 @@ class ManyToManyPersister extends AbstractCollectionPersister $expression = $criteria->getWhereExpression(); if ($expression === null) { - return array(); + return []; } $valueVisitor = new SqlValueVisitor(); diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 0e2fda868..82115071f 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -83,13 +83,13 @@ class OneToManyPersister extends AbstractCollectionPersister $persister = $this->uow->getEntityPersister($mapping['targetEntity']); return $persister->load( - array( + [ $mapping['mappedBy'] => $collection->getOwner(), $mapping['indexBy'] => $index - ), + ], null, $mapping, - array(), + [], null, 1 ); @@ -249,10 +249,10 @@ class OneToManyPersister extends AbstractCollectionPersister $columnDefinitions = []; foreach ($idColumnNames as $idColumnName) { - $columnDefinitions[$idColumnName] = array( + $columnDefinitions[$idColumnName] = [ 'notnull' => true, 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $this->em)), - ); + ]; } $statement = $this->platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable @@ -271,7 +271,7 @@ class OneToManyPersister extends AbstractCollectionPersister $numDeleted = $this->conn->executeUpdate($statement, $parameters); // 3) Delete records on each table in the hierarchy - $classNames = array_merge($targetClass->parentClasses, array($targetClass->name), $targetClass->subClasses); + $classNames = array_merge($targetClass->parentClasses, [$targetClass->name], $targetClass->subClasses); foreach (array_reverse($classNames) as $className) { $tableName = $this->quoteStrategy->getTableName($this->em->getClassMetadata($className), $this->platform); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index d577df6d9..e3d0a165f 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -86,7 +86,7 @@ class BasicEntityPersister implements EntityPersister /** * @var array */ - static private $comparisonMap = array( + static private $comparisonMap = [ Comparison::EQ => '= %s', Comparison::IS => '= %s', Comparison::NEQ => '!= %s', @@ -97,7 +97,7 @@ class BasicEntityPersister implements EntityPersister Comparison::IN => 'IN (%s)', Comparison::NIN => 'NOT IN (%s)', Comparison::CONTAINS => 'LIKE %s', - ); + ]; /** * Metadata object that describes the mapping of the mapped entity class. @@ -132,7 +132,7 @@ class BasicEntityPersister implements EntityPersister * * @var array */ - protected $queuedInserts = array(); + protected $queuedInserts = []; /** * The map of column names to DBAL mapping types of all prepared columns used @@ -143,7 +143,7 @@ class BasicEntityPersister implements EntityPersister * @see prepareInsertData($entity) * @see prepareUpdateData($entity) */ - protected $columnTypes = array(); + protected $columnTypes = []; /** * The map of quoted column names. @@ -153,7 +153,7 @@ class BasicEntityPersister implements EntityPersister * @see prepareInsertData($entity) * @see prepareUpdateData($entity) */ - protected $quotedColumns = array(); + protected $quotedColumns = []; /** * The INSERT SQL statement used for entities handled by this persister. @@ -257,10 +257,10 @@ class BasicEntityPersister implements EntityPersister public function executeInserts() { if ( ! $this->queuedInserts) { - return array(); + return []; } - $postInsertIds = array(); + $postInsertIds = []; $idGenerator = $this->class->idGenerator; $isPostInsertId = $idGenerator->isPostInsertGenerator(); @@ -282,13 +282,13 @@ class BasicEntityPersister implements EntityPersister if ($isPostInsertId) { $generatedId = $idGenerator->generate($this->em, $entity); - $id = array( + $id = [ $this->class->identifier[0] => $generatedId - ); - $postInsertIds[] = array( + ]; + $postInsertIds[] = [ 'generatedId' => $generatedId, 'entity' => $entity, - ); + ]; } else { $id = $this->class->getIdentifierValues($entity); } @@ -299,7 +299,7 @@ class BasicEntityPersister implements EntityPersister } $stmt->closeCursor(); - $this->queuedInserts = array(); + $this->queuedInserts = []; return $postInsertIds; } @@ -389,9 +389,9 @@ class BasicEntityPersister implements EntityPersister */ protected final function updateTable($entity, $quotedTableName, array $updateData, $versioned = false) { - $set = array(); - $types = array(); - $params = array(); + $set = []; + $types = []; + $params = []; foreach ($updateData as $columnName => $value) { $placeholder = '?'; @@ -420,7 +420,7 @@ class BasicEntityPersister implements EntityPersister $types[] = $this->columnTypes[$columnName]; } - $where = array(); + $where = []; $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); foreach ($this->class->identifier as $idField) { @@ -503,9 +503,9 @@ class BasicEntityPersister implements EntityPersister $selfReferential = ($mapping['targetEntity'] == $mapping['sourceEntity']); $class = $this->class; $association = $mapping; - $otherColumns = array(); - $otherKeys = array(); - $keys = array(); + $otherColumns = []; + $otherKeys = []; + $keys = []; if ( ! $mapping['isOwningSide']) { $class = $this->em->getClassMetadata($mapping['targetEntity']); @@ -603,7 +603,7 @@ class BasicEntityPersister implements EntityPersister protected function prepareUpdateData($entity) { $versionField = null; - $result = array(); + $result = []; $uow = $this->em->getUnitOfWork(); if (($versioned = $this->class->isVersioned) != false) { @@ -646,7 +646,7 @@ class BasicEntityPersister implements EntityPersister // The associated entity $newVal is not yet persisted, so we must // set $newVal = null, in order to insert a null value and schedule an // extra update on the UnitOfWork. - $uow->scheduleExtraUpdate($entity, array($field => array(null, $newVal))); + $uow->scheduleExtraUpdate($entity, [$field => [null, $newVal]]); $newVal = null; } @@ -705,7 +705,7 @@ class BasicEntityPersister implements EntityPersister /** * {@inheritdoc} */ - public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = null, $limit = null, array $orderBy = null) + public function load(array $criteria, $entity = null, $assoc = null, array $hints = [], $lockMode = null, $limit = null, array $orderBy = null) { $this->switchPersisterContext(null, $limit); @@ -735,7 +735,7 @@ class BasicEntityPersister implements EntityPersister /** * {@inheritdoc} */ - public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = array()) + public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = []) { if (($foundEntity = $this->em->getUnitOfWork()->tryGetById($identifier, $assoc['targetEntity'])) != false) { return $foundEntity; @@ -748,7 +748,7 @@ class BasicEntityPersister implements EntityPersister // Mark inverse side as fetched in the hints, otherwise the UoW would // try to load it in a separate query (remember: to-one inverse sides can not be lazy). - $hints = array(); + $hints = []; if ($isInverseSingleValued) { $hints['fetched']["r"][$assoc['inversedBy']] = true; @@ -808,13 +808,13 @@ class BasicEntityPersister implements EntityPersister $stmt = $this->conn->executeQuery($sql, $params, $types); $hydrator = $this->em->newHydrator(Query::HYDRATE_OBJECT); - $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, array(Query::HINT_REFRESH => true)); + $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, [Query::HINT_REFRESH => true]); } /** * {@inheritDoc} */ - public function count($criteria = array()) + public function count($criteria = []) { $sql = $this->getCountSQL($criteria); @@ -840,7 +840,8 @@ class BasicEntityPersister implements EntityPersister $stmt = $this->conn->executeQuery($query, $params, $types); $hydrator = $this->em->newHydrator(($this->currentPersisterContext->selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); - return $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true)); + return $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, [UnitOfWork::HINT_DEFEREAGERLOAD => true] + ); } /** @@ -849,11 +850,11 @@ class BasicEntityPersister implements EntityPersister public function expandCriteriaParameters(Criteria $criteria) { $expression = $criteria->getWhereExpression(); - $sqlParams = array(); - $sqlTypes = array(); + $sqlParams = []; + $sqlTypes = []; if ($expression === null) { - return array($sqlParams, $sqlTypes); + return [$sqlParams, $sqlTypes]; } $valueVisitor = new SqlValueVisitor(); @@ -871,13 +872,13 @@ class BasicEntityPersister implements EntityPersister $sqlTypes = array_merge($sqlTypes, $this->getTypes($field, $value, $this->class)); } - return array($sqlParams, $sqlTypes); + return [$sqlParams, $sqlTypes]; } /** * {@inheritdoc} */ - public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null) + public function loadAll(array $criteria = [], array $orderBy = null, $limit = null, $offset = null) { $this->switchPersisterContext($offset, $limit); @@ -887,7 +888,8 @@ class BasicEntityPersister implements EntityPersister $hydrator = $this->em->newHydrator(($this->currentPersisterContext->selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); - return $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true)); + return $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, [UnitOfWork::HINT_DEFEREAGERLOAD => true] + ); } /** @@ -913,7 +915,7 @@ class BasicEntityPersister implements EntityPersister private function loadArrayFromStatement($assoc, $stmt) { $rsm = $this->currentPersisterContext->rsm; - $hints = array(UnitOfWork::HINT_DEFEREAGERLOAD => true); + $hints = [UnitOfWork::HINT_DEFEREAGERLOAD => true]; if (isset($assoc['indexBy'])) { $rsm = clone ($this->currentPersisterContext->rsm); // this is necessary because the "default rsm" should be changed. @@ -935,10 +937,10 @@ class BasicEntityPersister implements EntityPersister private function loadCollectionFromStatement($assoc, $stmt, $coll) { $rsm = $this->currentPersisterContext->rsm; - $hints = array( + $hints = [ UnitOfWork::HINT_DEFEREAGERLOAD => true, 'collection' => $coll - ); + ]; if (isset($assoc['indexBy'])) { $rsm = clone ($this->currentPersisterContext->rsm); // this is necessary because the "default rsm" should be changed. @@ -975,8 +977,8 @@ class BasicEntityPersister implements EntityPersister $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); $class = $sourceClass; $association = $assoc; - $criteria = array(); - $parameters = array(); + $criteria = []; + $parameters = []; if ( ! $assoc['isOwningSide']) { $class = $this->em->getClassMetadata($assoc['targetEntity']); @@ -1018,11 +1020,11 @@ class BasicEntityPersister implements EntityPersister } $criteria[$quotedJoinTable . '.' . $quotedKeyColumn] = $value; - $parameters[] = array( + $parameters[] = [ 'value' => $value, 'field' => $field, 'class' => $sourceClass, - ); + ]; } $sql = $this->getSelectSQL($criteria, $assoc, null, $limit, $offset); @@ -1096,7 +1098,7 @@ class BasicEntityPersister implements EntityPersister /** * {@inheritDoc} */ - public function getCountSQL($criteria = array()) + public function getCountSQL($criteria = []) { $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); $tableAlias = $this->getSQLTableAlias($this->class->name); @@ -1132,7 +1134,7 @@ class BasicEntityPersister implements EntityPersister */ protected final function getOrderBySQL(array $orderBy, $baseTableAlias) { - $orderByList = array(); + $orderByList = []; foreach ($orderBy as $fieldName => $orientation) { @@ -1194,7 +1196,7 @@ class BasicEntityPersister implements EntityPersister return $this->currentPersisterContext->selectColumnListSql; } - $columnList = array(); + $columnList = []; $this->currentPersisterContext->rsm->addEntityResult($this->class->name, 'r'); // r for root // Add regular columns to select list @@ -1247,7 +1249,7 @@ class BasicEntityPersister implements EntityPersister } $association = $assoc; - $joinCondition = array(); + $joinCondition = []; if (isset($assoc['indexBy'])) { $this->currentPersisterContext->rsm->addIndexBy($assocAlias, $assoc['indexBy']); @@ -1315,7 +1317,7 @@ class BasicEntityPersister implements EntityPersister return ''; } - $columnList = array(); + $columnList = []; $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); $isIdentifier = isset($assoc['id']) && $assoc['id'] === true; $sqlTableAlias = $this->getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias)); @@ -1343,7 +1345,7 @@ class BasicEntityPersister implements EntityPersister */ protected function getSelectManyToManyJoinSQL(array $manyToMany) { - $conditions = array(); + $conditions = []; $association = $manyToMany; $sourceTableAlias = $this->getSQLTableAlias($this->class->name); @@ -1385,7 +1387,7 @@ class BasicEntityPersister implements EntityPersister return $this->insertSql; } - $values = array(); + $values = []; $columns = array_unique($columns); foreach ($columns as $column) { @@ -1419,7 +1421,7 @@ class BasicEntityPersister implements EntityPersister */ protected function getInsertColumnList() { - $columns = array(); + $columns = []; foreach ($this->class->reflFields as $name => $field) { if ($this->class->isVersioned && $this->class->versionField == $name) { @@ -1579,7 +1581,7 @@ class BasicEntityPersister implements EntityPersister */ public function getSelectConditionStatementSQL($field, $value, $assoc = null, $comparison = null) { - $selectedColumns = array(); + $selectedColumns = []; $columns = $this->getSelectConditionStatementColumnSQL($field, $assoc); if (count($columns) > 1 && $comparison === Comparison::IN) { @@ -1660,13 +1662,13 @@ class BasicEntityPersister implements EntityPersister ? $this->class->fieldMappings[$field]['inherited'] : $this->class->name; - return array($this->getSQLTableAlias($className) . '.' . $this->quoteStrategy->getColumnName($field, $this->class, $this->platform)); + return [$this->getSQLTableAlias($className) . '.' . $this->quoteStrategy->getColumnName($field, $this->class, $this->platform)]; } if (isset($this->class->associationMappings[$field])) { $association = $this->class->associationMappings[$field]; // Many-To-Many requires join table check for joinColumn - $columns = array(); + $columns = []; $class = $this->class; if ($association['type'] === ClassMetadata::MANY_TO_MANY) { @@ -1705,7 +1707,7 @@ class BasicEntityPersister implements EntityPersister // therefore checking for spaces and function calls which are not allowed. // found a join column condition, not really a "field" - return array($field); + return [$field]; } throw ORMException::unrecognizedField($field); @@ -1725,7 +1727,7 @@ class BasicEntityPersister implements EntityPersister */ protected function getSelectConditionSQL(array $criteria, $assoc = null) { - $conditions = array(); + $conditions = []; foreach ($criteria as $field => $value) { $conditions[] = $this->getSelectConditionStatementSQL($field, $value, $assoc); @@ -1770,8 +1772,8 @@ class BasicEntityPersister implements EntityPersister { $this->switchPersisterContext($offset, $limit); - $criteria = array(); - $parameters = array(); + $criteria = []; + $parameters = []; $owningAssoc = $this->class->associationMappings[$assoc['mappedBy']]; $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); $tableAlias = $this->getSQLTableAlias(isset($owningAssoc['inherited']) ? $owningAssoc['inherited'] : $this->class->name); @@ -1787,11 +1789,11 @@ class BasicEntityPersister implements EntityPersister } $criteria[$tableAlias . "." . $targetKeyColumn] = $value; - $parameters[] = array( + $parameters[] = [ 'value' => $value, 'field' => $field, 'class' => $sourceClass, - ); + ]; continue; } @@ -1800,11 +1802,11 @@ class BasicEntityPersister implements EntityPersister $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); $criteria[$tableAlias . "." . $targetKeyColumn] = $value; - $parameters[] = array( + $parameters[] = [ 'value' => $value, 'field' => $field, 'class' => $sourceClass, - ); + ]; } @@ -1819,8 +1821,8 @@ class BasicEntityPersister implements EntityPersister */ public function expandParameters($criteria) { - $params = array(); - $types = array(); + $params = []; + $types = []; foreach ($criteria as $field => $value) { if ($value === null) { @@ -1831,7 +1833,7 @@ class BasicEntityPersister implements EntityPersister $params = array_merge($params, $this->getValues($value)); } - return array($params, $types); + return [$params, $types]; } /** @@ -1848,8 +1850,8 @@ class BasicEntityPersister implements EntityPersister */ private function expandToManyParameters($criteria) { - $params = array(); - $types = array(); + $params = []; + $types = []; foreach ($criteria as $criterion) { if ($criterion['value'] === null) { @@ -1860,7 +1862,7 @@ class BasicEntityPersister implements EntityPersister $params = array_merge($params, $this->getValues($criterion['value'])); } - return array($params, $types); + return [$params, $types]; } /** @@ -1875,11 +1877,11 @@ class BasicEntityPersister implements EntityPersister */ private function getTypes($field, $value, ClassMetadata $class) { - $types = array(); + $types = []; switch (true) { case (isset($class->fieldMappings[$field])): - $types = array_merge($types, array($class->fieldMappings[$field]['type'])); + $types = array_merge($types, [$class->fieldMappings[$field]['type']]); break; case (isset($class->associationMappings[$field])): @@ -1926,19 +1928,19 @@ class BasicEntityPersister implements EntityPersister private function getValues($value) { if (is_array($value)) { - $newValue = array(); + $newValue = []; foreach ($value as $itemValue) { $newValue = array_merge($newValue, $this->getValues($itemValue)); } - return array($newValue); + return [$newValue]; } if (is_object($value) && $this->em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) { $class = $this->em->getClassMetadata(get_class($value)); if ($class->isIdentifierComposite) { - $newValue = array(); + $newValue = []; foreach ($class->getIdentifierValues($value) as $innerValue) { $newValue = array_merge($newValue, $this->getValues($innerValue)); @@ -1948,7 +1950,7 @@ class BasicEntityPersister implements EntityPersister } } - return array($this->getIndividualValue($value)); + return [$this->getIndividualValue($value)]; } /** @@ -2038,7 +2040,7 @@ class BasicEntityPersister implements EntityPersister */ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) { - $filterClauses = array(); + $filterClauses = []; foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { diff --git a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php index 81fde938b..132dac7e4 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php +++ b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php @@ -76,7 +76,7 @@ class CachedPersisterContext * * @var array */ - public $sqlTableAliases = array(); + public $sqlTableAliases = []; /** * Whether this persistent context is considering limit operations applied to the selection queries diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index ff018a050..9ac631668 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -81,7 +81,7 @@ interface EntityPersister * * @return string */ - public function getCountSQL($criteria = array()); + public function getCountSQL($criteria = []); /** * Expands the parameters from the given criteria and use the correct binding types if found. @@ -165,7 +165,7 @@ interface EntityPersister * * @return int */ - public function count($criteria = array()); + public function count($criteria = []); /** * Gets the name of the table that owns the column the given field is mapped to. @@ -197,7 +197,7 @@ interface EntityPersister * * @todo Check identity map? loadById method? Try to guess whether $criteria is the id? */ - public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = null, $limit = null, array $orderBy = null); + public function load(array $criteria, $entity = null, $assoc = null, array $hints = [], $lockMode = null, $limit = null, array $orderBy = null); /** * Loads an entity by identifier. @@ -225,7 +225,7 @@ interface EntityPersister * * @throws \Doctrine\ORM\Mapping\MappingException */ - public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = array()); + public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = []); /** * Refreshes a managed entity. @@ -260,7 +260,7 @@ interface EntityPersister * * @return array */ - public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null); + public function loadAll(array $criteria = [], array $orderBy = null, $limit = null, $offset = null); /** * Gets (sliced or full) elements of the given collection. diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 0975cf56e..e3e7d2b43 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -45,14 +45,14 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister * * @var array */ - private $owningTableMap = array(); + private $owningTableMap = []; /** * Map of table to quoted table names. * * @var array */ - private $quotedTableMap = array(); + private $quotedTableMap = []; /** * {@inheritdoc} @@ -127,10 +127,10 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister public function executeInserts() { if ( ! $this->queuedInserts) { - return array(); + return []; } - $postInsertIds = array(); + $postInsertIds = []; $idGenerator = $this->class->idGenerator; $isPostInsertId = $idGenerator->isPostInsertGenerator(); $rootClass = ($this->class->name !== $this->class->rootEntityName) @@ -143,7 +143,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister $rootTableStmt = $this->conn->prepare($rootPersister->getInsertSQL()); // Prepare statements for sub tables. - $subTableStmts = array(); + $subTableStmts = []; if ($rootClass !== $this->class) { $subTableStmts[$this->class->getTableName()] = $this->conn->prepare($this->getInsertSQL()); @@ -176,13 +176,13 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister if ($isPostInsertId) { $generatedId = $idGenerator->generate($this->em, $entity); - $id = array( + $id = [ $this->class->identifier[0] => $generatedId - ); - $postInsertIds[] = array( + ]; + $postInsertIds[] = [ 'generatedId' => $generatedId, 'entity' => $entity, - ); + ]; } else { $id = $this->em->getUnitOfWork()->getEntityIdentifier($entity); } @@ -198,7 +198,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister $paramIndex = 1; $data = isset($insertData[$tableName]) ? $insertData[$tableName] - : array(); + : []; foreach ((array) $id as $idName => $idVal) { $type = isset($this->columnTypes[$idName]) ? $this->columnTypes[$idName] : Type::STRING; @@ -222,7 +222,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister $stmt->closeCursor(); } - $this->queuedInserts = array(); + $this->queuedInserts = []; return $postInsertIds; } @@ -258,7 +258,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister if ( ! isset($updateData[$versionedTable])) { $tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform); - $this->updateTable($entity, $tableName, array(), true); + $this->updateTable($entity, $tableName, [], true); } $identifiers = $this->em->getUnitOfWork()->getEntityIdentifier($entity); @@ -369,7 +369,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister /** * {@inheritDoc} */ - public function getCountSQL($criteria = array()) + public function getCountSQL($criteria = []) { $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); $baseTableAlias = $this->getSQLTableAlias($this->class->name); @@ -406,7 +406,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister // INNER JOIN parent tables foreach ($this->class->parentClasses as $parentClassName) { - $conditions = array(); + $conditions = []; $tableAlias = $this->getSQLTableAlias($parentClassName); $parentClass = $this->em->getClassMetadata($parentClassName); $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; @@ -433,7 +433,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister return $this->currentPersisterContext->selectColumnListSql; } - $columnList = array(); + $columnList = []; $discrColumn = $this->class->discriminatorColumn['name']; $discrColumnType = $this->class->discriminatorColumn['type']; $baseTableAlias = $this->getSQLTableAlias($this->class->name); @@ -545,7 +545,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister // Identifier columns must always come first in the column list of subclasses. $columns = $this->class->parentClasses ? $this->class->getIdentifierColumnNames() - : array(); + : []; foreach ($this->class->reflFields as $name => $field) { if (isset($this->class->fieldMappings[$name]['inherited']) @@ -599,7 +599,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister // INNER JOIN parent tables foreach ($this->class->parentClasses as $parentClassName) { - $conditions = array(); + $conditions = []; $parentClass = $this->em->getClassMetadata($parentClassName); $tableAlias = $this->getSQLTableAlias($parentClassName); $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; @@ -614,7 +614,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister // OUTER JOIN sub tables foreach ($this->class->subClasses as $subClassName) { - $conditions = array(); + $conditions = []; $subClass = $this->em->getClassMetadata($subClassName); $tableAlias = $this->getSQLTableAlias($subClassName); $joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON '; diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index 8dc71bb1d..d3eb5d8ac 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -164,7 +164,7 @@ class SingleTablePersister extends AbstractEntityInheritancePersister */ protected function getSelectConditionDiscriminatorValueSQL() { - $values = array(); + $values = []; if ($this->class->discriminatorValue !== null) { // discriminators can be 0 $values[] = $this->conn->quote($this->class->discriminatorValue); diff --git a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php b/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php index f23bfa3da..476ecaba8 100644 --- a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php @@ -70,7 +70,7 @@ class SqlExpressionVisitor extends ExpressionVisitor if (isset($this->classMetadata->associationMappings[$field]) && $value !== null && ! is_object($value) && - ! in_array($comparison->getOperator(), array(Comparison::IN, Comparison::NIN))) { + ! in_array($comparison->getOperator(), [Comparison::IN, Comparison::NIN])) { throw PersisterException::matchingAssocationFieldRequiresObject($this->classMetadata->name, $field); } @@ -89,7 +89,7 @@ class SqlExpressionVisitor extends ExpressionVisitor */ public function walkCompositeExpression(CompositeExpression $expr) { - $expressionList = array(); + $expressionList = []; foreach ($expr->getExpressionList() as $child) { $expressionList[] = $this->dispatch($child); diff --git a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php index 0e680ad07..2b3bdedc4 100644 --- a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php @@ -34,12 +34,12 @@ class SqlValueVisitor extends ExpressionVisitor /** * @var array */ - private $values = array(); + private $values = []; /** * @var array */ - private $types = array(); + private $types = []; /** * Converts a comparison expression into the target query language output. @@ -61,7 +61,7 @@ class SqlValueVisitor extends ExpressionVisitor } $this->values[] = $value; - $this->types[] = array($field, $value); + $this->types[] = [$field, $value]; } /** @@ -97,7 +97,7 @@ class SqlValueVisitor extends ExpressionVisitor */ public function getParamsAndTypes() { - return array($this->values, $this->types); + return [$this->values, $this->types]; } /** diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 6a8a50ae0..12fb3f560 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -135,7 +135,7 @@ final class Query extends AbstractQuery * * @var array */ - private $_parsedTypes = array(); + private $_parsedTypes = []; /** * Cached DQL query. @@ -241,7 +241,7 @@ final class Query extends AbstractQuery */ private function _parse() { - $types = array(); + $types = []; foreach ($this->parameters as $parameter) { /** @var Query\Parameter $parameter */ @@ -354,8 +354,8 @@ final class Query extends AbstractQuery */ private function processParameterMappings($paramMappings) { - $sqlParams = array(); - $types = array(); + $sqlParams = []; + $types = []; foreach ($this->parameters as $parameter) { $key = $parameter->getName(); @@ -383,7 +383,7 @@ final class Query extends AbstractQuery // optimized multi value sql positions away for now, // they are not allowed in DQL anyways. - $value = array($value); + $value = [$value]; $countValue = count($value); for ($i = 0, $l = count($sqlPositions); $i < $l; $i++) { @@ -403,7 +403,7 @@ final class Query extends AbstractQuery $types = array_values($types); } - return array($sqlParams, $types); + return [$sqlParams, $types]; } /** @@ -667,7 +667,7 @@ final class Query extends AbstractQuery */ public function setLockMode($lockMode) { - if (in_array($lockMode, array(LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE), true)) { + if (in_array($lockMode, [LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE], true)) { if ( ! $this->_em->getConnection()->isTransactionActive()) { throw TransactionRequiredException::transactionRequired(); } diff --git a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php b/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php index 194f9ace5..9e3b4c526 100644 --- a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php +++ b/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php @@ -23,7 +23,7 @@ namespace Doctrine\ORM\Query\AST; * CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")" * * @since 2.1 - * + * * @link www.doctrine-project.org * @author Benjamin Eberlei * @author Guilherme Blanco @@ -35,7 +35,7 @@ class CoalesceExpression extends Node /** * @var array */ - public $scalarExpressions = array(); + public $scalarExpressions = []; /** * @param array $scalarExpressions diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php b/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php index 62c7b2bca..bf823629b 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php @@ -33,7 +33,7 @@ class ConditionalExpression extends Node /** * @var array */ - public $conditionalTerms = array(); + public $conditionalTerms = []; /** * @param array $conditionalTerms diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php b/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php index bb92db119..7122c9c68 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php @@ -32,7 +32,7 @@ class ConditionalTerm extends Node /** * @var array */ - public $conditionalFactors = array(); + public $conditionalFactors = []; /** * @param array $conditionalFactors diff --git a/lib/Doctrine/ORM/Query/AST/FromClause.php b/lib/Doctrine/ORM/Query/AST/FromClause.php index b1d8dfe6b..fdb61ca37 100644 --- a/lib/Doctrine/ORM/Query/AST/FromClause.php +++ b/lib/Doctrine/ORM/Query/AST/FromClause.php @@ -22,7 +22,7 @@ namespace Doctrine\ORM\Query\AST; /** * FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration} * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -34,7 +34,7 @@ class FromClause extends Node /** * @var array */ - public $identificationVariableDeclarations = array(); + public $identificationVariableDeclarations = []; /** * @param array $identificationVariableDeclarations diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php index 1c58f6cbd..71da374df 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php @@ -38,7 +38,7 @@ class ConcatFunction extends FunctionNode public $secondStringPrimary; - public $concatExpressions = array(); + public $concatExpressions = []; /** * @override @@ -47,13 +47,13 @@ class ConcatFunction extends FunctionNode { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); - $args = array(); + $args = []; foreach ($this->concatExpressions as $expression) { $args[] = $sqlWalker->walkStringPrimary($expression); } - return call_user_func_array(array($platform,'getConcatExpression'), $args); + return call_user_func_array([$platform,'getConcatExpression'], $args); } /** diff --git a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php b/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php index a74eed599..e7937d60d 100644 --- a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php @@ -23,7 +23,7 @@ namespace Doctrine\ORM\Query\AST; * GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END" * * @since 2.2 - * + * * @link www.doctrine-project.org * @author Benjamin Eberlei * @author Guilherme Blanco @@ -35,7 +35,7 @@ class GeneralCaseExpression extends Node /** * @var array */ - public $whenClauses = array(); + public $whenClauses = []; /** * @var mixed diff --git a/lib/Doctrine/ORM/Query/AST/GroupByClause.php b/lib/Doctrine/ORM/Query/AST/GroupByClause.php index c05fa5863..687512a4c 100644 --- a/lib/Doctrine/ORM/Query/AST/GroupByClause.php +++ b/lib/Doctrine/ORM/Query/AST/GroupByClause.php @@ -33,7 +33,7 @@ class GroupByClause extends Node /** * @var array */ - public $groupByItems = array(); + public $groupByItems = []; /** * @param array $groupByItems diff --git a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php index a8f7f6d35..2e2032ca3 100644 --- a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php @@ -43,7 +43,7 @@ class IdentificationVariableDeclaration extends Node /** * @var array */ - public $joins = array(); + public $joins = []; /** * @param RangeVariableDeclaration|null $rangeVariableDecl diff --git a/lib/Doctrine/ORM/Query/AST/InExpression.php b/lib/Doctrine/ORM/Query/AST/InExpression.php index 9d0a8b54e..64ef13405 100644 --- a/lib/Doctrine/ORM/Query/AST/InExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InExpression.php @@ -42,7 +42,7 @@ class InExpression extends Node /** * @var array */ - public $literals = array(); + public $literals = []; /** * @var Subselect|null diff --git a/lib/Doctrine/ORM/Query/AST/OrderByClause.php b/lib/Doctrine/ORM/Query/AST/OrderByClause.php index 75d16c731..e0e30e9d9 100644 --- a/lib/Doctrine/ORM/Query/AST/OrderByClause.php +++ b/lib/Doctrine/ORM/Query/AST/OrderByClause.php @@ -33,7 +33,7 @@ class OrderByClause extends Node /** * @var array */ - public $orderByItems = array(); + public $orderByItems = []; /** * @param array $orderByItems diff --git a/lib/Doctrine/ORM/Query/AST/SelectClause.php b/lib/Doctrine/ORM/Query/AST/SelectClause.php index 1df143677..f8e6f472a 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SelectClause.php @@ -38,7 +38,7 @@ class SelectClause extends Node /** * @var array */ - public $selectExpressions = array(); + public $selectExpressions = []; /** * @param array $selectExpressions diff --git a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php index 9bd485045..80ecd15ce 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php @@ -33,7 +33,7 @@ class SimpleArithmeticExpression extends Node /** * @var array */ - public $arithmeticTerms = array(); + public $arithmeticTerms = []; /** * @param array $arithmeticTerms diff --git a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php index 5272f3962..67e354e55 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php @@ -23,7 +23,7 @@ namespace Doctrine\ORM\Query\AST; * SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" * * @since 2.2 - * + * * @link www.doctrine-project.org * @author Benjamin Eberlei * @author Guilherme Blanco @@ -40,7 +40,7 @@ class SimpleCaseExpression extends Node /** * @var array */ - public $simpleWhenClauses = array(); + public $simpleWhenClauses = []; /** * @var mixed diff --git a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php b/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php index 8d009fcfd..9704061e8 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php @@ -33,7 +33,7 @@ class SubselectFromClause extends Node /** * @var array */ - public $identificationVariableDeclarations = array(); + public $identificationVariableDeclarations = []; /** * @param array $identificationVariableDeclarations diff --git a/lib/Doctrine/ORM/Query/AST/UpdateClause.php b/lib/Doctrine/ORM/Query/AST/UpdateClause.php index 430ed14eb..23c722a62 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateClause.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateClause.php @@ -43,7 +43,7 @@ class UpdateClause extends Node /** * @var array */ - public $updateItems = array(); + public $updateItems = []; /** * @param string $abstractSchemaName diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php index b14ddb534..aaf94d7ff 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php @@ -81,7 +81,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor . ' SELECT t0.' . implode(', t0.', $idColumnNames); $rangeDecl = new AST\RangeVariableDeclaration($primaryClass->name, $primaryDqlAlias); - $fromClause = new AST\FromClause(array(new AST\IdentificationVariableDeclaration($rangeDecl, null, array()))); + $fromClause = new AST\FromClause([new AST\IdentificationVariableDeclaration($rangeDecl, null, [])]); $this->_insertSql .= $sqlWalker->walkFromClause($fromClause); // Append WHERE clause, if there is one. @@ -93,7 +93,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor $idSubselect = 'SELECT ' . $idColumnList . ' FROM ' . $tempTable; // 3. Create and store DELETE statements - $classNames = array_merge($primaryClass->parentClasses, array($primaryClass->name), $primaryClass->subClasses); + $classNames = array_merge($primaryClass->parentClasses, [$primaryClass->name], $primaryClass->subClasses); foreach (array_reverse($classNames) as $className) { $tableName = $quoteStrategy->getTableName($em->getClassMetadata($className), $platform); $this->_sqlStatements[] = 'DELETE FROM ' . $tableName @@ -101,12 +101,12 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor } // 4. Store DDL for temporary identifier table. - $columnDefinitions = array(); + $columnDefinitions = []; foreach ($idColumnNames as $idColumnName) { - $columnDefinitions[$idColumnName] = array( + $columnDefinitions[$idColumnName] = [ 'notnull' => true, 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)), - ); + ]; } $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')'; diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php index 995f9cad1..acad25a92 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -52,7 +52,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor /** * @var array */ - private $_sqlParameters = array(); + private $_sqlParameters = []; /** * @var int @@ -92,7 +92,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor . ' SELECT t0.' . implode(', t0.', $idColumnNames); $rangeDecl = new AST\RangeVariableDeclaration($primaryClass->name, $updateClause->aliasIdentificationVariable); - $fromClause = new AST\FromClause(array(new AST\IdentificationVariableDeclaration($rangeDecl, null, array()))); + $fromClause = new AST\FromClause([new AST\IdentificationVariableDeclaration($rangeDecl, null, [])]); $this->_insertSql .= $sqlWalker->walkFromClause($fromClause); @@ -100,7 +100,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor $idSubselect = 'SELECT ' . $idColumnList . ' FROM ' . $tempTable; // 3. Create and store UPDATE statements - $classNames = array_merge($primaryClass->parentClasses, array($primaryClass->name), $primaryClass->subClasses); + $classNames = array_merge($primaryClass->parentClasses, [$primaryClass->name], $primaryClass->subClasses); $i = -1; foreach (array_reverse($classNames) as $className) { @@ -143,13 +143,13 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor } // 4. Store DDL for temporary identifier table. - $columnDefinitions = array(); + $columnDefinitions = []; foreach ($idColumnNames as $idColumnName) { - $columnDefinitions[$idColumnName] = array( + $columnDefinitions[$idColumnName] = [ 'notnull' => true, 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)), - ); + ]; } $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' @@ -176,8 +176,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor // Execute UPDATE statements foreach ($this->_sqlStatements as $key => $statement) { - $paramValues = array(); - $paramTypes = array(); + $paramValues = []; + $paramTypes = []; if (isset($this->_sqlParameters[$key])) { foreach ($this->_sqlParameters[$key] as $parameterKey => $parameterName) { diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index 70f9ac9e2..eada61058 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -220,7 +220,7 @@ class Expr */ public function avg($x) { - return new Expr\Func('AVG', array($x)); + return new Expr\Func('AVG', [$x]); } /** @@ -232,7 +232,7 @@ class Expr */ public function max($x) { - return new Expr\Func('MAX', array($x)); + return new Expr\Func('MAX', [$x]); } /** @@ -244,7 +244,7 @@ class Expr */ public function min($x) { - return new Expr\Func('MIN', array($x)); + return new Expr\Func('MIN', [$x]); } /** @@ -256,7 +256,7 @@ class Expr */ public function count($x) { - return new Expr\Func('COUNT', array($x)); + return new Expr\Func('COUNT', [$x]); } /** @@ -280,7 +280,7 @@ class Expr */ public function exists($subquery) { - return new Expr\Func('EXISTS', array($subquery)); + return new Expr\Func('EXISTS', [$subquery]); } /** @@ -292,7 +292,7 @@ class Expr */ public function all($subquery) { - return new Expr\Func('ALL', array($subquery)); + return new Expr\Func('ALL', [$subquery]); } /** @@ -304,7 +304,7 @@ class Expr */ public function some($subquery) { - return new Expr\Func('SOME', array($subquery)); + return new Expr\Func('SOME', [$subquery]); } /** @@ -316,7 +316,7 @@ class Expr */ public function any($subquery) { - return new Expr\Func('ANY', array($subquery)); + return new Expr\Func('ANY', [$subquery]); } /** @@ -328,7 +328,7 @@ class Expr */ public function not($restriction) { - return new Expr\Func('NOT', array($restriction)); + return new Expr\Func('NOT', [$restriction]); } /** @@ -340,7 +340,7 @@ class Expr */ public function abs($x) { - return new Expr\Func('ABS', array($x)); + return new Expr\Func('ABS', [$x]); } /** @@ -429,7 +429,7 @@ class Expr */ public function sqrt($x) { - return new Expr\Func('SQRT', array($x)); + return new Expr\Func('SQRT', [$x]); } /** @@ -548,7 +548,7 @@ class Expr */ public function substring($x, $from, $len = null) { - $args = array($x, $from); + $args = [$x, $from]; if (null !== $len) { $args[] = $len; } @@ -565,7 +565,7 @@ class Expr */ public function lower($x) { - return new Expr\Func('LOWER', array($x)); + return new Expr\Func('LOWER', [$x]); } /** @@ -577,7 +577,7 @@ class Expr */ public function upper($x) { - return new Expr\Func('UPPER', array($x)); + return new Expr\Func('UPPER', [$x]); } /** @@ -589,7 +589,7 @@ class Expr */ public function length($x) { - return new Expr\Func('LENGTH', array($x)); + return new Expr\Func('LENGTH', [$x]); } /** diff --git a/lib/Doctrine/ORM/Query/Expr/Andx.php b/lib/Doctrine/ORM/Query/Expr/Andx.php index 432f714f6..cc64ab1a8 100644 --- a/lib/Doctrine/ORM/Query/Expr/Andx.php +++ b/lib/Doctrine/ORM/Query/Expr/Andx.php @@ -38,12 +38,12 @@ class Andx extends Composite /** * @var array */ - protected $allowedClasses = array( + protected $allowedClasses = [ 'Doctrine\ORM\Query\Expr\Comparison', 'Doctrine\ORM\Query\Expr\Func', 'Doctrine\ORM\Query\Expr\Orx', 'Doctrine\ORM\Query\Expr\Andx', - ); + ]; /** * @return array diff --git a/lib/Doctrine/ORM/Query/Expr/Base.php b/lib/Doctrine/ORM/Query/Expr/Base.php index 6eac70a27..d13031383 100644 --- a/lib/Doctrine/ORM/Query/Expr/Base.php +++ b/lib/Doctrine/ORM/Query/Expr/Base.php @@ -48,17 +48,17 @@ abstract class Base /** * @var array */ - protected $allowedClasses = array(); + protected $allowedClasses = []; /** * @var array */ - protected $parts = array(); + protected $parts = []; /** * @param array $args */ - public function __construct($args = array()) + public function __construct($args = []) { $this->addMultiple($args); } @@ -68,7 +68,7 @@ abstract class Base * * @return Base */ - public function addMultiple($args = array()) + public function addMultiple($args = []) { foreach ((array) $args as $arg) { $this->add($arg); diff --git a/lib/Doctrine/ORM/Query/Expr/Composite.php b/lib/Doctrine/ORM/Query/Expr/Composite.php index 4d9a25198..6b8a04fa5 100644 --- a/lib/Doctrine/ORM/Query/Expr/Composite.php +++ b/lib/Doctrine/ORM/Query/Expr/Composite.php @@ -39,7 +39,7 @@ class Composite extends Base return (string) $this->parts[0]; } - $components = array(); + $components = []; foreach ($this->parts as $part) { $components[] = $this->processQueryPart($part); diff --git a/lib/Doctrine/ORM/Query/Expr/OrderBy.php b/lib/Doctrine/ORM/Query/Expr/OrderBy.php index 932548bd6..b9da73b98 100644 --- a/lib/Doctrine/ORM/Query/Expr/OrderBy.php +++ b/lib/Doctrine/ORM/Query/Expr/OrderBy.php @@ -48,12 +48,12 @@ class OrderBy /** * @var array */ - protected $allowedClasses = array(); + protected $allowedClasses = []; /** * @var array */ - protected $parts = array(); + protected $parts = []; /** * @param string|null $sort diff --git a/lib/Doctrine/ORM/Query/Expr/Orx.php b/lib/Doctrine/ORM/Query/Expr/Orx.php index c4ff7ae30..35f88e831 100644 --- a/lib/Doctrine/ORM/Query/Expr/Orx.php +++ b/lib/Doctrine/ORM/Query/Expr/Orx.php @@ -38,12 +38,12 @@ class Orx extends Composite /** * @var array */ - protected $allowedClasses = array( + protected $allowedClasses = [ 'Doctrine\ORM\Query\Expr\Comparison', 'Doctrine\ORM\Query\Expr\Func', 'Doctrine\ORM\Query\Expr\Andx', 'Doctrine\ORM\Query\Expr\Orx', - ); + ]; /** * @return array diff --git a/lib/Doctrine/ORM/Query/Expr/Select.php b/lib/Doctrine/ORM/Query/Expr/Select.php index 21df6c735..00bdc94f3 100644 --- a/lib/Doctrine/ORM/Query/Expr/Select.php +++ b/lib/Doctrine/ORM/Query/Expr/Select.php @@ -43,9 +43,7 @@ class Select extends Base /** * @var array */ - protected $allowedClasses = array( - 'Doctrine\ORM\Query\Expr\Func' - ); + protected $allowedClasses = ['Doctrine\ORM\Query\Expr\Func']; /** * @return array diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index b0248fbac..c48edd43f 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -75,7 +75,7 @@ abstract class SQLFilter $type = ParameterTypeInferer::inferType($value); } - $this->parameters[$name] = array('value' => $value, 'type' => $type); + $this->parameters[$name] = ['value' => $value, 'type' => $type]; // Keep the parameters sorted for the hash ksort($this->parameters); @@ -122,7 +122,7 @@ abstract class SQLFilter return true; } - + /** * Returns as string representation of the SQLFilter parameters (the state). * diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index ffbaeaf12..ca7f1ac32 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -59,7 +59,7 @@ class FilterCollection * * @var \Doctrine\ORM\Query\Filter\SQLFilter[] */ - private $enabledFilters = array(); + private $enabledFilters = []; /** * @var string The filter hash from the last time the query was parsed. @@ -176,16 +176,16 @@ class FilterCollection /** * Checks if a filter is enabled. - * + * * @param string $name Name of the filter. - * + * * @return boolean True if the filter is enabled, false otherwise. */ public function isEnabled($name) { return isset($this->enabledFilters[$name]); } - + /** * @return boolean True, if the filter collection is clean. */ diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index b31b93b87..b889ecfae 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -129,13 +129,13 @@ class Lexer extends \Doctrine\Common\Lexer */ protected function getCatchablePatterns() { - return array( + return [ '[a-z_][a-z0-9_]*\:[a-z_][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // aliased name '[a-z_\\\][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // identifier or qualified name '(?:[0-9]+(?:[\.][0-9]+)*)(?:e[+-]?[0-9]+)?', // numbers "'(?:[^']|'')*'", // quoted strings '\?[0-9]*|:[a-z_][a-z0-9_]*' // parameters - ); + ]; } /** @@ -143,7 +143,7 @@ class Lexer extends \Doctrine\Common\Lexer */ protected function getNonCatchablePatterns() { - return array('\s+', '(.)'); + return ['\s+', '(.)']; } /** diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 6f8eda514..ae8fcd3eb 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -40,21 +40,21 @@ class Parser * * @var array */ - private static $_STRING_FUNCTIONS = array( + private static $_STRING_FUNCTIONS = [ 'concat' => 'Doctrine\ORM\Query\AST\Functions\ConcatFunction', 'substring' => 'Doctrine\ORM\Query\AST\Functions\SubstringFunction', 'trim' => 'Doctrine\ORM\Query\AST\Functions\TrimFunction', 'lower' => 'Doctrine\ORM\Query\AST\Functions\LowerFunction', 'upper' => 'Doctrine\ORM\Query\AST\Functions\UpperFunction', 'identity' => 'Doctrine\ORM\Query\AST\Functions\IdentityFunction', - ); + ]; /** * READ-ONLY: Maps BUILT-IN numeric function names to AST class names. * * @var array */ - private static $_NUMERIC_FUNCTIONS = array( + private static $_NUMERIC_FUNCTIONS = [ 'length' => 'Doctrine\ORM\Query\AST\Functions\LengthFunction', 'locate' => 'Doctrine\ORM\Query\AST\Functions\LocateFunction', 'abs' => 'Doctrine\ORM\Query\AST\Functions\AbsFunction', @@ -64,20 +64,20 @@ class Parser 'date_diff' => 'Doctrine\ORM\Query\AST\Functions\DateDiffFunction', 'bit_and' => 'Doctrine\ORM\Query\AST\Functions\BitAndFunction', 'bit_or' => 'Doctrine\ORM\Query\AST\Functions\BitOrFunction', - ); + ]; /** * READ-ONLY: Maps BUILT-IN datetime function names to AST class names. * * @var array */ - private static $_DATETIME_FUNCTIONS = array( + private static $_DATETIME_FUNCTIONS = [ 'current_date' => 'Doctrine\ORM\Query\AST\Functions\CurrentDateFunction', 'current_time' => 'Doctrine\ORM\Query\AST\Functions\CurrentTimeFunction', 'current_timestamp' => 'Doctrine\ORM\Query\AST\Functions\CurrentTimestampFunction', 'date_add' => 'Doctrine\ORM\Query\AST\Functions\DateAddFunction', 'date_sub' => 'Doctrine\ORM\Query\AST\Functions\DateSubFunction', - ); + ]; /* * Expressions that were encountered during parsing of identifiers and expressions @@ -87,27 +87,27 @@ class Parser /** * @var array */ - private $deferredIdentificationVariables = array(); + private $deferredIdentificationVariables = []; /** * @var array */ - private $deferredPartialObjectExpressions = array(); + private $deferredPartialObjectExpressions = []; /** * @var array */ - private $deferredPathExpressions = array(); + private $deferredPathExpressions = []; /** * @var array */ - private $deferredResultVariables = array(); + private $deferredResultVariables = []; /** * @var array */ - private $deferredNewObjectExpressions = array(); + private $deferredNewObjectExpressions = []; /** * The lexer. @@ -142,7 +142,7 @@ class Parser * * @var array */ - private $queryComponents = array(); + private $queryComponents = []; /** * Keeps the nesting level of defined ResultVariables. @@ -156,7 +156,7 @@ class Parser * * @var array */ - private $customTreeWalkers = array(); + private $customTreeWalkers = []; /** * The custom last tree walker, if any, that is responsible for producing the output. @@ -168,7 +168,7 @@ class Parser /** * @var array */ - private $identVariableExpressions = array(); + private $identVariableExpressions = []; /** * Checks if a function is internally defined. Used to prevent overwriting @@ -541,7 +541,7 @@ class Parser */ private function isMathOperator($token) { - return in_array($token['type'], array(Lexer::T_PLUS, Lexer::T_MINUS, Lexer::T_DIVIDE, Lexer::T_MULTIPLY)); + return in_array($token['type'], [Lexer::T_PLUS, Lexer::T_MINUS, Lexer::T_DIVIDE, Lexer::T_MULTIPLY]); } /** @@ -568,7 +568,7 @@ class Parser */ private function isAggregateFunction($tokenType) { - return in_array($tokenType, array(Lexer::T_AVG, Lexer::T_MIN, Lexer::T_MAX, Lexer::T_SUM, Lexer::T_COUNT)); + return in_array($tokenType, [Lexer::T_AVG, Lexer::T_MIN, Lexer::T_MAX, Lexer::T_SUM, Lexer::T_COUNT]); } /** @@ -578,7 +578,7 @@ class Parser */ private function isNextAllAnySome() { - return in_array($this->lexer->lookahead['type'], array(Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME)); + return in_array($this->lexer->lookahead['type'], [Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME]); } /** @@ -787,7 +787,7 @@ class Parser if ( ! ($expectedType & $fieldType)) { // We need to recognize which was expected type(s) - $expectedStringTypes = array(); + $expectedStringTypes = []; // Validate state field type if ($expectedType & AST\PathExpression::TYPE_STATE_FIELD) { @@ -929,11 +929,11 @@ class Parser $identVariable = $this->lexer->token['value']; - $this->deferredIdentificationVariables[] = array( + $this->deferredIdentificationVariables[] = [ 'expression' => $identVariable, 'nestingLevel' => $this->nestingLevel, 'token' => $this->lexer->token, - ); + ]; return $identVariable; } @@ -1028,11 +1028,11 @@ class Parser $resultVariable = $this->lexer->token['value']; // Defer ResultVariable validation - $this->deferredResultVariables[] = array( + $this->deferredResultVariables[] = [ 'expression' => $resultVariable, 'nestingLevel' => $this->nestingLevel, 'token' => $this->lexer->token, - ); + ]; return $resultVariable; } @@ -1100,11 +1100,11 @@ class Parser $pathExpr = new AST\PathExpression($expectedTypes, $identVariable, $field); // Defer PathExpression validation if requested to be deferred - $this->deferredPathExpressions[] = array( + $this->deferredPathExpressions[] = [ 'expression' => $pathExpr, 'nestingLevel' => $this->nestingLevel, 'token' => $this->lexer->token, - ); + ]; return $pathExpr; } @@ -1183,7 +1183,7 @@ class Parser } // Process SelectExpressions (1..N) - $selectExpressions = array(); + $selectExpressions = []; $selectExpressions[] = $this->SelectExpression(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { @@ -1237,20 +1237,20 @@ class Parser $class = $this->em->getClassMetadata($abstractSchemaName); // Building queryComponent - $queryComponent = array( + $queryComponent = [ 'metadata' => $class, 'parent' => null, 'relation' => null, 'map' => null, 'nestingLevel' => $this->nestingLevel, 'token' => $token, - ); + ]; $this->queryComponents[$aliasIdentificationVariable] = $queryComponent; $this->match(Lexer::T_SET); - $updateItems = array(); + $updateItems = []; $updateItems[] = $this->UpdateItem(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { @@ -1295,14 +1295,14 @@ class Parser $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName); // Building queryComponent - $queryComponent = array( + $queryComponent = [ 'metadata' => $class, 'parent' => null, 'relation' => null, 'map' => null, 'nestingLevel' => $this->nestingLevel, 'token' => $token, - ); + ]; $this->queryComponents[$aliasIdentificationVariable] = $queryComponent; @@ -1318,7 +1318,7 @@ class Parser { $this->match(Lexer::T_FROM); - $identificationVariableDeclarations = array(); + $identificationVariableDeclarations = []; $identificationVariableDeclarations[] = $this->IdentificationVariableDeclaration(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { @@ -1339,7 +1339,7 @@ class Parser { $this->match(Lexer::T_FROM); - $identificationVariables = array(); + $identificationVariables = []; $identificationVariables[] = $this->SubselectIdentificationVariableDeclaration(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { @@ -1385,7 +1385,7 @@ class Parser $this->match(Lexer::T_GROUP); $this->match(Lexer::T_BY); - $groupByItems = array($this->GroupByItem()); + $groupByItems = [$this->GroupByItem()]; while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); @@ -1406,7 +1406,7 @@ class Parser $this->match(Lexer::T_ORDER); $this->match(Lexer::T_BY); - $orderByItems = array(); + $orderByItems = []; $orderByItems[] = $this->OrderByItem(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { @@ -1583,7 +1583,7 @@ class Parser */ public function IdentificationVariableDeclaration() { - $joins = array(); + $joins = []; $rangeVariableDeclaration = $this->RangeVariableDeclaration(); $indexBy = $this->lexer->isNextToken(Lexer::T_INDEX) ? $this->IndexBy() @@ -1739,14 +1739,14 @@ class Parser $classMetadata = $this->em->getClassMetadata($abstractSchemaName); // Building queryComponent - $queryComponent = array( + $queryComponent = [ 'metadata' => $classMetadata, 'parent' => null, 'relation' => null, 'map' => null, 'nestingLevel' => $this->nestingLevel, 'token' => $token - ); + ]; $this->queryComponents[$aliasIdentificationVariable] = $queryComponent; @@ -1776,14 +1776,14 @@ class Parser $targetClass = $this->em->getClassMetadata($class->associationMappings[$field]['targetEntity']); // Building queryComponent - $joinQueryComponent = array( + $joinQueryComponent = [ 'metadata' => $targetClass, 'parent' => $joinAssociationPathExpression->identificationVariable, 'relation' => $class->getAssociationMapping($field), 'map' => null, 'nestingLevel' => $this->nestingLevel, 'token' => $this->lexer->lookahead - ); + ]; $this->queryComponents[$aliasIdentificationVariable] = $joinQueryComponent; @@ -1800,7 +1800,7 @@ class Parser { $this->match(Lexer::T_PARTIAL); - $partialFieldSet = array(); + $partialFieldSet = []; $identificationVariable = $this->IdentificationVariable(); @@ -1822,15 +1822,15 @@ class Parser while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $this->match(Lexer::T_IDENTIFIER); - + $field = $this->lexer->token['value']; - + while ($this->lexer->isNextToken(Lexer::T_DOT)) { $this->match(Lexer::T_DOT); $this->match(Lexer::T_IDENTIFIER); $field .= '.'.$this->lexer->token['value']; } - + $partialFieldSet[] = $field; } @@ -1839,11 +1839,11 @@ class Parser $partialObjectExpression = new AST\PartialObjectExpression($identificationVariable, $partialFieldSet); // Defer PartialObjectExpression validation - $this->deferredPartialObjectExpressions[] = array( + $this->deferredPartialObjectExpressions[] = [ 'expression' => $partialObjectExpression, 'nestingLevel' => $this->nestingLevel, 'token' => $this->lexer->token, - ); + ]; return $partialObjectExpression; } @@ -1875,11 +1875,11 @@ class Parser $expression = new AST\NewObjectExpression($className, $args); // Defer NewObjectExpression validation - $this->deferredNewObjectExpressions[] = array( + $this->deferredNewObjectExpressions[] = [ 'token' => $token, 'expression' => $expression, 'nestingLevel' => $this->nestingLevel, - ); + ]; return $expression; } @@ -2058,7 +2058,7 @@ class Parser $this->match(Lexer::T_OPEN_PARENTHESIS); // Process ScalarExpressions (1..N) - $scalarExpressions = array(); + $scalarExpressions = []; $scalarExpressions[] = $this->ScalarExpression(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { @@ -2101,7 +2101,7 @@ class Parser $this->match(Lexer::T_CASE); // Process WhenClause (1..N) - $whenClauses = array(); + $whenClauses = []; do { $whenClauses[] = $this->WhenClause(); @@ -2126,7 +2126,7 @@ class Parser $caseOperand = $this->StateFieldPathExpression(); // Process SimpleWhenClause (1..N) - $simpleWhenClauses = array(); + $simpleWhenClauses = []; do { $simpleWhenClauses[] = $this->SimpleWhenClause(); @@ -2283,11 +2283,11 @@ class Parser $aliasResultVariable = $this->AliasResultVariable(); // Include AliasResultVariable in query components. - $this->queryComponents[$aliasResultVariable] = array( + $this->queryComponents[$aliasResultVariable] = [ 'resultVariable' => $expression, 'nestingLevel' => $this->nestingLevel, 'token' => $token, - ); + ]; } // AST @@ -2377,11 +2377,11 @@ class Parser $expr->fieldIdentificationVariable = $resultVariable; // Include AliasResultVariable in query components. - $this->queryComponents[$resultVariable] = array( + $this->queryComponents[$resultVariable] = [ 'resultvariable' => $expr, 'nestingLevel' => $this->nestingLevel, 'token' => $token, - ); + ]; } return $expr; @@ -2394,7 +2394,7 @@ class Parser */ public function ConditionalExpression() { - $conditionalTerms = array(); + $conditionalTerms = []; $conditionalTerms[] = $this->ConditionalTerm(); while ($this->lexer->isNextToken(Lexer::T_OR)) { @@ -2419,7 +2419,7 @@ class Parser */ public function ConditionalTerm() { - $conditionalFactors = array(); + $conditionalFactors = []; $conditionalFactors[] = $this->ConditionalFactor(); while ($this->lexer->isNextToken(Lexer::T_AND)) { @@ -2484,8 +2484,8 @@ class Parser // Peek beyond the matching closing parenthesis ')' $peek = $this->peekBeyondClosingParenthesis(); - if (in_array($peek['value'], array("=", "<", "<=", "<>", ">", ">=", "!=")) || - in_array($peek['type'], array(Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_IN, Lexer::T_IS, Lexer::T_EXISTS)) || + if (in_array($peek['value'], ["=", "<", "<=", "<>", ">", ">=", "!="]) || + in_array($peek['type'], [Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_IN, Lexer::T_IS, Lexer::T_EXISTS]) || $this->isMathOperator($peek)) { $condPrimary->simpleConditionalExpression = $this->SimpleConditionalExpression(); @@ -2741,7 +2741,7 @@ class Parser */ public function SimpleArithmeticExpression() { - $terms = array(); + $terms = []; $terms[] = $this->ArithmeticTerm(); while (($isPlus = $this->lexer->isNextToken(Lexer::T_PLUS)) || $this->lexer->isNextToken(Lexer::T_MINUS)) { @@ -2767,7 +2767,7 @@ class Parser */ public function ArithmeticTerm() { - $factors = array(); + $factors = []; $factors[] = $this->ArithmeticFactor(); while (($isMult = $this->lexer->isNextToken(Lexer::T_MULTIPLY)) || $this->lexer->isNextToken(Lexer::T_DIVIDE)) { @@ -2988,7 +2988,7 @@ class Parser $lookaheadType = $this->lexer->lookahead['type']; $isDistinct = false; - if ( ! in_array($lookaheadType, array(Lexer::T_COUNT, Lexer::T_AVG, Lexer::T_MAX, Lexer::T_MIN, Lexer::T_SUM))) { + if ( ! in_array($lookaheadType, [Lexer::T_COUNT, Lexer::T_AVG, Lexer::T_MAX, Lexer::T_MIN, Lexer::T_SUM])) { $this->syntaxError('One of: MAX, MIN, AVG, SUM, COUNT'); } @@ -3018,7 +3018,7 @@ class Parser $lookaheadType = $this->lexer->lookahead['type']; $value = $this->lexer->lookahead['value']; - if ( ! in_array($lookaheadType, array(Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME))) { + if ( ! in_array($lookaheadType, [Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME])) { $this->syntaxError('ALL, ANY or SOME'); } @@ -3097,7 +3097,7 @@ class Parser if ($this->lexer->isNextToken(Lexer::T_SELECT)) { $inExpression->subselect = $this->Subselect(); } else { - $literals = array(); + $literals = []; $literals[] = $this->InParameter(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { @@ -3130,7 +3130,7 @@ class Parser $this->match(Lexer::T_INSTANCE); $this->match(Lexer::T_OF); - $exprValues = array(); + $exprValues = []; if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { $this->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/ParserResult.php b/lib/Doctrine/ORM/Query/ParserResult.php index dfc7361f8..84ad17822 100644 --- a/lib/Doctrine/ORM/Query/ParserResult.php +++ b/lib/Doctrine/ORM/Query/ParserResult.php @@ -51,7 +51,7 @@ class ParserResult * * @var array */ - private $_parameterMappings = array(); + private $_parameterMappings = []; /** * Initializes a new instance of the ParserResult class. diff --git a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php index 73a1b4dd1..dbdaeb40c 100644 --- a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php +++ b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php @@ -37,12 +37,12 @@ class QueryExpressionVisitor extends ExpressionVisitor /** * @var array */ - private static $operatorMap = array( + private static $operatorMap = [ Comparison::GT => Expr\Comparison::GT, Comparison::GTE => Expr\Comparison::GTE, Comparison::LT => Expr\Comparison::LT, Comparison::LTE => Expr\Comparison::LTE - ); + ]; /** * @var array @@ -57,7 +57,7 @@ class QueryExpressionVisitor extends ExpressionVisitor /** * @var array */ - private $parameters = array(); + private $parameters = []; /** * Constructor @@ -88,7 +88,7 @@ class QueryExpressionVisitor extends ExpressionVisitor */ public function clearParameters() { - $this->parameters = array(); + $this->parameters = []; } /** @@ -108,7 +108,7 @@ class QueryExpressionVisitor extends ExpressionVisitor */ public function walkCompositeExpression(CompositeExpression $expr) { - $expressionList = array(); + $expressionList = []; foreach ($expr->getExpressionList() as $child) { $expressionList[] = $this->dispatch($child); @@ -160,11 +160,11 @@ class QueryExpressionVisitor extends ExpressionVisitor switch ($comparison->getOperator()) { case Comparison::IN: $this->parameters[] = $parameter; - + return $this->expr->in($field, $placeholder); case Comparison::NIN: $this->parameters[] = $parameter; - + return $this->expr->notIn($field, $placeholder); case Comparison::EQ: case Comparison::IS: @@ -172,19 +172,19 @@ class QueryExpressionVisitor extends ExpressionVisitor return $this->expr->isNull($field); } $this->parameters[] = $parameter; - + return $this->expr->eq($field, $placeholder); case Comparison::NEQ: if ($this->walkValue($comparison->getValue()) === null) { return $this->expr->isNotNull($field); } $this->parameters[] = $parameter; - + return $this->expr->neq($field, $placeholder); case Comparison::CONTAINS: $parameter->setValue('%' . $parameter->getValue() . '%', $parameter->getType()); $this->parameters[] = $parameter; - + return $this->expr->like($field, $placeholder); default: $operator = self::convertComparisonOperator($comparison->getOperator()); diff --git a/lib/Doctrine/ORM/Query/ResultSetMapping.php b/lib/Doctrine/ORM/Query/ResultSetMapping.php index b80acf0cc..5c4550980 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMapping.php +++ b/lib/Doctrine/ORM/Query/ResultSetMapping.php @@ -57,7 +57,7 @@ class ResultSetMapping * @ignore * @var array */ - public $aliasMap = array(); + public $aliasMap = []; /** * Maps alias names to related association field names. @@ -65,7 +65,7 @@ class ResultSetMapping * @ignore * @var array */ - public $relationMap = array(); + public $relationMap = []; /** * Maps alias names to parent alias names. @@ -73,7 +73,7 @@ class ResultSetMapping * @ignore * @var array */ - public $parentAliasMap = array(); + public $parentAliasMap = []; /** * Maps column names in the result set to field names for each class. @@ -81,7 +81,7 @@ class ResultSetMapping * @ignore * @var array */ - public $fieldMappings = array(); + public $fieldMappings = []; /** * Maps column names in the result set to the alias/field name to use in the mapped result. @@ -89,7 +89,7 @@ class ResultSetMapping * @ignore * @var array */ - public $scalarMappings = array(); + public $scalarMappings = []; /** * Maps column names in the result set to the alias/field type to use in the mapped result. @@ -97,7 +97,7 @@ class ResultSetMapping * @ignore * @var array */ - public $typeMappings = array(); + public $typeMappings = []; /** * Maps entities in the result set to the alias name to use in the mapped result. @@ -105,7 +105,7 @@ class ResultSetMapping * @ignore * @var array */ - public $entityMappings = array(); + public $entityMappings = []; /** * Maps column names of meta columns (foreign keys, discriminator columns, ...) to field names. @@ -113,7 +113,7 @@ class ResultSetMapping * @ignore * @var array */ - public $metaMappings = array(); + public $metaMappings = []; /** * Maps column names in the result set to the alias they belong to. @@ -121,7 +121,7 @@ class ResultSetMapping * @ignore * @var array */ - public $columnOwnerMap = array(); + public $columnOwnerMap = []; /** * List of columns in the result set that are used as discriminator columns. @@ -129,7 +129,7 @@ class ResultSetMapping * @ignore * @var array */ - public $discriminatorColumns = array(); + public $discriminatorColumns = []; /** * Maps alias names to field names that should be used for indexing. @@ -137,7 +137,7 @@ class ResultSetMapping * @ignore * @var array */ - public $indexByMap = array(); + public $indexByMap = []; /** * Map from column names to class names that declare the field the column is mapped to. @@ -145,28 +145,28 @@ class ResultSetMapping * @ignore * @var array */ - public $declaringClasses = array(); + public $declaringClasses = []; /** * This is necessary to hydrate derivate foreign keys correctly. * * @var array */ - public $isIdentifierColumn = array(); + public $isIdentifierColumn = []; /** * Maps column names in the result set to field names for each new object expression. * * @var array */ - public $newObjectMappings = array(); + public $newObjectMappings = []; /** * Maps metadata parameter names to the metadata attribute. * * @var array */ - public $metadataParameterMapping = array(); + public $metadataParameterMapping = []; /** * Adds an entity result to this ResultSetMapping. diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 73eb5ae5a..887d02c6f 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -97,7 +97,7 @@ class ResultSetMappingBuilder extends ResultSetMapping * * @return void */ - public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = array(), $renameMode = null) + public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = [], $renameMode = null) { $renameMode = $renameMode ?: $this->defaultRenameMode; $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); @@ -119,7 +119,7 @@ class ResultSetMappingBuilder extends ResultSetMapping * * @return void */ - public function addJoinedEntityFromClassMetadata($class, $alias, $parentAlias, $relation, $renamedColumns = array(), $renameMode = null) + public function addJoinedEntityFromClassMetadata($class, $alias, $parentAlias, $relation, $renamedColumns = [], $renameMode = null) { $renameMode = $renameMode ?: $this->defaultRenameMode; $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); @@ -139,7 +139,7 @@ class ResultSetMappingBuilder extends ResultSetMapping * * @throws \InvalidArgumentException */ - protected function addAllClassFields($class, $alias, $columnAliasMap = array()) + protected function addAllClassFields($class, $alias, $columnAliasMap = []) { $classMetadata = $this->em->getClassMetadata($class); $platform = $this->em->getConnection()->getDatabasePlatform(); @@ -232,7 +232,7 @@ class ResultSetMappingBuilder extends ResultSetMapping $mode = self::COLUMN_RENAMING_CUSTOM; } - $columnAlias = array(); + $columnAlias = []; $class = $this->em->getClassMetadata($className); foreach ($class->getColumnNames() as $columnName) { @@ -436,7 +436,7 @@ class ResultSetMappingBuilder extends ResultSetMapping * * @return string */ - public function generateSelectClause($tableAliases = array()) + public function generateSelectClause($tableAliases = []) { $sql = ""; @@ -470,6 +470,6 @@ class ResultSetMappingBuilder extends ResultSetMapping */ public function __toString() { - return $this->generateSelectClause(array()); + return $this->generateSelectClause([]); } } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 6e607ffa9..fb6efb9c7 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -109,28 +109,28 @@ class SqlWalker implements TreeWalker /** * @var array */ - private $tableAliasMap = array(); + private $tableAliasMap = []; /** * Map from result variable names to their SQL column alias names. * * @var array */ - private $scalarResultAliasMap = array(); + private $scalarResultAliasMap = []; /** * Map from Table-Alias + Column-Name to OrderBy-Direction. * * @var array */ - private $orderedColumnsMap = array(); + private $orderedColumnsMap = []; /** * Map from DQL-Alias + Field-Name to SQL Column Alias. * * @var array */ - private $scalarFields = array(); + private $scalarFields = []; /** * Map of all components/classes that appear in the DQL query. @@ -144,14 +144,14 @@ class SqlWalker implements TreeWalker * * @var array */ - private $selectedClasses = array(); + private $selectedClasses = []; /** * The DQL alias of the root class of the currently traversed query. * * @var array */ - private $rootAliases = array(); + private $rootAliases = []; /** * Flag that indicates whether to generate SQL table aliases in the SQL. @@ -245,7 +245,7 @@ class SqlWalker implements TreeWalker */ public function setQueryComponent($dqlAlias, array $queryComponent) { - $requiredKeys = array('metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token'); + $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; if (array_diff($requiredKeys, array_keys($queryComponent))) { throw QueryException::invalidQueryComponent($dqlAlias); @@ -354,7 +354,7 @@ class SqlWalker implements TreeWalker $sql .= isset($this->queryComponents[$dqlAlias]['relation']) ? ' LEFT ' : ' INNER '; $sql .= 'JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; - $sqlParts = array(); + $sqlParts = []; foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) { $sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName; @@ -380,7 +380,7 @@ class SqlWalker implements TreeWalker $sql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON '; - $sqlParts = array(); + $sqlParts = []; foreach ($this->quoteStrategy->getIdentifierColumnNames($subClass, $this->platform) as $columnName) { $sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName; @@ -397,7 +397,7 @@ class SqlWalker implements TreeWalker */ private function _generateOrderedCollectionOrderByItems() { - $orderedColumns = array(); + $orderedColumns = []; foreach ($this->selectedClasses as $selectedClass) { $dqlAlias = $selectedClass['dqlAlias']; @@ -439,7 +439,7 @@ class SqlWalker implements TreeWalker */ private function _generateDiscriminatorColumnConditionSQL(array $dqlAliases) { - $sqlParts = array(); + $sqlParts = []; foreach ($dqlAliases as $dqlAlias) { $class = $this->queryComponents[$dqlAlias]['metadata']; @@ -447,7 +447,7 @@ class SqlWalker implements TreeWalker if ( ! $class->isInheritanceTypeSingleTable()) continue; $conn = $this->em->getConnection(); - $values = array(); + $values = []; if ($class->discriminatorValue !== null) { // discriminators can be 0 $values[] = $conn->quote($class->discriminatorValue); @@ -503,7 +503,7 @@ class SqlWalker implements TreeWalker return ''; } - $filterClauses = array(); + $filterClauses = []; foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { $filterClauses[] = '(' . $filterExpr . ')'; @@ -606,7 +606,7 @@ class SqlWalker implements TreeWalker { $class = $this->queryComponents[$identVariable]['metadata']; $tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable); - $sqlParts = array(); + $sqlParts = []; foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) { $sqlParts[] = $tableAlias . '.' . $columnName; @@ -699,7 +699,7 @@ class SqlWalker implements TreeWalker public function walkSelectClause($selectClause) { $sql = 'SELECT ' . (($selectClause->isDistinct) ? 'DISTINCT ' : ''); - $sqlSelectExpressions = array_filter(array_map(array($this, 'walkSelectExpression'), $selectClause->selectExpressions)); + $sqlSelectExpressions = array_filter(array_map([$this, 'walkSelectExpression'], $selectClause->selectExpressions)); if ($this->query->getHint(Query::HINT_INTERNAL_ITERATION) == true && $selectClause->isDistinct) { $this->query->setHint(self::HINT_DISTINCT, true); @@ -812,7 +812,7 @@ class SqlWalker implements TreeWalker public function walkFromClause($fromClause) { $identificationVarDecls = $fromClause->identificationVariableDeclarations; - $sqlParts = array(); + $sqlParts = []; foreach ($identificationVarDecls as $identificationVariableDecl) { $sqlParts[] = $this->walkIdentificationVariableDeclaration($identificationVariableDecl); @@ -937,7 +937,7 @@ class SqlWalker implements TreeWalker // The owning side is necessary at this point because only it contains the JoinColumn information. switch (true) { case ($assoc['type'] & ClassMetadata::TO_ONE): - $conditions = array(); + $conditions = []; foreach ($assoc['joinColumns'] as $joinColumn) { $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); @@ -953,7 +953,7 @@ class SqlWalker implements TreeWalker } // Apply remaining inheritance restrictions - $discrSql = $this->_generateDiscriminatorColumnConditionSQL(array($joinedDqlAlias)); + $discrSql = $this->_generateDiscriminatorColumnConditionSQL([$joinedDqlAlias]); if ($discrSql) { $conditions[] = $discrSql; @@ -966,10 +966,10 @@ class SqlWalker implements TreeWalker $conditions[] = $filterExpr; } - $targetTableJoin = array( + $targetTableJoin = [ 'table' => $targetTableName . ' ' . $targetTableAlias, 'condition' => implode(' AND ', $conditions), - ); + ]; break; case ($assoc['type'] == ClassMetadata::MANY_TO_MANY): @@ -978,7 +978,7 @@ class SqlWalker implements TreeWalker $joinTableAlias = $this->getSQLTableAlias($joinTable['name'], $joinedDqlAlias); $joinTableName = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->platform); - $conditions = array(); + $conditions = []; $relationColumns = ($relation['isOwningSide']) ? $assoc['joinTable']['joinColumns'] : $assoc['joinTable']['inverseJoinColumns']; @@ -995,7 +995,7 @@ class SqlWalker implements TreeWalker // Join target table $sql .= ($joinType == AST\Join::JOIN_TYPE_LEFT || $joinType == AST\Join::JOIN_TYPE_LEFTOUTER) ? ' LEFT JOIN ' : ' INNER JOIN '; - $conditions = array(); + $conditions = []; $relationColumns = ($relation['isOwningSide']) ? $assoc['joinTable']['inverseJoinColumns'] : $assoc['joinTable']['joinColumns']; @@ -1008,7 +1008,7 @@ class SqlWalker implements TreeWalker } // Apply remaining inheritance restrictions - $discrSql = $this->_generateDiscriminatorColumnConditionSQL(array($joinedDqlAlias)); + $discrSql = $this->_generateDiscriminatorColumnConditionSQL([$joinedDqlAlias]); if ($discrSql) { $conditions[] = $discrSql; @@ -1021,10 +1021,10 @@ class SqlWalker implements TreeWalker $conditions[] = $filterExpr; } - $targetTableJoin = array( + $targetTableJoin = [ 'table' => $targetTableName . ' ' . $targetTableAlias, 'condition' => implode(' AND ', $conditions), - ); + ]; break; default: @@ -1074,7 +1074,7 @@ class SqlWalker implements TreeWalker */ public function walkOrderByClause($orderByClause) { - $orderByItems = array_map(array($this, 'walkOrderByItem'), $orderByClause->orderByItems); + $orderByItems = array_map([$this, 'walkOrderByItem'], $orderByClause->orderByItems); if (($collectionOrderByItems = $this->_generateOrderedCollectionOrderByItems()) !== '') { $orderByItems = array_merge($orderByItems, (array) $collectionOrderByItems); @@ -1141,7 +1141,7 @@ class SqlWalker implements TreeWalker $sql .= $this->walkRangeVariableDeclaration($joinDeclaration); // Apply remaining inheritance restrictions - $discrSql = $this->_generateDiscriminatorColumnConditionSQL(array($dqlAlias)); + $discrSql = $this->_generateDiscriminatorColumnConditionSQL([$dqlAlias]); if ($discrSql) { $conditions[] = $discrSql; @@ -1206,7 +1206,7 @@ class SqlWalker implements TreeWalker { $sql = 'COALESCE('; - $scalarExpressions = array(); + $scalarExpressions = []; foreach ($coalesceExpression->scalarExpressions as $scalarExpression) { $scalarExpressions[] = $this->walkSimpleArithmeticExpression($scalarExpression); @@ -1375,7 +1375,7 @@ class SqlWalker implements TreeWalker $partialFieldSet = $expr->partialFieldSet; } else { $dqlAlias = $expr; - $partialFieldSet = array(); + $partialFieldSet = []; } $queryComp = $this->queryComponents[$dqlAlias]; @@ -1383,14 +1383,14 @@ class SqlWalker implements TreeWalker $resultAlias = $selectExpression->fieldIdentificationVariable ?: null; if ( ! isset($this->selectedClasses[$dqlAlias])) { - $this->selectedClasses[$dqlAlias] = array( + $this->selectedClasses[$dqlAlias] = [ 'class' => $class, 'dqlAlias' => $dqlAlias, 'resultAlias' => $resultAlias - ); + ]; } - $sqlParts = array(); + $sqlParts = []; // Select all fields from the queried class foreach ($class->fieldMappings as $fieldName => $mapping) { @@ -1475,7 +1475,7 @@ class SqlWalker implements TreeWalker $useAliasesBefore = $this->useSqlTableAliases; $rootAliasesBefore = $this->rootAliases; - $this->rootAliases = array(); // reset the rootAliases for the subselect + $this->rootAliases = []; // reset the rootAliases for the subselect $this->useSqlTableAliases = true; $sql = $this->walkSimpleSelectClause($subselect->simpleSelectClause); @@ -1498,7 +1498,7 @@ class SqlWalker implements TreeWalker public function walkSubselectFromClause($subselectFromClause) { $identificationVarDecls = $subselectFromClause->identificationVariableDeclarations; - $sqlParts = array (); + $sqlParts = []; foreach ($identificationVarDecls as $subselectIdVarDecl) { $sqlParts[] = $this->walkIdentificationVariableDeclaration($subselectIdVarDecl); @@ -1533,7 +1533,7 @@ class SqlWalker implements TreeWalker */ public function walkNewObject($newObjectExpression, $newObjectResultAlias=null) { - $sqlSelectExpressions = array(); + $sqlSelectExpressions = []; $objIndex = $newObjectResultAlias?:$this->newObjectCounter++; foreach ($newObjectExpression->args as $argIndex => $e) { @@ -1581,11 +1581,11 @@ class SqlWalker implements TreeWalker $this->scalarResultAliasMap[$resultAlias] = $columnAlias; $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldType); - $this->rsm->newObjectMappings[$columnAlias] = array( + $this->rsm->newObjectMappings[$columnAlias] = [ 'className' => $newObjectExpression->className, 'objIndex' => $objIndex, 'argIndex' => $argIndex - ); + ]; } return implode(', ', $sqlSelectExpressions); @@ -1662,7 +1662,7 @@ class SqlWalker implements TreeWalker */ public function walkGroupByClause($groupByClause) { - $sqlParts = array(); + $sqlParts = []; foreach ($groupByClause->groupByItems as $groupByItem) { $sqlParts[] = $this->walkGroupByItem($groupByItem); @@ -1697,7 +1697,7 @@ class SqlWalker implements TreeWalker } // IdentificationVariable - $sqlParts = array(); + $sqlParts = []; foreach ($this->queryComponents[$groupByItem]['metadata']->fieldNames as $field) { $item = new AST\PathExpression(AST\PathExpression::TYPE_STATE_FIELD, $groupByItem, $field); @@ -1745,7 +1745,7 @@ class SqlWalker implements TreeWalker $this->setSQLTableAlias($tableName, $tableName, $updateClause->aliasIdentificationVariable); $this->rootAliases[] = $updateClause->aliasIdentificationVariable; - $sql .= ' SET ' . implode(', ', array_map(array($this, 'walkUpdateItem'), $updateClause->updateItems)); + $sql .= ' SET ' . implode(', ', array_map([$this, 'walkUpdateItem'], $updateClause->updateItems)); return $sql; } @@ -1789,7 +1789,7 @@ class SqlWalker implements TreeWalker $discrSql = $this->_generateDiscriminatorColumnConditionSql($this->rootAliases); if ($this->em->hasFilters()) { - $filterClauses = array(); + $filterClauses = []; foreach ($this->rootAliases as $dqlAlias) { $class = $this->queryComponents[$dqlAlias]['metadata']; $tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias); @@ -1830,7 +1830,7 @@ class SqlWalker implements TreeWalker return $this->walkConditionalTerm($condExpr); } - return implode(' OR ', array_map(array($this, 'walkConditionalTerm'), $condExpr->conditionalTerms)); + return implode(' OR ', array_map([$this, 'walkConditionalTerm'], $condExpr->conditionalTerms)); } /** @@ -1844,7 +1844,7 @@ class SqlWalker implements TreeWalker return $this->walkConditionalFactor($condTerm); } - return implode(' AND ', array_map(array($this, 'walkConditionalFactor'), $condTerm->conditionalFactors)); + return implode(' AND ', array_map([$this, 'walkConditionalFactor'], $condTerm->conditionalFactors)); } /** @@ -1929,7 +1929,7 @@ class SqlWalker implements TreeWalker $sql .= $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' WHERE '; $owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']]; - $sqlParts = array(); + $sqlParts = []; foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) { $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $this->platform); @@ -1963,7 +1963,7 @@ class SqlWalker implements TreeWalker // join conditions $joinColumns = $assoc['isOwningSide'] ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns']; - $joinSqlParts = array(); + $joinSqlParts = []; foreach ($joinColumns as $joinColumn) { $targetColumn = $this->quoteStrategy->getColumnName($targetClass->fieldNames[$joinColumn['referencedColumnName']], $targetClass, $this->platform); @@ -1975,7 +1975,7 @@ class SqlWalker implements TreeWalker $sql .= ' WHERE '; $joinColumns = $assoc['isOwningSide'] ? $joinTable['joinColumns'] : $joinTable['inverseJoinColumns']; - $sqlParts = array(); + $sqlParts = []; foreach ($joinColumns as $joinColumn) { $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$joinColumn['referencedColumnName']], $class, $this->platform); @@ -2038,7 +2038,7 @@ class SqlWalker implements TreeWalker $sql .= ($inExpr->subselect) ? $this->walkSubselect($inExpr->subselect) - : implode(', ', array_map(array($this, 'walkInParameter'), $inExpr->literals)); + : implode(', ', array_map([$this, 'walkInParameter'], $inExpr->literals)); $sql .= ')'; @@ -2065,7 +2065,7 @@ class SqlWalker implements TreeWalker $sql .= $class->discriminatorColumn['name'] . ($instanceOfExpr->not ? ' NOT IN ' : ' IN '); - $sqlParameterList = array(); + $sqlParameterList = []; foreach ($instanceOfExpr->value as $parameter) { if ($parameter instanceof AST\InputParameter) { @@ -2239,7 +2239,7 @@ class SqlWalker implements TreeWalker return $this->walkArithmeticTerm($simpleArithmeticExpr); } - return implode(' ', array_map(array($this, 'walkArithmeticTerm'), $simpleArithmeticExpr->arithmeticTerms)); + return implode(' ', array_map([$this, 'walkArithmeticTerm'], $simpleArithmeticExpr->arithmeticTerms)); } /** @@ -2259,7 +2259,7 @@ class SqlWalker implements TreeWalker return $this->walkArithmeticFactor($term); } - return implode(' ', array_map(array($this, 'walkArithmeticFactor'), $term->arithmeticFactors)); + return implode(' ', array_map([$this, 'walkArithmeticFactor'], $term->arithmeticFactors)); } /** diff --git a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php index 529d855aa..deee03ab5 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php @@ -72,7 +72,7 @@ abstract class TreeWalkerAdapter implements TreeWalker */ public function setQueryComponent($dqlAlias, array $queryComponent) { - $requiredKeys = array('metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token'); + $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; if (array_diff($requiredKeys, array_keys($queryComponent))) { throw QueryException::invalidQueryComponent($dqlAlias); diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChain.php b/lib/Doctrine/ORM/Query/TreeWalkerChain.php index 573ef88ff..074aa9387 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerChain.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerChain.php @@ -72,7 +72,7 @@ class TreeWalkerChain implements TreeWalker */ public function setQueryComponent($dqlAlias, array $queryComponent) { - $requiredKeys = array('metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token'); + $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; if (array_diff($requiredKeys, array_keys($queryComponent))) { throw QueryException::invalidQueryComponent($dqlAlias); diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php b/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php index 30db08175..e72e1d4dc 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php @@ -27,7 +27,7 @@ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess /** * @var TreeWalker[] */ - private $walkers = array(); + private $walkers = []; /** * @var TreeWalkerChain */ diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 455e39ab3..70b55f17d 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -57,17 +57,17 @@ class QueryBuilder * * @var array */ - private $_dqlParts = array( + private $_dqlParts = [ 'distinct' => false, - 'select' => array(), - 'from' => array(), - 'join' => array(), - 'set' => array(), + 'select' => [], + 'from' => [], + 'join' => [], + 'set' => [], 'where' => null, - 'groupBy' => array(), + 'groupBy' => [], 'having' => null, - 'orderBy' => array() - ); + 'orderBy' => [] + ]; /** * The type of query this is. Can be select, update or delete. @@ -116,7 +116,7 @@ class QueryBuilder * * @var array */ - private $joinRootAliases = array(); + private $joinRootAliases = []; /** * Whether to use second level cache, if available. @@ -444,7 +444,7 @@ class QueryBuilder */ public function getRootAliases() { - $aliases = array(); + $aliases = []; foreach ($this->_dqlParts['from'] as &$fromClause) { if (is_string($fromClause)) { @@ -496,7 +496,7 @@ class QueryBuilder */ public function getRootEntities() { - $entities = array(); + $entities = []; foreach ($this->_dqlParts['from'] as &$fromClause) { if (is_string($fromClause)) { @@ -707,7 +707,7 @@ class QueryBuilder // This is introduced for backwards compatibility reasons. // TODO: Remove for 3.0 if ($dqlPartName == 'join') { - $newDqlPart = array(); + $newDqlPart = []; foreach ($dqlPart as $k => $v) { $k = is_numeric($k) ? $this->getRootAlias() : $k; @@ -727,7 +727,7 @@ class QueryBuilder $this->_dqlParts[$dqlPartName][] = $dqlPart; } } else { - $this->_dqlParts[$dqlPartName] = ($isMultiple) ? array($dqlPart) : $dqlPart; + $this->_dqlParts[$dqlPartName] = ($isMultiple) ? [$dqlPart] : $dqlPart; } $this->_state = self::STATE_DIRTY; @@ -990,7 +990,7 @@ class QueryBuilder Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition, $indexBy ); - return $this->add('join', array($rootAlias => $join), true); + return $this->add('join', [$rootAlias => $join], true); } /** @@ -1025,7 +1025,7 @@ class QueryBuilder Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition, $indexBy ); - return $this->add('join', array($rootAlias => $join), true); + return $this->add('join', [$rootAlias => $join], true); } /** @@ -1374,9 +1374,9 @@ class QueryBuilder private function _getDQLForDelete() { return 'DELETE' - . $this->_getReducedDQLQueryPart('from', array('pre' => ' ', 'separator' => ', ')) - . $this->_getReducedDQLQueryPart('where', array('pre' => ' WHERE ')) - . $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', ')); + . $this->_getReducedDQLQueryPart('from', ['pre' => ' ', 'separator' => ', ']) + . $this->_getReducedDQLQueryPart('where', ['pre' => ' WHERE ']) + . $this->_getReducedDQLQueryPart('orderBy', ['pre' => ' ORDER BY ', 'separator' => ', ']); } /** @@ -1385,10 +1385,10 @@ class QueryBuilder private function _getDQLForUpdate() { return 'UPDATE' - . $this->_getReducedDQLQueryPart('from', array('pre' => ' ', 'separator' => ', ')) - . $this->_getReducedDQLQueryPart('set', array('pre' => ' SET ', 'separator' => ', ')) - . $this->_getReducedDQLQueryPart('where', array('pre' => ' WHERE ')) - . $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', ')); + . $this->_getReducedDQLQueryPart('from', ['pre' => ' ', 'separator' => ', ']) + . $this->_getReducedDQLQueryPart('set', ['pre' => ' SET ', 'separator' => ', ']) + . $this->_getReducedDQLQueryPart('where', ['pre' => ' WHERE ']) + . $this->_getReducedDQLQueryPart('orderBy', ['pre' => ' ORDER BY ', 'separator' => ', ']); } /** @@ -1398,11 +1398,11 @@ class QueryBuilder { $dql = 'SELECT' . ($this->_dqlParts['distinct']===true ? ' DISTINCT' : '') - . $this->_getReducedDQLQueryPart('select', array('pre' => ' ', 'separator' => ', ')); + . $this->_getReducedDQLQueryPart('select', ['pre' => ' ', 'separator' => ', ']); $fromParts = $this->getDQLPart('from'); $joinParts = $this->getDQLPart('join'); - $fromClauses = array(); + $fromClauses = []; // Loop through all FROM clauses if ( ! empty($fromParts)) { @@ -1422,10 +1422,10 @@ class QueryBuilder } $dql .= implode(', ', $fromClauses) - . $this->_getReducedDQLQueryPart('where', array('pre' => ' WHERE ')) - . $this->_getReducedDQLQueryPart('groupBy', array('pre' => ' GROUP BY ', 'separator' => ', ')) - . $this->_getReducedDQLQueryPart('having', array('pre' => ' HAVING ')) - . $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', ')); + . $this->_getReducedDQLQueryPart('where', ['pre' => ' WHERE ']) + . $this->_getReducedDQLQueryPart('groupBy', ['pre' => ' GROUP BY ', 'separator' => ', ']) + . $this->_getReducedDQLQueryPart('having', ['pre' => ' HAVING ']) + . $this->_getReducedDQLQueryPart('orderBy', ['pre' => ' ORDER BY ', 'separator' => ', ']); return $dql; } @@ -1436,7 +1436,7 @@ class QueryBuilder * * @return string */ - private function _getReducedDQLQueryPart($queryPartName, $options = array()) + private function _getReducedDQLQueryPart($queryPartName, $options = []) { $queryPart = $this->getDQLPart($queryPartName); @@ -1478,7 +1478,7 @@ class QueryBuilder */ public function resetDQLPart($part) { - $this->_dqlParts[$part] = is_array($this->_dqlParts[$part]) ? array() : null; + $this->_dqlParts[$part] = is_array($this->_dqlParts[$part]) ? [] : null; $this->_state = self::STATE_DIRTY; return $this; @@ -1514,7 +1514,7 @@ class QueryBuilder } } - $parameters = array(); + $parameters = []; foreach ($this->parameters as $parameter) { $parameters[] = clone $parameter; diff --git a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php b/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php index 12163eff6..680962413 100644 --- a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php +++ b/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php @@ -34,7 +34,7 @@ final class DefaultRepositoryFactory implements RepositoryFactory * * @var \Doctrine\Common\Persistence\ObjectRepository[] */ - private $repositoryList = array(); + private $repositoryList = []; /** * {@inheritdoc} diff --git a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php index bb0ca81b2..cf7cc8b8b 100644 --- a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php +++ b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php @@ -33,7 +33,7 @@ class AttachEntityListenersListener /** * @var array[] */ - private $entityListeners = array(); + private $entityListeners = []; /** * Adds a entity listener for a specific entity. @@ -47,11 +47,11 @@ class AttachEntityListenersListener */ public function addEntityListener($entityClass, $listenerClass, $eventName, $listenerCallback = null) { - $this->entityListeners[ltrim($entityClass, '\\')][] = array( + $this->entityListeners[ltrim($entityClass, '\\')][] = [ 'event' => $eventName, 'class' => $listenerClass, 'method' => $listenerCallback ?: $eventName - ); + ]; } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php index e23d36b24..5bc0c859d 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php @@ -46,12 +46,14 @@ class MetadataCommand extends Command $this ->setName('orm:clear-cache:metadata') ->setDescription('Clear all metadata cache of the various cache drivers.') - ->setDefinition(array( - new InputOption( - 'flush', null, InputOption::VALUE_NONE, - 'If defined, cache entries will be flushed instead of deleted/invalidated.' - ) - )); + ->setDefinition( + [ + new InputOption( + 'flush', null, InputOption::VALUE_NONE, + 'If defined, cache entries will be flushed instead of deleted/invalidated.' + ) + ] + ); $this->setHelp(<<%command.name% command is meant to clear the metadata cache of associated Entity Manager. diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php index f1be98d30..5828d0771 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php @@ -46,12 +46,14 @@ class QueryCommand extends Command $this ->setName('orm:clear-cache:query') ->setDescription('Clear all query cache of the various cache drivers.') - ->setDefinition(array( - new InputOption( - 'flush', null, InputOption::VALUE_NONE, - 'If defined, cache entries will be flushed instead of deleted/invalidated.' - ) - )); + ->setDefinition( + [ + new InputOption( + 'flush', null, InputOption::VALUE_NONE, + 'If defined, cache entries will be flushed instead of deleted/invalidated.' + ) + ] + ); $this->setHelp(<<%command.name% command is meant to clear the query cache of associated Entity Manager. @@ -91,7 +93,7 @@ EOT if ($cacheDriver instanceof XcacheCache) { throw new \LogicException("Cannot clear XCache Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); } - + $output->write('Clearing ALL Query cache entries' . PHP_EOL); $result = $cacheDriver->deleteAll(); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php index c21f55452..55b89efa8 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php @@ -46,12 +46,14 @@ class ResultCommand extends Command $this ->setName('orm:clear-cache:result') ->setDescription('Clear all result cache of the various cache drivers.') - ->setDefinition(array( - new InputOption( - 'flush', null, InputOption::VALUE_NONE, - 'If defined, cache entries will be flushed instead of deleted/invalidated.' - ) - )); + ->setDefinition( + [ + new InputOption( + 'flush', null, InputOption::VALUE_NONE, + 'If defined, cache entries will be flushed instead of deleted/invalidated.' + ) + ] + ); $this->setHelp(<<%command.name% command is meant to clear the result cache of associated Entity Manager. @@ -92,7 +94,7 @@ EOT if ($cacheDriver instanceof XcacheCache) { throw new \LogicException("Cannot clear XCache Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); } - + $output->writeln('Clearing ALL Result cache entries'); $result = $cacheDriver->deleteAll(); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php index 71d72deb8..ee370dd0f 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php @@ -102,33 +102,35 @@ class ConvertDoctrine1SchemaCommand extends Command { $this ->setName('orm:convert-d1-schema') - ->setAliases(array('orm:convert:d1-schema')) + ->setAliases(['orm:convert:d1-schema']) ->setDescription('Converts Doctrine 1.X schema into a Doctrine 2.X schema.') - ->setDefinition(array( - new InputArgument( - 'from-path', InputArgument::REQUIRED, 'The path of Doctrine 1.X schema information.' - ), - new InputArgument( - 'to-type', InputArgument::REQUIRED, 'The destination Doctrine 2.X mapping type.' - ), - new InputArgument( - 'dest-path', InputArgument::REQUIRED, - 'The path to generate your Doctrine 2.X mapping information.' - ), - new InputOption( - 'from', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'Optional paths of Doctrine 1.X schema information.', - array() - ), - new InputOption( - 'extend', null, InputOption::VALUE_OPTIONAL, - 'Defines a base class to be extended by generated entity classes.' - ), - new InputOption( - 'num-spaces', null, InputOption::VALUE_OPTIONAL, - 'Defines the number of indentation spaces', 4 - ) - )) + ->setDefinition( + [ + new InputArgument( + 'from-path', InputArgument::REQUIRED, 'The path of Doctrine 1.X schema information.' + ), + new InputArgument( + 'to-type', InputArgument::REQUIRED, 'The destination Doctrine 2.X mapping type.' + ), + new InputArgument( + 'dest-path', InputArgument::REQUIRED, + 'The path to generate your Doctrine 2.X mapping information.' + ), + new InputOption( + 'from', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'Optional paths of Doctrine 1.X schema information.', + [] + ), + new InputOption( + 'extend', null, InputOption::VALUE_OPTIONAL, + 'Defines a base class to be extended by generated entity classes.' + ), + new InputOption( + 'num-spaces', null, InputOption::VALUE_OPTIONAL, + 'Defines the number of indentation spaces', 4 + ) + ] + ) ->setHelp(<<getArgument('from-path')), $input->getOption('from')); + $fromPaths = array_merge([$input->getArgument('from-path')], $input->getOption('from')); // Process destination directory $destPath = realpath($input->getArgument('dest-path')); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php index b229f4a6c..798dbe728 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php @@ -49,40 +49,42 @@ class ConvertMappingCommand extends Command { $this ->setName('orm:convert-mapping') - ->setAliases(array('orm:convert:mapping')) + ->setAliases(['orm:convert:mapping']) ->setDescription('Convert mapping information between supported formats.') - ->setDefinition(array( - new InputOption( - 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'A string pattern used to match entities that should be processed.' - ), - new InputArgument( - 'to-type', InputArgument::REQUIRED, 'The mapping type to be converted.' - ), - new InputArgument( - 'dest-path', InputArgument::REQUIRED, - 'The path to generate your entities classes.' - ), - new InputOption( - 'force', 'f', InputOption::VALUE_NONE, - 'Force to overwrite existing mapping files.' - ), - new InputOption( - 'from-database', null, null, 'Whether or not to convert mapping information from existing database.' - ), - new InputOption( - 'extend', null, InputOption::VALUE_OPTIONAL, - 'Defines a base class to be extended by generated entity classes.' - ), - new InputOption( - 'num-spaces', null, InputOption::VALUE_OPTIONAL, - 'Defines the number of indentation spaces', 4 - ), - new InputOption( - 'namespace', null, InputOption::VALUE_OPTIONAL, - 'Defines a namespace for the generated entity classes, if converted from database.' - ), - )) + ->setDefinition( + [ + new InputOption( + 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'A string pattern used to match entities that should be processed.' + ), + new InputArgument( + 'to-type', InputArgument::REQUIRED, 'The mapping type to be converted.' + ), + new InputArgument( + 'dest-path', InputArgument::REQUIRED, + 'The path to generate your entities classes.' + ), + new InputOption( + 'force', 'f', InputOption::VALUE_NONE, + 'Force to overwrite existing mapping files.' + ), + new InputOption( + 'from-database', null, null, 'Whether or not to convert mapping information from existing database.' + ), + new InputOption( + 'extend', null, InputOption::VALUE_OPTIONAL, + 'Defines a base class to be extended by generated entity classes.' + ), + new InputOption( + 'num-spaces', null, InputOption::VALUE_OPTIONAL, + 'Defines the number of indentation spaces', 4 + ), + new InputOption( + 'namespace', null, InputOption::VALUE_OPTIONAL, + 'Defines a namespace for the generated entity classes, if converted from database.' + ), + ] + ) ->setHelp(<<setName('orm:ensure-production-settings') ->setDescription('Verify that Doctrine is properly configured for a production environment.') - ->setDefinition(array( - new InputOption( - 'complete', null, InputOption::VALUE_NONE, - 'Flag to also inspect database connection existence.' - ) - )) + ->setDefinition( + [ + new InputOption( + 'complete', null, InputOption::VALUE_NONE, + 'Flag to also inspect database connection existence.' + ) + ] + ) ->setHelp(<<setName('orm:generate-entities') - ->setAliases(array('orm:generate:entities')) + ->setAliases(['orm:generate:entities']) ->setDescription('Generate entity classes and method stubs from your mapping information.') - ->setDefinition(array( - new InputOption( - 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'A string pattern used to match entities that should be processed.' - ), - new InputArgument( - 'dest-path', InputArgument::REQUIRED, 'The path to generate your entity classes.' - ), - new InputOption( - 'generate-annotations', null, InputOption::VALUE_OPTIONAL, - 'Flag to define if generator should generate annotation metadata on entities.', false - ), - new InputOption( - 'generate-methods', null, InputOption::VALUE_OPTIONAL, - 'Flag to define if generator should generate stub methods on entities.', true - ), - new InputOption( - 'regenerate-entities', null, InputOption::VALUE_OPTIONAL, - 'Flag to define if generator should regenerate entity if it exists.', false - ), - new InputOption( - 'update-entities', null, InputOption::VALUE_OPTIONAL, - 'Flag to define if generator should only update entity if it exists.', true - ), - new InputOption( - 'extend', null, InputOption::VALUE_REQUIRED, - 'Defines a base class to be extended by generated entity classes.' - ), - new InputOption( - 'num-spaces', null, InputOption::VALUE_REQUIRED, - 'Defines the number of indentation spaces', 4 - ), - new InputOption( - 'no-backup', null, InputOption::VALUE_NONE, - 'Flag to define if generator should avoid backuping existing entity file if it exists.' - ) - )) + ->setDefinition( + [ + new InputOption( + 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'A string pattern used to match entities that should be processed.' + ), + new InputArgument( + 'dest-path', InputArgument::REQUIRED, 'The path to generate your entity classes.' + ), + new InputOption( + 'generate-annotations', null, InputOption::VALUE_OPTIONAL, + 'Flag to define if generator should generate annotation metadata on entities.', false + ), + new InputOption( + 'generate-methods', null, InputOption::VALUE_OPTIONAL, + 'Flag to define if generator should generate stub methods on entities.', true + ), + new InputOption( + 'regenerate-entities', null, InputOption::VALUE_OPTIONAL, + 'Flag to define if generator should regenerate entity if it exists.', false + ), + new InputOption( + 'update-entities', null, InputOption::VALUE_OPTIONAL, + 'Flag to define if generator should only update entity if it exists.', true + ), + new InputOption( + 'extend', null, InputOption::VALUE_REQUIRED, + 'Defines a base class to be extended by generated entity classes.' + ), + new InputOption( + 'num-spaces', null, InputOption::VALUE_REQUIRED, + 'Defines the number of indentation spaces', 4 + ), + new InputOption( + 'no-backup', null, InputOption::VALUE_NONE, + 'Flag to define if generator should avoid backuping existing entity file if it exists.' + ) + ] + ) ->setHelp(<<setName('orm:generate-proxies') - ->setAliases(array('orm:generate:proxies')) + ->setAliases(['orm:generate:proxies']) ->setDescription('Generates proxy classes for entity classes.') - ->setDefinition(array( - new InputOption( - 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'A string pattern used to match entities that should be processed.' - ), - new InputArgument( - 'dest-path', InputArgument::OPTIONAL, - 'The path to generate your proxy classes. If none is provided, it will attempt to grab from configuration.' - ), - )) + ->setDefinition( + [ + new InputOption( + 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'A string pattern used to match entities that should be processed.' + ), + new InputArgument( + 'dest-path', InputArgument::OPTIONAL, + 'The path to generate your proxy classes. If none is provided, it will attempt to grab from configuration.' + ), + ] + ) ->setHelp(<<setName('orm:generate-repositories') - ->setAliases(array('orm:generate:repositories')) + ->setAliases(['orm:generate:repositories']) ->setDescription('Generate repository classes from your mapping information.') - ->setDefinition(array( - new InputOption( - 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'A string pattern used to match entities that should be processed.' - ), - new InputArgument( - 'dest-path', InputArgument::REQUIRED, 'The path to generate your repository classes.' - ) - )) + ->setDefinition( + [ + new InputOption( + 'filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'A string pattern used to match entities that should be processed.' + ), + new InputArgument( + 'dest-path', InputArgument::REQUIRED, 'The path to generate your repository classes.' + ) + ] + ) ->setHelp(<<setHeaders(array('Field', 'Value')); + $table->setHeaders(['Field', 'Value']); $metadata = $this->getClassMetadata($entityName, $entityManager); array_map( - array($table, 'addRow'), + [$table, 'addRow'], array_merge( - array( + [ $this->formatField('Name', $metadata->name), $this->formatField('Root entity name', $metadata->rootEntityName), $this->formatField('Custom generator definition', $metadata->customGeneratorDefinition), @@ -118,10 +118,10 @@ EOT $this->formatField('Read only?', $metadata->isReadOnly), $this->formatEntityListeners($metadata->entityListeners), - ), - array($this->formatField('Association mappings:', '')), + ], + [$this->formatField('Association mappings:', '')], $this->formatMappings($metadata->associationMappings), - array($this->formatField('Field mappings:', '')), + [$this->formatField('Field mappings:', '')], $this->formatMappings($metadata->fieldMappings) ) ); @@ -251,7 +251,7 @@ EOT $value = 'None'; } - return array(sprintf('%s', $label), $this->formatValue($value)); + return [sprintf('%s', $label), $this->formatValue($value)]; } /** @@ -263,7 +263,7 @@ EOT */ private function formatMappings(array $propertyMappings) { - $output = array(); + $output = []; foreach ($propertyMappings as $propertyName => $mapping) { $output[] = $this->formatField(sprintf(' %s', $propertyName), ''); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php index abd999aef..b246850a9 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php @@ -46,30 +46,32 @@ class RunDqlCommand extends Command $this ->setName('orm:run-dql') ->setDescription('Executes arbitrary DQL directly from the command line.') - ->setDefinition(array( - new InputArgument('dql', InputArgument::REQUIRED, 'The DQL to execute.'), - new InputOption( - 'hydrate', null, InputOption::VALUE_REQUIRED, - 'Hydration mode of result set. Should be either: object, array, scalar or single-scalar.', - 'object' - ), - new InputOption( - 'first-result', null, InputOption::VALUE_REQUIRED, - 'The first result in the result set.' - ), - new InputOption( - 'max-result', null, InputOption::VALUE_REQUIRED, - 'The maximum number of results in the result set.' - ), - new InputOption( - 'depth', null, InputOption::VALUE_REQUIRED, - 'Dumping depth of Entity graph.', 7 - ), - new InputOption( - 'show-sql', null, InputOption::VALUE_NONE, - 'Dump generated SQL instead of executing query' - ) - )) + ->setDefinition( + [ + new InputArgument('dql', InputArgument::REQUIRED, 'The DQL to execute.'), + new InputOption( + 'hydrate', null, InputOption::VALUE_REQUIRED, + 'Hydration mode of result set. Should be either: object, array, scalar or single-scalar.', + 'object' + ), + new InputOption( + 'first-result', null, InputOption::VALUE_REQUIRED, + 'The first result in the result set.' + ), + new InputOption( + 'max-result', null, InputOption::VALUE_REQUIRED, + 'The maximum number of results in the result set.' + ), + new InputOption( + 'depth', null, InputOption::VALUE_REQUIRED, + 'Dumping depth of Entity graph.', 7 + ), + new InputOption( + 'show-sql', null, InputOption::VALUE_NONE, + 'Dump generated SQL instead of executing query' + ) + ] + ) ->setHelp(<<execute(array(), constant($hydrationMode)); + $resultSet = $query->execute([], constant($hydrationMode)); $output->writeln(Debug::dump($resultSet, $input->getOption('depth'), true, false)); } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php index b2af0ca2c..73fbcbabb 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php @@ -46,12 +46,14 @@ class CreateCommand extends AbstractCommand ->setDescription( 'Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output.' ) - ->setDefinition(array( - new InputOption( - 'dump-sql', null, InputOption::VALUE_NONE, - 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.' - ) - )) + ->setDefinition( + [ + new InputOption( + 'dump-sql', null, InputOption::VALUE_NONE, + 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.' + ) + ] + ) ->setHelp(<<setDescription( 'Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output.' ) - ->setDefinition(array( - new InputOption( - 'dump-sql', null, InputOption::VALUE_NONE, - 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.' - ), - new InputOption( - 'force', 'f', InputOption::VALUE_NONE, - "Don't ask for the deletion of the database, but force the operation to run." - ), - new InputOption( - 'full-database', null, InputOption::VALUE_NONE, - 'Instead of using the Class Metadata to detect the database table schema, drop ALL assets that the database contains.' - ), - )) + ->setDefinition( + [ + new InputOption( + 'dump-sql', null, InputOption::VALUE_NONE, + 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.' + ), + new InputOption( + 'force', 'f', InputOption::VALUE_NONE, + "Don't ask for the deletion of the database, but force the operation to run." + ), + new InputOption( + 'full-database', null, InputOption::VALUE_NONE, + 'Instead of using the Class Metadata to detect the database table schema, drop ALL assets that the database contains.' + ), + ] + ) ->setHelp(<<setDescription( 'Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.' ) - ->setDefinition(array( - new InputOption( - 'complete', null, InputOption::VALUE_NONE, - 'If defined, all assets of the database which are not relevant to the current metadata will be dropped.' - ), + ->setDefinition( + [ + new InputOption( + 'complete', null, InputOption::VALUE_NONE, + 'If defined, all assets of the database which are not relevant to the current metadata will be dropped.' + ), - new InputOption( - 'dump-sql', null, InputOption::VALUE_NONE, - 'Dumps the generated SQL statements to the screen (does not execute them).' - ), - new InputOption( - 'force', 'f', InputOption::VALUE_NONE, - 'Causes the generated SQL statements to be physically executed against your database.' - ), - )); + new InputOption( + 'dump-sql', null, InputOption::VALUE_NONE, + 'Dumps the generated SQL statements to the screen (does not execute them).' + ), + new InputOption( + 'force', 'f', InputOption::VALUE_NONE, + 'Causes the generated SQL statements to be physically executed against your database.' + ), + ] + ); $this->setHelp(<<%command.name% command generates the SQL needed to diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index 64f2abe69..706d99d33 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -40,10 +40,12 @@ class ConsoleRunner */ public static function createHelperSet(EntityManagerInterface $entityManager) { - return new HelperSet(array( - 'db' => new ConnectionHelper($entityManager->getConnection()), - 'em' => new EntityManagerHelper($entityManager) - )); + return new HelperSet( + [ + 'db' => new ConnectionHelper($entityManager->getConnection()), + 'em' => new EntityManagerHelper($entityManager) + ] + ); } /** @@ -54,7 +56,7 @@ class ConsoleRunner * * @return void */ - static public function run(HelperSet $helperSet, $commands = array()) + static public function run(HelperSet $helperSet, $commands = []) { $cli = self::createApplication($helperSet, $commands); $cli->run(); @@ -69,7 +71,7 @@ class ConsoleRunner * * @return \Symfony\Component\Console\Application */ - static public function createApplication(HelperSet $helperSet, $commands = array()) + static public function createApplication(HelperSet $helperSet, $commands = []) { $cli = new Application('Doctrine Command Line Interface', Version::VERSION); $cli->setCatchExceptions(true); @@ -87,29 +89,31 @@ class ConsoleRunner */ static public function addCommands(Application $cli) { - $cli->addCommands(array( - // DBAL Commands - new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), - new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), + $cli->addCommands( + [ + // DBAL Commands + new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), + new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), - // ORM Commands - new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), - new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), - new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), - new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), - new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), - new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), - new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), - new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), - new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), - new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), - new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), - new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), - new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), - new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(), - new \Doctrine\ORM\Tools\Console\Command\InfoCommand(), - new \Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand(), - )); + // ORM Commands + new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), + new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), + new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), + new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), + new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), + new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), + new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), + new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), + new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), + new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), + new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), + new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), + new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), + new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(), + new \Doctrine\ORM\Tools\Console\Command\InfoCommand(), + new \Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand(), + ] + ); } static public function printCliConfigTemplate() diff --git a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php b/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php index 5a72b7d6d..f480c3063 100644 --- a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php +++ b/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php @@ -35,7 +35,7 @@ class MetadataFilter extends \FilterIterator implements \Countable /** * @var array */ - private $filter = array(); + private $filter = []; /** * Filter Metadatas by one or more filter options. diff --git a/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php b/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php index 52f3c92b9..408cb52d2 100644 --- a/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php +++ b/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php @@ -44,12 +44,12 @@ class ConvertDoctrine1Schema /** * @var array */ - private $legacyTypeMap = array( + private $legacyTypeMap = [ // TODO: This list may need to be updated 'clob' => 'text', 'timestamp' => 'datetime', 'enum' => 'string' - ); + ]; /** * Constructor passes the directory or array of directories @@ -72,7 +72,7 @@ class ConvertDoctrine1Schema */ public function getMetadata() { - $schema = array(); + $schema = []; foreach ($this->from as $path) { if (is_dir($path)) { $files = glob($path . '/*.yml'); @@ -84,7 +84,7 @@ class ConvertDoctrine1Schema } } - $metadatas = array(); + $metadatas = []; foreach ($schema as $className => $mappingInformation) { $metadatas[] = $this->convertToClassMetadataInfo($className, $mappingInformation); } @@ -153,12 +153,12 @@ class ConvertDoctrine1Schema } if ( ! $id) { - $fieldMapping = array( + $fieldMapping = [ 'fieldName' => 'id', 'columnName' => 'id', 'type' => 'integer', 'id' => true - ); + ]; $metadata->mapField($fieldMapping); $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); } @@ -178,7 +178,7 @@ class ConvertDoctrine1Schema { if (is_string($column)) { $string = $column; - $column = array(); + $column = []; $column['type'] = $string; } @@ -208,7 +208,7 @@ class ConvertDoctrine1Schema throw ToolsException::couldNotMapDoctrine1Type($column['type']); } - $fieldMapping = array(); + $fieldMapping = []; if (isset($column['primary'])) { $fieldMapping['id'] = true; @@ -222,7 +222,7 @@ class ConvertDoctrine1Schema $fieldMapping['length'] = $column['length']; } - $allowed = array('precision', 'scale', 'unique', 'options', 'notnull', 'version'); + $allowed = ['precision', 'scale', 'unique', 'options', 'notnull', 'version']; foreach ($column as $key => $value) { if (in_array($key, $allowed)) { @@ -237,9 +237,9 @@ class ConvertDoctrine1Schema } elseif (isset($column['sequence'])) { $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); - $definition = array( + $definition = [ 'sequenceName' => is_array($column['sequence']) ? $column['sequence']['name']:$column['sequence'] - ); + ]; if (isset($column['sequence']['size'])) { $definition['allocationSize'] = $column['sequence']['size']; @@ -272,9 +272,9 @@ class ConvertDoctrine1Schema $type = (isset($index['type']) && $index['type'] == 'unique') ? 'uniqueConstraints' : 'indexes'; - $metadata->table[$type][$name] = array( + $metadata->table[$type][$name] = [ 'columns' => $index['fields'] - ); + ]; } } @@ -311,17 +311,17 @@ class ConvertDoctrine1Schema if (isset($relation['refClass'])) { $type = 'many'; $foreignType = 'many'; - $joinColumns = array(); + $joinColumns = []; } else { $type = isset($relation['type']) ? $relation['type'] : 'one'; $foreignType = isset($relation['foreignType']) ? $relation['foreignType'] : 'many'; - $joinColumns = array( - array( + $joinColumns = [ + [ 'name' => $relation['local'], 'referencedColumnName' => $relation['foreign'], 'onDelete' => isset($relation['onDelete']) ? $relation['onDelete'] : null, - ) - ); + ] + ]; } if ($type == 'one' && $foreignType == 'one') { @@ -332,7 +332,7 @@ class ConvertDoctrine1Schema $method = 'mapOneToMany'; } - $associationMapping = array(); + $associationMapping = []; $associationMapping['fieldName'] = $relation['alias']; $associationMapping['targetEntity'] = $relation['class']; $associationMapping['mappedBy'] = $relation['foreignAlias']; diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index 22d5b412a..03e964817 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -78,7 +78,7 @@ class EntityGenerator /** * @var array */ - protected $staticReflection = array(); + protected $staticReflection = []; /** * Number of spaces to use for indention in generated code. @@ -151,7 +151,7 @@ class EntityGenerator * * @var array */ - protected $typeAlias = array( + protected $typeAlias = [ Type::DATETIMETZ => '\DateTime', Type::DATETIME => '\DateTime', Type::DATE => '\DateTime', @@ -166,14 +166,14 @@ class EntityGenerator Type::JSON_ARRAY => 'array', Type::SIMPLE_ARRAY => 'array', Type::BOOLEAN => 'bool', - ); + ]; /** * Hash-map to handle generator types string. * * @var array */ - protected static $generatorStrategyMap = array( + protected static $generatorStrategyMap = [ ClassMetadataInfo::GENERATOR_TYPE_AUTO => 'AUTO', ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE => 'SEQUENCE', ClassMetadataInfo::GENERATOR_TYPE_TABLE => 'TABLE', @@ -181,30 +181,30 @@ class EntityGenerator ClassMetadataInfo::GENERATOR_TYPE_NONE => 'NONE', ClassMetadataInfo::GENERATOR_TYPE_UUID => 'UUID', ClassMetadataInfo::GENERATOR_TYPE_CUSTOM => 'CUSTOM' - ); + ]; /** * Hash-map to handle the change tracking policy string. * * @var array */ - protected static $changeTrackingPolicyMap = array( + protected static $changeTrackingPolicyMap = [ ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT => 'DEFERRED_IMPLICIT', ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT => 'DEFERRED_EXPLICIT', ClassMetadataInfo::CHANGETRACKING_NOTIFY => 'NOTIFY', - ); + ]; /** * Hash-map to handle the inheritance type string. * * @var array */ - protected static $inheritanceTypeMap = array( + protected static $inheritanceTypeMap = [ ClassMetadataInfo::INHERITANCE_TYPE_NONE => 'NONE', ClassMetadataInfo::INHERITANCE_TYPE_JOINED => 'JOINED', ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE => 'SINGLE_TABLE', ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS => 'TABLE_PER_CLASS', - ); + ]; /** * @var string @@ -376,7 +376,7 @@ public function __construct() if ( ! $this->isNew) { $this->parseTokensInEntityFile(file_get_contents($path)); } else { - $this->staticReflection[$metadata->name] = array('properties' => array(), 'methods' => array()); + $this->staticReflection[$metadata->name] = ['properties' => [], 'methods' => []]; } if ($this->backupExisting && file_exists($path)) { @@ -405,21 +405,21 @@ public function __construct() */ public function generateEntityClass(ClassMetadataInfo $metadata) { - $placeHolders = array( + $placeHolders = [ '', '', '', '', '' - ); + ]; - $replacements = array( + $replacements = [ $this->generateEntityNamespace($metadata), $this->generateEntityUse(), $this->generateEntityDocBlock($metadata), $this->generateEntityClassName($metadata), $this->generateEntityBody($metadata) - ); + ]; $code = str_replace($placeHolders, $replacements, static::$classTemplate) . "\n"; @@ -641,7 +641,7 @@ public function __construct() $stubMethods = $this->generateEntityStubMethods ? $this->generateEntityStubMethods($metadata) : null; $lifecycleCallbackMethods = $this->generateEntityLifecycleCallbackMethods($metadata); - $code = array(); + $code = []; if ($fieldMappingProperties) { $code[] = $fieldMappingProperties; @@ -683,7 +683,7 @@ public function __construct() return $this->generateEmbeddableConstructor($metadata); } - $collections = array(); + $collections = []; foreach ($metadata->associationMappings as $mapping) { if ($mapping['type'] & ClassMetadataInfo::TO_MANY) { @@ -705,14 +705,14 @@ public function __construct() */ private function generateEmbeddableConstructor(ClassMetadataInfo $metadata) { - $paramTypes = array(); - $paramVariables = array(); - $params = array(); - $fields = array(); + $paramTypes = []; + $paramVariables = []; + $params = []; + $fields = []; // Resort fields to put optional fields at the end of the method signature. - $requiredFields = array(); - $optionalFields = array(); + $requiredFields = []; + $optionalFields = []; foreach ($metadata->fieldMappings as $fieldMapping) { if (empty($fieldMapping['nullable'])) { @@ -777,11 +777,11 @@ public function __construct() $params = implode(', ', $params); } - $replacements = array( + $replacements = [ '' => implode("\n * ", $paramTags), '' => $params, '' => implode("\n" . $this->spaces, $fields), - ); + ]; $constructor = str_replace( array_keys($replacements), @@ -811,14 +811,14 @@ public function __construct() for ($i = 0; $i < $tokensCount; $i++) { $token = $tokens[$i]; - if (in_array($token[0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT), true)) { + if (in_array($token[0], [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT], true)) { continue; } if ($inNamespace) { - if (in_array($token[0], array(T_NS_SEPARATOR, T_STRING), true)) { + if (in_array($token[0], [T_NS_SEPARATOR, T_STRING], true)) { $lastSeenNamespace .= $token[1]; - } elseif (is_string($token) && in_array($token, array(';', '{'), true)) { + } elseif (is_string($token) && in_array($token, [';', '{'], true)) { $inNamespace = false; } } @@ -826,8 +826,8 @@ public function __construct() if ($inClass) { $inClass = false; $lastSeenClass = $lastSeenNamespace . ($lastSeenNamespace ? '\\' : '') . $token[1]; - $this->staticReflection[$lastSeenClass]['properties'] = array(); - $this->staticReflection[$lastSeenClass]['methods'] = array(); + $this->staticReflection[$lastSeenClass]['properties'] = []; + $this->staticReflection[$lastSeenClass]['methods'] = []; } if (T_NAMESPACE === $token[0]) { @@ -841,7 +841,7 @@ public function __construct() } elseif ($tokens[$i+2] == '&' && T_STRING === $tokens[$i+3][0]) { $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i+3][1]); } - } elseif (in_array($token[0], array(T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED), true) && T_FUNCTION !== $tokens[$i+2][0]) { + } elseif (in_array($token[0], [T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED], true) && T_FUNCTION !== $tokens[$i+2][0]) { $this->staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i+2][1], 1); } } @@ -921,7 +921,7 @@ public function __construct() ? new \ReflectionClass($metadata->name) : $metadata->reflClass; - $traits = array(); + $traits = []; while ($reflClass !== false) { $traits = array_merge($traits, $reflClass->getTraits()); @@ -996,20 +996,20 @@ public function __construct() */ protected function generateEntityDocBlock(ClassMetadataInfo $metadata) { - $lines = array(); + $lines = []; $lines[] = '/**'; $lines[] = ' * ' . $this->getClassName($metadata); if ($this->generateAnnotations) { $lines[] = ' *'; - $methods = array( + $methods = [ 'generateTableAnnotation', 'generateInheritanceAnnotation', 'generateDiscriminatorColumnAnnotation', 'generateDiscriminatorMapAnnotation', 'generateEntityAnnotation', - ); + ]; foreach ($methods as $method) { if ($code = $this->$method($metadata)) { @@ -1058,7 +1058,7 @@ public function __construct() return ''; } - $table = array(); + $table = []; if (isset($metadata->table['schema'])) { $table[] = 'schema="' . $metadata->table['schema'] . '"'; @@ -1093,9 +1093,9 @@ public function __construct() */ protected function generateTableConstraints($constraintName, array $constraints) { - $annotations = array(); + $annotations = []; foreach ($constraints as $name => $constraint) { - $columns = array(); + $columns = []; foreach ($constraint['columns'] as $column) { $columns[] = '"' . $column . '"'; } @@ -1142,7 +1142,7 @@ public function __construct() protected function generateDiscriminatorMapAnnotation(ClassMetadataInfo $metadata) { if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - $inheritanceClassMap = array(); + $inheritanceClassMap = []; foreach ($metadata->discriminatorMap as $type => $class) { $inheritanceClassMap[] .= '"' . $type . '" = "' . $class . '"'; @@ -1159,7 +1159,7 @@ public function __construct() */ protected function generateEntityStubMethods(ClassMetadataInfo $metadata) { - $methods = array(); + $methods = []; foreach ($metadata->fieldMappings as $fieldMapping) { if (isset($fieldMapping['declaredField']) && @@ -1240,7 +1240,7 @@ public function __construct() $joinColumns = $associationMapping['joinColumns']; } else { //@todo there is no way to retrieve targetEntity metadata - $joinColumns = array(); + $joinColumns = []; } foreach ($joinColumns as $joinColumn) { @@ -1281,7 +1281,7 @@ public function __construct() */ protected function generateEntityAssociationMappingProperties(ClassMetadataInfo $metadata) { - $lines = array(); + $lines = []; foreach ($metadata->associationMappings as $associationMapping) { if ($this->hasProperty($associationMapping['fieldName'], $metadata)) { @@ -1303,7 +1303,7 @@ public function __construct() */ protected function generateEntityFieldMappingProperties(ClassMetadataInfo $metadata) { - $lines = array(); + $lines = []; foreach ($metadata->fieldMappings as $fieldMapping) { if ($this->hasProperty($fieldMapping['fieldName'], $metadata) || @@ -1331,7 +1331,7 @@ public function __construct() */ protected function generateEntityEmbeddedProperties(ClassMetadataInfo $metadata) { - $lines = array(); + $lines = []; foreach ($metadata->embeddedClasses as $fieldName => $embeddedClass) { if (isset($embeddedClass['declaredField']) || $this->hasProperty($fieldName, $metadata)) { @@ -1358,7 +1358,7 @@ public function __construct() { $methodName = $type . Inflector::classify($fieldName); $variableName = Inflector::camelize($fieldName); - if (in_array($type, array("add", "remove"))) { + if (in_array($type, ["add", "remove"])) { $methodName = Inflector::singularize($methodName); $variableName = Inflector::singularize($variableName); } @@ -1380,7 +1380,7 @@ public function __construct() $methodTypeHint = '\\' . $typeHint . ' '; } - $replacements = array( + $replacements = [ '' => ucfirst($type) . ' ' . $variableName . '.', '' => $methodTypeHint, '' => $variableType . (null !== $defaultValue ? ('|' . $defaultValue) : ''), @@ -1389,7 +1389,7 @@ public function __construct() '' => $fieldName, '' => ($defaultValue !== null ) ? (' = ' . $defaultValue) : '', '' => $this->getClassName($metadata) - ); + ]; $method = str_replace( array_keys($replacements), @@ -1414,10 +1414,10 @@ public function __construct() } $this->staticReflection[$metadata->name]['methods'][] = $methodName; - $replacements = array( + $replacements = [ '' => $this->annotationsPrefix . ucfirst($name), '' => $methodName, - ); + ]; $method = str_replace( array_keys($replacements), @@ -1435,7 +1435,7 @@ public function __construct() */ protected function generateJoinColumnAnnotation(array $joinColumn) { - $joinColumnAnnot = array(); + $joinColumnAnnot = []; if (isset($joinColumn['name'])) { $joinColumnAnnot[] = 'name="' . $joinColumn['name'] . '"'; @@ -1472,7 +1472,7 @@ public function __construct() */ protected function generateAssociationMappingPropertyDocBlock(array $associationMapping, ClassMetadataInfo $metadata) { - $lines = array(); + $lines = []; $lines[] = $this->spaces . '/**'; if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) { @@ -1507,7 +1507,7 @@ public function __construct() $type = 'ManyToMany'; break; } - $typeOptions = array(); + $typeOptions = []; if (isset($associationMapping['targetEntity'])) { $typeOptions[] = 'targetEntity="' . $associationMapping['targetEntity'] . '"'; @@ -1522,7 +1522,7 @@ public function __construct() } if ($associationMapping['cascade']) { - $cascades = array(); + $cascades = []; if ($associationMapping['isCascadePersist']) $cascades[] = '"persist"'; if ($associationMapping['isCascadeRemove']) $cascades[] = '"remove"'; @@ -1531,7 +1531,7 @@ public function __construct() if ($associationMapping['isCascadeRefresh']) $cascades[] = '"refresh"'; if (count($cascades) === 5) { - $cascades = array('"all"'); + $cascades = ['"all"']; } $typeOptions[] = 'cascade={' . implode(',', $cascades) . '}'; @@ -1542,10 +1542,10 @@ public function __construct() } if (isset($associationMapping['fetch']) && $associationMapping['fetch'] !== ClassMetadataInfo::FETCH_LAZY) { - $fetchMap = array( + $fetchMap = [ ClassMetadataInfo::FETCH_EXTRA_LAZY => 'EXTRA_LAZY', ClassMetadataInfo::FETCH_EAGER => 'EAGER', - ); + ]; $typeOptions[] = 'fetch="' . $fetchMap[$associationMapping['fetch']] . '"'; } @@ -1555,7 +1555,7 @@ public function __construct() if (isset($associationMapping['joinColumns']) && $associationMapping['joinColumns']) { $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'JoinColumns({'; - $joinColumnsLines = array(); + $joinColumnsLines = []; foreach ($associationMapping['joinColumns'] as $joinColumn) { if ($joinColumnAnnot = $this->generateJoinColumnAnnotation($joinColumn)) { @@ -1568,7 +1568,7 @@ public function __construct() } if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) { - $joinTable = array(); + $joinTable = []; $joinTable[] = 'name="' . $associationMapping['joinTable']['name'] . '"'; if (isset($associationMapping['joinTable']['schema'])) { @@ -1578,7 +1578,7 @@ public function __construct() $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'JoinTable(' . implode(', ', $joinTable) . ','; $lines[] = $this->spaces . ' * joinColumns={'; - $joinColumnsLines = array(); + $joinColumnsLines = []; foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) { $joinColumnsLines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn); @@ -1588,7 +1588,7 @@ public function __construct() $lines[] = $this->spaces . ' * },'; $lines[] = $this->spaces . ' * inverseJoinColumns={'; - $inverseJoinColumnsLines = array(); + $inverseJoinColumnsLines = []; foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $joinColumn) { $inverseJoinColumnsLines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn); @@ -1624,7 +1624,7 @@ public function __construct() */ protected function generateFieldMappingPropertyDocBlock(array $fieldMapping, ClassMetadataInfo $metadata) { - $lines = array(); + $lines = []; $lines[] = $this->spaces . '/**'; $lines[] = $this->spaces . ' * @var ' . $this->getType($fieldMapping['type']) @@ -1633,7 +1633,7 @@ public function __construct() if ($this->generateAnnotations) { $lines[] = $this->spaces . ' *'; - $column = array(); + $column = []; if (isset($fieldMapping['columnName'])) { $column[] = 'name="' . $fieldMapping['columnName'] . '"'; } @@ -1686,7 +1686,7 @@ public function __construct() } if ($metadata->sequenceGeneratorDefinition) { - $sequenceGenerator = array(); + $sequenceGenerator = []; if (isset($metadata->sequenceGeneratorDefinition['sequenceName'])) { $sequenceGenerator[] = 'sequenceName="' . $metadata->sequenceGeneratorDefinition['sequenceName'] . '"'; @@ -1721,14 +1721,14 @@ public function __construct() */ protected function generateEmbeddedPropertyDocBlock(array $embeddedClass) { - $lines = array(); + $lines = []; $lines[] = $this->spaces . '/**'; $lines[] = $this->spaces . ' * @var \\' . ltrim($embeddedClass['class'], '\\'); if ($this->generateAnnotations) { $lines[] = $this->spaces . ' *'; - $embedded = array('class="' . $embeddedClass['class'] . '"'); + $embedded = ['class="' . $embeddedClass['class'] . '"']; if (isset($fieldMapping['columnPrefix'])) { $embedded[] = 'columnPrefix=' . var_export($embeddedClass['columnPrefix'], true); @@ -1833,7 +1833,7 @@ public function __construct() */ private function exportTableOptions(array $options) { - $optionsStr = array(); + $optionsStr = []; foreach ($options as $name => $option) { if (is_array($option)) { diff --git a/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php b/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php index f431588fb..927738cba 100644 --- a/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php @@ -57,11 +57,11 @@ class extends */ public function generateEntityRepositoryClass($fullClassName) { - $variables = array( + $variables = [ '' => $this->generateEntityRepositoryNamespace($fullClassName), '' => $this->generateEntityRepositoryName($fullClassName), '' => $this->generateClassName($fullClassName) - ); + ]; return str_replace(array_keys($variables), array_values($variables), self::$_template); } @@ -70,7 +70,7 @@ class extends * Generates the namespace, if class do not have namespace, return empty string instead. * * @param string $fullClassName - * + * * @return string $namespace */ private function getClassNamespace($fullClassName) @@ -82,9 +82,9 @@ class extends /** * Generates the class name - * + * * @param string $fullClassName - * + * * @return string */ private function generateClassName($fullClassName) @@ -102,7 +102,7 @@ class extends /** * Generates the namespace statement, if class do not have namespace, return empty string instead. - * + * * @param string $fullClassName The full repository class name. * * @return string $namespace @@ -158,7 +158,7 @@ class extends /** * @param string $repositoryName - * + * * @return \Doctrine\ORM\Tools\EntityRepositoryGenerator */ public function setDefaultRepositoryName($repositoryName) diff --git a/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php b/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php index 1ea2a3735..94c781bef 100644 --- a/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php @@ -32,13 +32,13 @@ class ClassMetadataExporter /** * @var array */ - private static $_exporterDrivers = array( + private static $_exporterDrivers = [ 'xml' => 'Doctrine\ORM\Tools\Export\Driver\XmlExporter', 'yaml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter', 'yml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter', 'php' => 'Doctrine\ORM\Tools\Export\Driver\PhpExporter', 'annotation' => 'Doctrine\ORM\Tools\Export\Driver\AnnotationExporter' - ); + ]; /** * Registers a new exporter driver class under a specified name. diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php index ae8650525..100e16fd0 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php @@ -35,7 +35,7 @@ abstract class AbstractExporter /** * @var array */ - protected $_metadata = array(); + protected $_metadata = []; /** * @var string|null diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php index 5d88901a5..00a4be596 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php @@ -40,7 +40,7 @@ class PhpExporter extends AbstractExporter */ public function exportClassMetadata(ClassMetadataInfo $metadata) { - $lines = array(); + $lines = []; $lines[] = 'associationMappings as $associationMapping) { - $cascade = array('remove', 'persist', 'refresh', 'merge', 'detach'); + $cascade = ['remove', 'persist', 'refresh', 'merge', 'detach']; foreach ($cascade as $key => $value) { if ( ! $associationMapping['isCascade'.ucfirst($value)]) { unset($cascade[$key]); @@ -99,14 +99,14 @@ class PhpExporter extends AbstractExporter } if (count($cascade) === 5) { - $cascade = array('all'); + $cascade = ['all']; } - $associationMappingArray = array( + $associationMappingArray = [ 'fieldName' => $associationMapping['fieldName'], 'targetEntity' => $associationMapping['targetEntity'], 'cascade' => $cascade, - ); + ]; if (isset($associationMapping['fetch'])) { $associationMappingArray['fetch'] = $associationMapping['fetch']; @@ -114,21 +114,21 @@ class PhpExporter extends AbstractExporter if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { $method = 'mapOneToOne'; - $oneToOneMappingArray = array( + $oneToOneMappingArray = [ 'mappedBy' => $associationMapping['mappedBy'], 'inversedBy' => $associationMapping['inversedBy'], 'joinColumns' => $associationMapping['isOwningSide'] ? $associationMapping['joinColumns'] : [], 'orphanRemoval' => $associationMapping['orphanRemoval'], - ); + ]; $associationMappingArray = array_merge($associationMappingArray, $oneToOneMappingArray); } elseif ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { $method = 'mapOneToMany'; - $potentialAssociationMappingIndexes = array( + $potentialAssociationMappingIndexes = [ 'mappedBy', 'orphanRemoval', 'orderBy', - ); + ]; foreach ($potentialAssociationMappingIndexes as $index) { if (isset($associationMapping[$index])) { $oneToManyMappingArray[$index] = $associationMapping[$index]; @@ -137,11 +137,11 @@ class PhpExporter extends AbstractExporter $associationMappingArray = array_merge($associationMappingArray, $oneToManyMappingArray); } elseif ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { $method = 'mapManyToMany'; - $potentialAssociationMappingIndexes = array( + $potentialAssociationMappingIndexes = [ 'mappedBy', 'joinTable', 'orderBy', - ); + ]; foreach ($potentialAssociationMappingIndexes as $index) { if (isset($associationMapping[$index])) { $manyToManyMappingArray[$index] = $associationMapping[$index]; diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php index ba41d9986..fbcbf42d1 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php @@ -126,7 +126,7 @@ class XmlExporter extends AbstractExporter $fields = $metadata->fieldMappings; - $id = array(); + $id = []; foreach ($fields as $name => $field) { if (isset($field['id']) && $field['id']) { $id[$name] = $field; @@ -136,10 +136,10 @@ class XmlExporter extends AbstractExporter foreach ($metadata->associationMappings as $name => $assoc) { if (isset($assoc['id']) && $assoc['id']) { - $id[$name] = array( + $id[$name] = [ 'fieldName' => $name, 'associationKey' => true - ); + ]; } } @@ -225,12 +225,12 @@ class XmlExporter extends AbstractExporter } } - $orderMap = array( + $orderMap = [ ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_ONE, ClassMetadataInfo::MANY_TO_MANY, - ); + ]; uasort($metadata->associationMappings, function($m1, $m2) use (&$orderMap){ $a1 = array_search($m1['type'], $orderMap); @@ -273,7 +273,7 @@ class XmlExporter extends AbstractExporter $associationMappingXml->addAttribute('fetch', $this->_getFetchModeString($associationMapping['fetch'])); } - $cascade = array(); + $cascade = []; if ($associationMapping['isCascadeRemove']) { $cascade[] = 'cascade-remove'; } @@ -295,7 +295,7 @@ class XmlExporter extends AbstractExporter } if (count($cascade) === 5) { - $cascade = array('cascade-all'); + $cascade = ['cascade-all']; } if ($cascade) { diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php index 7677ad950..b9a38f904 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php @@ -41,7 +41,7 @@ class YamlExporter extends AbstractExporter */ public function exportClassMetadata(ClassMetadataInfo $metadata) { - $array = array(); + $array = []; if ($metadata->isMappedSuperclass) { $array['type'] = 'mappedSuperclass'; @@ -91,7 +91,7 @@ class YamlExporter extends AbstractExporter $fieldMappings = $metadata->fieldMappings; - $ids = array(); + $ids = []; foreach ($fieldMappings as $name => $fieldMapping) { $fieldMapping['column'] = $fieldMapping['columnName']; @@ -118,13 +118,13 @@ class YamlExporter extends AbstractExporter if ($fieldMappings) { if ( ! isset($array['fields'])) { - $array['fields'] = array(); + $array['fields'] = []; } $array['fields'] = array_merge($array['fields'], $fieldMappings); } foreach ($metadata->associationMappings as $name => $associationMapping) { - $cascade = array(); + $cascade = []; if ($associationMapping['isCascadeRemove']) { $cascade[] = 'remove'; @@ -146,13 +146,13 @@ class YamlExporter extends AbstractExporter $cascade[] = 'detach'; } if (count($cascade) === 5) { - $cascade = array('all'); + $cascade = ['all']; } - $associationMappingArray = array( + $associationMappingArray = [ 'targetEntity' => $associationMapping['targetEntity'], 'cascade' => $cascade, - ); + ]; if (isset($associationMapping['fetch'])) { $associationMappingArray['fetch'] = $this->_getFetchModeString($associationMapping['fetch']); @@ -164,7 +164,7 @@ class YamlExporter extends AbstractExporter if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { $joinColumns = $associationMapping['isOwningSide'] ? $associationMapping['joinColumns'] : []; - $newJoinColumns = array(); + $newJoinColumns = []; foreach ($joinColumns as $joinColumn) { $newJoinColumns[$joinColumn['name']]['referencedColumnName'] = $joinColumn['referencedColumnName']; @@ -174,12 +174,12 @@ class YamlExporter extends AbstractExporter } } - $oneToOneMappingArray = array( + $oneToOneMappingArray = [ 'mappedBy' => $associationMapping['mappedBy'], 'inversedBy' => $associationMapping['inversedBy'], 'joinColumns' => $newJoinColumns, 'orphanRemoval' => $associationMapping['orphanRemoval'], - ); + ]; $associationMappingArray = array_merge($associationMappingArray, $oneToOneMappingArray); @@ -189,22 +189,22 @@ class YamlExporter extends AbstractExporter $array['manyToOne'][$name] = $associationMappingArray; } } elseif ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { - $oneToManyMappingArray = array( + $oneToManyMappingArray = [ 'mappedBy' => $associationMapping['mappedBy'], 'inversedBy' => $associationMapping['inversedBy'], 'orphanRemoval' => $associationMapping['orphanRemoval'], 'orderBy' => isset($associationMapping['orderBy']) ? $associationMapping['orderBy'] : null - ); + ]; $associationMappingArray = array_merge($associationMappingArray, $oneToManyMappingArray); $array['oneToMany'][$name] = $associationMappingArray; } elseif ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { - $manyToManyMappingArray = array( + $manyToManyMappingArray = [ 'mappedBy' => $associationMapping['mappedBy'], 'inversedBy' => $associationMapping['inversedBy'], 'joinTable' => isset($associationMapping['joinTable']) ? $associationMapping['joinTable'] : null, 'orderBy' => isset($associationMapping['orderBy']) ? $associationMapping['orderBy'] : null - ); + ]; $associationMappingArray = array_merge($associationMappingArray, $manyToManyMappingArray); $array['manyToMany'][$name] = $associationMappingArray; @@ -214,7 +214,7 @@ class YamlExporter extends AbstractExporter $array['lifecycleCallbacks'] = $metadata->lifecycleCallbacks; } - return $this->yamlDump(array($metadata->name => $array), 10); + return $this->yamlDump([$metadata->name => $array], 10); } /** diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index 2cfd029df..8d3163043 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -108,7 +108,7 @@ class CountOutputWalker extends SqlWalker $rootIdentifier = $rootClass->identifier; // For every identifier, find out the SQL alias by combing through the ResultSetMapping - $sqlIdentifier = array(); + $sqlIdentifier = []; foreach ($rootIdentifier as $property) { if (isset($rootClass->fieldMappings[$property])) { foreach (array_keys($this->rsm->fieldMappings, $property) as $alias) { diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php index 628bd4cd1..a8f26001a 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -59,11 +59,11 @@ class CountWalker extends TreeWalkerAdapter $queryComponents = $this->_getQueryComponents(); // Get the root entity and alias from the AST fromClause $from = $AST->fromClause->identificationVariableDeclarations; - + if (count($from) > 1) { throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); } - + $fromRoot = reset($from); $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $queryComponents[$rootAlias]['metadata']; @@ -81,11 +81,11 @@ class CountWalker extends TreeWalkerAdapter $pathExpression->type = $pathType; $distinct = $this->_getQuery()->getHint(self::HINT_DISTINCT); - $AST->selectClause->selectExpressions = array( + $AST->selectClause->selectExpressions = [ new SelectExpression( new AggregateExpression('count', $pathExpression, $distinct), null ) - ); + ]; // ORDER BY is not needed, only increases query execution through unnecessary sorting. $AST->orderByClause = null; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index b2a292ad9..1874eb88d 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -69,7 +69,7 @@ class LimitSubqueryWalker extends TreeWalkerAdapter $fromRoot = reset($from); $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $queryComponents[$rootAlias]['metadata']; - $selectExpressions = array(); + $selectExpressions = []; $this->validate($AST); @@ -80,9 +80,9 @@ class LimitSubqueryWalker extends TreeWalkerAdapter continue; } } - + $identifier = $rootClass->getSingleIdentifierFieldName(); - + if (isset($rootClass->associationMappings[$identifier])) { throw new \RuntimeException("Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator."); } @@ -109,7 +109,7 @@ class LimitSubqueryWalker extends TreeWalkerAdapter if ( ! $item->expression instanceof PathExpression) { continue; } - + $AST->selectClause->selectExpressions[] = new SelectExpression( $this->createSelectExpressionItem($item->expression), '_dctrn_ord' . $this->_aliasCounter++ @@ -154,24 +154,24 @@ class LimitSubqueryWalker extends TreeWalkerAdapter } } } - + /** * Retrieve either an IdentityFunction (IDENTITY(u.assoc)) or a state field (u.name). - * + * * @param \Doctrine\ORM\Query\AST\PathExpression $pathExpression - * + * * @return \Doctrine\ORM\Query\AST\Functions\IdentityFunction */ private function createSelectExpressionItem(PathExpression $pathExpression) { if ($pathExpression->type === PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION) { $identity = new IdentityFunction('identity'); - + $identity->pathExpression = clone $pathExpression; - + return $identity; } - + return clone $pathExpression; } } diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index 449aae1ca..aa2a22365 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -225,7 +225,7 @@ class Paginator implements \Countable, \IteratorAggregate $hints = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS); if ($hints === false) { - $hints = array(); + $hints = []; } $hints[] = $walkerClass; diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php index 1f54da100..5fa4e2d94 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -76,11 +76,11 @@ class WhereInWalker extends TreeWalkerAdapter $queryComponents = $this->_getQueryComponents(); // Get the root entity and alias from the AST fromClause $from = $AST->fromClause->identificationVariableDeclarations; - + if (count($from) > 1) { throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); } - + $fromRoot = reset($from); $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $queryComponents[$rootAlias]['metadata']; @@ -99,7 +99,7 @@ class WhereInWalker extends TreeWalkerAdapter if ($count > 0) { $arithmeticExpression = new ArithmeticExpression(); $arithmeticExpression->simpleArithmeticExpression = new SimpleArithmeticExpression( - array($pathExpression) + [$pathExpression] ); $expression = new InExpression($arithmeticExpression); $expression->literals[] = new InputParameter(":" . self::PAGINATOR_ID_ALIAS); @@ -115,29 +115,35 @@ class WhereInWalker extends TreeWalkerAdapter if ($AST->whereClause->conditionalExpression instanceof ConditionalTerm) { $AST->whereClause->conditionalExpression->conditionalFactors[] = $conditionalPrimary; } elseif ($AST->whereClause->conditionalExpression instanceof ConditionalPrimary) { - $AST->whereClause->conditionalExpression = new ConditionalExpression(array( - new ConditionalTerm(array( - $AST->whereClause->conditionalExpression, - $conditionalPrimary - )) - )); + $AST->whereClause->conditionalExpression = new ConditionalExpression( + [ + new ConditionalTerm( + [ + $AST->whereClause->conditionalExpression, + $conditionalPrimary + ] + ) + ] + ); } elseif ($AST->whereClause->conditionalExpression instanceof ConditionalExpression || $AST->whereClause->conditionalExpression instanceof ConditionalFactor ) { $tmpPrimary = new ConditionalPrimary; $tmpPrimary->conditionalExpression = $AST->whereClause->conditionalExpression; - $AST->whereClause->conditionalExpression = new ConditionalTerm(array( - $tmpPrimary, - $conditionalPrimary - )); + $AST->whereClause->conditionalExpression = new ConditionalTerm( + [ + $tmpPrimary, + $conditionalPrimary + ] + ); } } else { $AST->whereClause = new WhereClause( - new ConditionalExpression(array( - new ConditionalTerm(array( - $conditionalPrimary - )) - )) + new ConditionalExpression( + [ + new ConditionalTerm([$conditionalPrimary]) + ] + ) ); } } diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php index 574c9c28e..46488bf97 100644 --- a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -39,17 +39,17 @@ class ResolveTargetEntityListener implements EventSubscriber /** * @var array[] indexed by original entity name */ - private $resolveTargetEntities = array(); + private $resolveTargetEntities = []; /** * {@inheritDoc} */ public function getSubscribedEvents() { - return array( + return [ Events::loadClassMetadata, Events::onClassMetadataNotFound - ); + ]; } /** diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index da1a291d3..627f7b573 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -143,16 +143,16 @@ class SchemaTool public function getSchemaFromMetadata(array $classes) { // Reminder for processed classes, used for hierarchies - $processedClasses = array(); + $processedClasses = []; $eventManager = $this->em->getEventManager(); $schemaManager = $this->em->getConnection()->getSchemaManager(); $metadataSchemaConfig = $schemaManager->createSchemaConfig(); $metadataSchemaConfig->setExplicitForeignKeyIndexes(false); - $schema = new Schema(array(), array(), $metadataSchemaConfig); + $schema = new Schema([], [], $metadataSchemaConfig); - $addedFks = array(); - $blacklistedFks = array(); + $addedFks = []; + $blacklistedFks = []; foreach ($classes as $class) { /** @var \Doctrine\ORM\Mapping\ClassMetadata $class */ @@ -183,7 +183,7 @@ class SchemaTool } } elseif ($class->isInheritanceTypeJoined()) { // Add all non-inherited fields as columns - $pkColumns = array(); + $pkColumns = []; foreach ($class->fieldMappings as $fieldName => $mapping) { if ( ! isset($mapping['inherited'])) { $columnName = $this->quoteStrategy->getColumnName( @@ -206,7 +206,7 @@ class SchemaTool $this->addDiscriminatorColumnDefinition($class, $table); } else { // Add an ID FK column to child tables - $inheritedKeyColumns = array(); + $inheritedKeyColumns = []; foreach ($class->identifier as $identifierField) { $idMapping = $class->fieldMappings[$identifierField]; if (isset($idMapping['inherited'])) { @@ -232,7 +232,7 @@ class SchemaTool ), $inheritedKeyColumns, $inheritedKeyColumns, - array('onDelete' => 'CASCADE') + ['onDelete' => 'CASCADE'] ); } @@ -247,7 +247,7 @@ class SchemaTool $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks); } - $pkColumns = array(); + $pkColumns = []; foreach ($class->identifier as $identifierField) { if (isset($class->fieldMappings[$identifierField])) { @@ -280,10 +280,10 @@ class SchemaTool if (isset($class->table['indexes'])) { foreach ($class->table['indexes'] as $indexName => $indexData) { if ( ! isset($indexData['flags'])) { - $indexData['flags'] = array(); + $indexData['flags'] = []; } - $table->addIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, (array) $indexData['flags'], isset($indexData['options']) ? $indexData['options'] : array()); + $table->addIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, (array) $indexData['flags'], isset($indexData['options']) ? $indexData['options'] : []); } } @@ -298,7 +298,7 @@ class SchemaTool } } - $table->addUniqueIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, isset($indexData['options']) ? $indexData['options'] : array()); + $table->addUniqueIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, isset($indexData['options']) ? $indexData['options'] : []); } } @@ -365,10 +365,10 @@ class SchemaTool $discrColumn['length'] = 255; } - $options = array( + $options = [ 'length' => isset($discrColumn['length']) ? $discrColumn['length'] : null, 'notnull' => true - ); + ]; if (isset($discrColumn['columnDefinition'])) { $options['columnDefinition'] = $discrColumn['columnDefinition']; @@ -388,7 +388,7 @@ class SchemaTool */ private function gatherColumns($class, Table $table) { - $pkColumns = array(); + $pkColumns = []; foreach ($class->fieldMappings as $mapping) { if ($class->isInheritanceTypeSingleTable() && isset($mapping['inherited'])) { @@ -423,14 +423,14 @@ class SchemaTool $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); $columnType = $mapping['type']; - $options = array(); + $options = []; $options['length'] = isset($mapping['length']) ? $mapping['length'] : null; $options['notnull'] = isset($mapping['nullable']) ? ! $mapping['nullable'] : true; if ($class->isInheritanceTypeSingleTable() && $class->parentClasses) { $options['notnull'] = false; } - $options['platformOptions'] = array(); + $options['platformOptions'] = []; $options['platformOptions']['version'] = $class->isVersioned && $class->versionField === $mapping['fieldName']; if (strtolower($columnType) === 'string' && null === $options['length']) { @@ -454,7 +454,7 @@ class SchemaTool } if (isset($mapping['options'])) { - $knownOptions = array('comment', 'unsigned', 'fixed', 'default'); + $knownOptions = ['comment', 'unsigned', 'fixed', 'default']; foreach ($knownOptions as $knownOption) { if (array_key_exists($knownOption, $mapping['options'])) { @@ -467,7 +467,7 @@ class SchemaTool $options['customSchemaOptions'] = $mapping['options']; } - if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == array($mapping['fieldName'])) { + if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == [$mapping['fieldName']]) { $options['autoincrement'] = true; } if ($class->isInheritanceTypeJoined() && $class->name !== $class->rootEntityName) { @@ -483,7 +483,7 @@ class SchemaTool $isUnique = isset($mapping['unique']) ? $mapping['unique'] : false; if ($isUnique) { - $table->addUniqueIndex(array($columnName)); + $table->addUniqueIndex([$columnName]); } } @@ -511,7 +511,7 @@ class SchemaTool $foreignClass = $this->em->getClassMetadata($mapping['targetEntity']); if ($mapping['type'] & ClassMetadata::TO_ONE && $mapping['isOwningSide']) { - $primaryKeyColumns = array(); // PK is unnecessary for this relation-type + $primaryKeyColumns = []; // PK is unnecessary for this relation-type $this->gatherRelationJoinColumns( $mapping['joinColumns'], @@ -533,7 +533,7 @@ class SchemaTool $this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform) ); - $primaryKeyColumns = array(); + $primaryKeyColumns = []; // Build first FK constraint (relation table => source table) $this->gatherRelationJoinColumns( @@ -581,7 +581,7 @@ class SchemaTool $referencedFieldName = $class->getFieldName($referencedColumnName); if ($class->hasField($referencedFieldName)) { - return array($class, $referencedFieldName); + return [$class, $referencedFieldName]; } if (in_array($referencedColumnName, $class->getIdentifierColumnNames())) { @@ -625,11 +625,11 @@ class SchemaTool &$blacklistedFks ) { - $localColumns = array(); - $foreignColumns = array(); - $fkOptions = array(); + $localColumns = []; + $foreignColumns = []; + $fkOptions = []; $foreignTableName = $this->quoteStrategy->getTableName($class, $this->platform); - $uniqueConstraints = array(); + $uniqueConstraints = []; foreach ($joinColumns as $joinColumn) { @@ -670,7 +670,7 @@ class SchemaTool $columnDef = $fieldMapping['columnDefinition']; } - $columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef); + $columnOptions = ['notnull' => false, 'columnDefinition' => $columnDef]; if (isset($joinColumn['nullable'])) { $columnOptions['notnull'] = !$joinColumn['nullable']; @@ -691,7 +691,7 @@ class SchemaTool } if (isset($joinColumn['unique']) && $joinColumn['unique'] == true) { - $uniqueConstraints[] = array('columns' => array($quotedColumnName)); + $uniqueConstraints[] = ['columns' => [$quotedColumnName]]; } if (isset($joinColumn['onDelete'])) { @@ -721,7 +721,7 @@ class SchemaTool } $blacklistedFks[$compositeName] = true; } elseif (!isset($blacklistedFks[$compositeName])) { - $addedFks[$compositeName] = array('foreignTableName' => $foreignTableName, 'foreignColumns' => $foreignColumns); + $addedFks[$compositeName] = ['foreignTableName' => $foreignTableName, 'foreignColumns' => $foreignColumns]; $theJoinTable->addUnnamedForeignKeyConstraint( $foreignTableName, $localColumns, diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 3f5799a4d..4119b9d60 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -63,7 +63,7 @@ class SchemaValidator */ public function validateMapping() { - $errors = array(); + $errors = []; $cmf = $this->em->getMetadataFactory(); $classes = $cmf->getAllMetadata(); @@ -85,7 +85,7 @@ class SchemaValidator */ public function validateClass(ClassMetadataInfo $class) { - $ce = array(); + $ce = []; $cmf = $this->em->getMetadataFactory(); foreach ($class->fieldMappings as $fieldName => $mapping) { @@ -212,7 +212,7 @@ class SchemaValidator } if (count($identifierColumns) != count($assoc['joinColumns'])) { - $ids = array(); + $ids = []; foreach ($assoc['joinColumns'] as $joinColumn) { $ids[] = $joinColumn['name']; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 368fdfd63..00a41e6df 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -102,7 +102,7 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $identityMap = array(); + private $identityMap = []; /** * Map of all identifiers of managed entities. @@ -110,7 +110,7 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $entityIdentifiers = array(); + private $entityIdentifiers = []; /** * Map of the original entity data of managed entities. @@ -123,7 +123,7 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $originalEntityData = array(); + private $originalEntityData = []; /** * Map of entity changes. Keys are object ids (spl_object_hash). @@ -131,7 +131,7 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $entityChangeSets = array(); + private $entityChangeSets = []; /** * The (cached) states of any known entities. @@ -139,7 +139,7 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $entityStates = array(); + private $entityStates = []; /** * Map of entities that are scheduled for dirty checking at commit time. @@ -148,49 +148,49 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $scheduledForSynchronization = array(); + private $scheduledForSynchronization = []; /** * A list of all pending entity insertions. * * @var array */ - private $entityInsertions = array(); + private $entityInsertions = []; /** * A list of all pending entity updates. * * @var array */ - private $entityUpdates = array(); + private $entityUpdates = []; /** * Any pending extra updates that have been scheduled by persisters. * * @var array */ - private $extraUpdates = array(); + private $extraUpdates = []; /** * A list of all pending entity deletions. * * @var array */ - private $entityDeletions = array(); + private $entityDeletions = []; /** * All pending collection deletions. * * @var array */ - private $collectionDeletions = array(); + private $collectionDeletions = []; /** * All pending collection updates. * * @var array */ - private $collectionUpdates = array(); + private $collectionUpdates = []; /** * List of collections visited during changeset calculation on a commit-phase of a UnitOfWork. @@ -199,7 +199,7 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $visitedCollections = array(); + private $visitedCollections = []; /** * The EntityManager that "owns" this UnitOfWork instance. @@ -213,14 +213,14 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $persisters = array(); + private $persisters = []; /** * The collection persister instances used to persist collections. * * @var array */ - private $collectionPersisters = array(); + private $collectionPersisters = []; /** * The EventManager used for dispatching events. @@ -248,21 +248,21 @@ class UnitOfWork implements PropertyChangedListener * * @var array */ - private $orphanRemovals = array(); + private $orphanRemovals = []; /** * Read-Only objects are never evaluated * * @var array */ - private $readOnlyObjects = array(); + private $readOnlyObjects = []; /** * Map of Entity Class-Names and corresponding IDs that should eager loaded when requested. * * @var array */ - private $eagerLoadingEntities = array(); + private $eagerLoadingEntities = []; /** * @var boolean @@ -424,7 +424,7 @@ class UnitOfWork implements PropertyChangedListener $this->collectionDeletions = $this->visitedCollections = $this->scheduledForSynchronization = - $this->orphanRemovals = array(); + $this->orphanRemovals = []; } /** @@ -501,7 +501,7 @@ class UnitOfWork implements PropertyChangedListener $this->getEntityPersister(get_class($entity))->update($entity); } - $this->extraUpdates = array(); + $this->extraUpdates = []; } /** @@ -514,7 +514,7 @@ class UnitOfWork implements PropertyChangedListener public function & getEntityChangeSet($entity) { $oid = spl_object_hash($entity); - $data = array(); + $data = []; if (!isset($this->entityChangeSets[$oid])) { return $data; @@ -575,7 +575,7 @@ class UnitOfWork implements PropertyChangedListener $this->listenersInvoker->invoke($class, Events::preFlush, $entity, new PreFlushEventArgs($this->em), $invoke); } - $actualData = array(); + $actualData = []; foreach ($class->reflFields as $name => $refProp) { $value = $refProp->getValue($entity); @@ -619,11 +619,11 @@ class UnitOfWork implements PropertyChangedListener // Entity is either NEW or MANAGED but not yet fully persisted (only has an id). // These result in an INSERT. $this->originalEntityData[$oid] = $actualData; - $changeSet = array(); + $changeSet = []; foreach ($actualData as $propName => $actualValue) { if ( ! isset($class->associationMappings[$propName])) { - $changeSet[$propName] = array(null, $actualValue); + $changeSet[$propName] = [null, $actualValue]; continue; } @@ -631,7 +631,7 @@ class UnitOfWork implements PropertyChangedListener $assoc = $class->associationMappings[$propName]; if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { - $changeSet[$propName] = array(null, $actualValue); + $changeSet[$propName] = [null, $actualValue]; } } @@ -643,7 +643,7 @@ class UnitOfWork implements PropertyChangedListener $isChangeTrackingNotify = $class->isChangeTrackingNotify(); $changeSet = ($isChangeTrackingNotify && isset($this->entityChangeSets[$oid])) ? $this->entityChangeSets[$oid] - : array(); + : []; foreach ($actualData as $propName => $actualValue) { // skip field, its a partially omitted one! @@ -664,7 +664,7 @@ class UnitOfWork implements PropertyChangedListener continue; } - $changeSet[$propName] = array($orgValue, $actualValue); + $changeSet[$propName] = [$orgValue, $actualValue]; continue; } @@ -704,7 +704,7 @@ class UnitOfWork implements PropertyChangedListener if ($assoc['type'] & ClassMetadata::TO_ONE) { if ($assoc['isOwningSide']) { - $changeSet[$propName] = array($orgValue, $actualValue); + $changeSet[$propName] = [$orgValue, $actualValue]; } if ($orgValue !== null && $assoc['orphanRemoval']) { @@ -734,7 +734,7 @@ class UnitOfWork implements PropertyChangedListener $val instanceof PersistentCollection && $val->isDirty()) { - $this->entityChangeSets[$oid] = array(); + $this->entityChangeSets[$oid] = []; $this->originalEntityData[$oid] = $actualData; $this->entityUpdates[$oid] = $entity; } @@ -774,7 +774,7 @@ class UnitOfWork implements PropertyChangedListener break; default: - $entitiesToProcess = array(); + $entitiesToProcess = []; } @@ -821,7 +821,7 @@ class UnitOfWork implements PropertyChangedListener // Look through the entities, and in any of their associations, // for transient (new) entities, recursively. ("Persistence by reachability") // Unwrap. Uninitialized collections will simply be empty. - $unwrappedValue = ($assoc['type'] & ClassMetadata::TO_ONE) ? array($value) : $value->unwrap(); + $unwrappedValue = ($assoc['type'] & ClassMetadata::TO_ONE) ? [$value] : $value->unwrap(); $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); foreach ($unwrappedValue as $key => $entry) { @@ -935,7 +935,7 @@ class UnitOfWork implements PropertyChangedListener $class = $this->em->getClassMetadata(get_class($entity)); } - $actualData = array(); + $actualData = []; foreach ($class->reflFields as $name => $refProp) { if (( ! $class->isIdentifier($name) || ! $class->isIdGeneratorIdentity()) @@ -950,13 +950,13 @@ class UnitOfWork implements PropertyChangedListener } $originalData = $this->originalEntityData[$oid]; - $changeSet = array(); + $changeSet = []; foreach ($actualData as $propName => $actualValue) { $orgValue = isset($originalData[$propName]) ? $originalData[$propName] : null; if ($orgValue !== $actualValue) { - $changeSet[$propName] = array($orgValue, $actualValue); + $changeSet[$propName] = [$orgValue, $actualValue]; } } @@ -980,7 +980,7 @@ class UnitOfWork implements PropertyChangedListener */ private function executeInserts($class) { - $entities = array(); + $entities = []; $className = $class->name; $persister = $this->getEntityPersister($className); $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postPersist); @@ -1013,7 +1013,7 @@ class UnitOfWork implements PropertyChangedListener $class->reflFields[$idField]->setValue($entity, $idValue); - $this->entityIdentifiers[$oid] = array($idField => $idValue); + $this->entityIdentifiers[$oid] = [$idField => $idValue]; $this->entityStates[$oid] = self::STATE_MANAGED; $this->originalEntityData[$oid][$idField] = $idValue; @@ -1123,7 +1123,7 @@ class UnitOfWork implements PropertyChangedListener // We have to inspect changeSet to be able to correctly build dependencies. // It is not possible to use IdentityMap here because post inserted ids // are not yet available. - $newNodes = array(); + $newNodes = []; foreach ($entityChangeSet as $entity) { $class = $this->em->getClassMetadata(get_class($entity)); @@ -1274,12 +1274,12 @@ class UnitOfWork implements PropertyChangedListener public function scheduleExtraUpdate($entity, array $changeset) { $oid = spl_object_hash($entity); - $extraUpdate = array($entity, $changeset); + $extraUpdate = [$entity, $changeset]; if (isset($this->extraUpdates[$oid])) { list(, $changeset2) = $this->extraUpdates[$oid]; - $extraUpdate = array($entity, $changeset + $changeset2); + $extraUpdate = [$entity, $changeset + $changeset2]; } $this->extraUpdates[$oid] = $extraUpdate; @@ -1615,7 +1615,7 @@ class UnitOfWork implements PropertyChangedListener */ public function persist($entity) { - $visited = array(); + $visited = []; $this->doPersist($entity, $visited); } @@ -1692,7 +1692,7 @@ class UnitOfWork implements PropertyChangedListener */ public function remove($entity) { - $visited = array(); + $visited = []; $this->doRemove($entity, $visited); } @@ -1766,7 +1766,7 @@ class UnitOfWork implements PropertyChangedListener */ public function merge($entity) { - $visited = array(); + $visited = []; return $this->doMerge($entity, $visited); } @@ -1942,7 +1942,7 @@ class UnitOfWork implements PropertyChangedListener */ public function detach($entity) { - $visited = array(); + $visited = []; $this->doDetach($entity, $visited); } @@ -2003,7 +2003,7 @@ class UnitOfWork implements PropertyChangedListener */ public function refresh($entity) { - $visited = array(); + $visited = []; $this->doRefresh($entity, $visited); } @@ -2245,7 +2245,7 @@ class UnitOfWork implements PropertyChangedListener function ($assoc) { return $assoc['isCascadeRemove']; } ); - $entitiesToCascade = array(); + $entitiesToCascade = []; foreach ($associationMappings as $assoc) { if ($entity instanceof Proxy && !$entity->__isInitialized__) { @@ -2380,7 +2380,7 @@ class UnitOfWork implements PropertyChangedListener $this->extraUpdates = $this->readOnlyObjects = $this->visitedCollections = - $this->orphanRemovals = array(); + $this->orphanRemovals = []; } else { $this->clearIdentityMapForEntityName($entityName); $this->clearEntityInsertionsForEntityName($entityName); @@ -2484,7 +2484,7 @@ class UnitOfWork implements PropertyChangedListener * * @todo Rename: getOrCreateEntity */ - public function createEntity($className, array $data, &$hints = array()) + public function createEntity($className, array $data, &$hints = []) { $class = $this->em->getClassMetadata($className); //$isReadOnly = isset($hints[Query::HINT_READ_ONLY]); @@ -2615,7 +2615,7 @@ class UnitOfWork implements PropertyChangedListener continue; } - $associatedId = array(); + $associatedId = []; // TODO: Is this even computed right in all cases of composite keys? foreach ($assoc['targetToSourceKeyColumns'] as $targetColumn => $srcColumn) { @@ -2631,7 +2631,7 @@ class UnitOfWork implements PropertyChangedListener && in_array($targetClass->getFieldForColumn($targetColumn), $targetClass->identifier, true) ) { // the missing key is part of target's entity primary key - $associatedId = array(); + $associatedId = []; break; } } @@ -2780,7 +2780,7 @@ class UnitOfWork implements PropertyChangedListener // avoid infinite recursion $eagerLoadingEntities = $this->eagerLoadingEntities; - $this->eagerLoadingEntities = array(); + $this->eagerLoadingEntities = []; foreach ($eagerLoadingEntities as $entityName => $ids) { if ( ! $ids) { @@ -2790,7 +2790,7 @@ class UnitOfWork implements PropertyChangedListener $class = $this->em->getClassMetadata($entityName); $this->getEntityPersister($entityName)->loadAll( - array_combine($class->identifier, array(array_values($ids))) + array_combine($class->identifier, [array_values($ids)]) ); } } @@ -3088,7 +3088,7 @@ class UnitOfWork implements PropertyChangedListener */ public function clearEntityChangeSet($oid) { - $this->entityChangeSets[$oid] = array(); + $this->entityChangeSets[$oid] = []; } /* PropertyChangedListener implementation */ @@ -3115,7 +3115,7 @@ class UnitOfWork implements PropertyChangedListener } // Update changeset and mark entity for synchronization - $this->entityChangeSets[$oid][$propertyName] = array($oldValue, $newValue); + $this->entityChangeSets[$oid][$propertyName] = [$oldValue, $newValue]; if ( ! isset($this->scheduledForSynchronization[$class->rootEntityName][$oid])) { $this->scheduleForDirtyCheck($entity); @@ -3374,7 +3374,7 @@ class UnitOfWork implements PropertyChangedListener $assoc2['targetEntity'], $relatedId ); - $this->registerManaged($other, $relatedId, array()); + $this->registerManaged($other, $relatedId, []); } } diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index 4a60385bd..a283a6834 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -68,7 +68,7 @@ final class IdentifierFlattener */ public function flattenIdentifier(ClassMetadata $class, array $id) { - $flatId = array(); + $flatId = []; foreach ($class->identifier as $field) { if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_object($id[$field])) { @@ -85,7 +85,7 @@ final class IdentifierFlattener $flatId[$field] = implode(' ', $associatedId); } elseif (isset($class->associationMappings[$field])) { - $associatedId = array(); + $associatedId = []; foreach ($class->associationMappings[$field]['joinColumns'] as $joinColumn) { $associatedId[] = $id[$joinColumn['name']]; diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index ad99a7ea8..d72dc3e19 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -46,11 +46,11 @@ class PersisterHelper public static function getTypeOfField($fieldName, ClassMetadata $class, EntityManagerInterface $em) { if (isset($class->fieldMappings[$fieldName])) { - return array($class->fieldMappings[$fieldName]['type']); + return [$class->fieldMappings[$fieldName]['type']]; } if ( ! isset($class->associationMappings[$fieldName])) { - return array(); + return []; } $assoc = $class->associationMappings[$fieldName]; @@ -65,7 +65,7 @@ class PersisterHelper $joinData = $assoc; } - $types = array(); + $types = []; $targetClass = $em->getClassMetadata($assoc['targetEntity']); foreach ($joinData['joinColumns'] as $joinColumn) {