1
0
mirror of synced 2025-02-09 08:49:26 +03:00

Use short-array syntax on "lib" directory

This commit is contained in:
Luís Cobucci 2016-12-08 00:31:12 +01:00
parent c609072ce1
commit 234989d069
No known key found for this signature in database
GPG Key ID: 8042585A7DBC92E1
139 changed files with 1532 additions and 1445 deletions

View File

@ -96,7 +96,7 @@ abstract class AbstractQuery
* *
* @var array * @var array
*/ */
protected $_hints = array(); protected $_hints = [];
/** /**
* The hydration mode. * The hydration mode.
@ -955,7 +955,7 @@ abstract class AbstractQuery
} }
if ( ! $result) { if ( ! $result) {
$result = array(); $result = [];
} }
$setCacheEntry = function($data) use ($cache, $result, $cacheKey, $realCacheKey, $queryCacheProfile) { $setCacheEntry = function($data) use ($cache, $result, $cacheKey, $realCacheKey, $queryCacheProfile) {
@ -1049,7 +1049,7 @@ abstract class AbstractQuery
*/ */
protected function getHydrationCacheId() protected function getHydrationCacheId()
{ {
$parameters = array(); $parameters = [];
foreach ($this->getParameters() as $parameter) { foreach ($this->getParameters() as $parameter) {
$parameters[$parameter->getName()] = $this->processParameterValue($parameter->getValue()); $parameters[$parameter->getName()] = $this->processParameterValue($parameter->getValue());
@ -1111,7 +1111,7 @@ abstract class AbstractQuery
{ {
$this->parameters = new ArrayCollection(); $this->parameters = new ArrayCollection();
$this->_hints = array(); $this->_hints = [];
$this->_hints = $this->_em->getConfiguration()->getDefaultQueryHints(); $this->_hints = $this->_em->getConfiguration()->getDefaultQueryHints();
} }

View File

@ -53,7 +53,7 @@ class DefaultCache implements Cache
/** /**
* @var \Doctrine\ORM\Cache\QueryCache[] * @var \Doctrine\ORM\Cache\QueryCache[]
*/ */
private $queryCaches = array(); private $queryCaches = [];
/** /**
* @var \Doctrine\ORM\Cache\QueryCache * @var \Doctrine\ORM\Cache\QueryCache
@ -336,7 +336,7 @@ class DefaultCache implements Cache
} }
} }
return array($metadata->identifier[0] => $identifier); return [$metadata->identifier[0] => $identifier];
} }
} }

View File

@ -64,7 +64,7 @@ class DefaultCacheFactory implements CacheFactory
/** /**
* @var \Doctrine\ORM\Cache\Region[] * @var \Doctrine\ORM\Cache\Region[]
*/ */
private $regions = array(); private $regions = [];
/** /**
* @var string|null * @var string|null
@ -167,10 +167,10 @@ class DefaultCacheFactory implements CacheFactory
return new DefaultQueryCache( return new DefaultQueryCache(
$em, $em,
$this->getRegion( $this->getRegion(
array( [
'region' => $regionName ?: Cache::DEFAULT_QUERY_REGION_NAME, 'region' => $regionName ?: Cache::DEFAULT_QUERY_REGION_NAME,
'usage' => ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE 'usage' => ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE
) ]
) )
); );
} }

View File

@ -46,7 +46,7 @@ class DefaultCollectionHydrator implements CollectionHydrator
/** /**
* @var array * @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. * @param \Doctrine\ORM\EntityManagerInterface $em The entity manager.
@ -62,7 +62,7 @@ class DefaultCollectionHydrator implements CollectionHydrator
*/ */
public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, $collection) public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, $collection)
{ {
$data = array(); $data = [];
foreach ($collection as $index => $entity) { foreach ($collection as $index => $entity) {
$data[$index] = new EntityCacheKey($metadata->name, $this->uow->getEntityIdentifier($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 */ /* @var $targetPersister \Doctrine\ORM\Cache\Persister\CachedPersister */
$targetPersister = $this->uow->getEntityPersister($assoc['targetEntity']); $targetPersister = $this->uow->getEntityPersister($assoc['targetEntity']);
$targetRegion = $targetPersister->getCacheRegion(); $targetRegion = $targetPersister->getCacheRegion();
$list = array(); $list = [];
$entityEntries = $targetRegion->getMultiple($entry); $entityEntries = $targetRegion->getMultiple($entry);

View File

@ -55,7 +55,7 @@ class DefaultEntityHydrator implements EntityHydrator
/** /**
* @var array * @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. * @param \Doctrine\ORM\EntityManagerInterface $em The entity manager.
@ -138,7 +138,7 @@ class DefaultEntityHydrator implements EntityHydrator
$data[reset($assoc['joinColumnFieldNames'])] = $targetId; $data[reset($assoc['joinColumnFieldNames'])] = $targetId;
$targetEntity = $this->em->getClassMetadata($assoc['targetEntity']); $targetEntity = $this->em->getClassMetadata($assoc['targetEntity']);
$targetId = array($targetEntity->identifier[0] => $targetId); $targetId = [$targetEntity->identifier[0] => $targetId];
} }
$data[$name] = new AssociationCacheEntry($assoc['targetEntity'], $targetId); $data[$name] = new AssociationCacheEntry($assoc['targetEntity'], $targetId);

View File

@ -66,7 +66,7 @@ class DefaultQueryCache implements QueryCache
/** /**
* @var array * @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. * @param \Doctrine\ORM\EntityManagerInterface $em The entity manager.
@ -86,7 +86,7 @@ class DefaultQueryCache implements QueryCache
/** /**
* {@inheritdoc} * {@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)) { if ( ! ($key->cacheMode & Cache::MODE_GET)) {
return null; return null;
@ -104,7 +104,7 @@ class DefaultQueryCache implements QueryCache
return null; return null;
} }
$result = array(); $result = [];
$entityName = reset($rsm->aliasMap); $entityName = reset($rsm->aliasMap);
$hasRelation = ( ! empty($rsm->relationMap)); $hasRelation = ( ! empty($rsm->relationMap));
$persister = $this->uow->getEntityPersister($entityName); $persister = $this->uow->getEntityPersister($entityName);
@ -209,7 +209,7 @@ class DefaultQueryCache implements QueryCache
/** /**
* {@inheritdoc} * {@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) { if ($rsm->scalarMappings) {
throw new CacheException("Second level cache does not support scalar results."); throw new CacheException("Second level cache does not support scalar results.");
@ -231,7 +231,7 @@ class DefaultQueryCache implements QueryCache
return false; return false;
} }
$data = array(); $data = [];
$entityName = reset($rsm->aliasMap); $entityName = reset($rsm->aliasMap);
$rootAlias = key($rsm->aliasMap); $rootAlias = key($rsm->aliasMap);
$hasRelation = ( ! empty($rsm->relationMap)); $hasRelation = ( ! empty($rsm->relationMap));
@ -247,7 +247,7 @@ class DefaultQueryCache implements QueryCache
$identifier = $this->uow->getEntityIdentifier($entity); $identifier = $this->uow->getEntityIdentifier($entity);
$entityKey = new EntityCacheKey($entityName, $identifier); $entityKey = new EntityCacheKey($entityName, $identifier);
$data[$index]['identifier'] = $identifier; $data[$index]['identifier'] = $identifier;
$data[$index]['associations'] = array(); $data[$index]['associations'] = [];
if (($key->cacheMode & Cache::MODE_REFRESH) || ! $region->contains($entityKey)) { if (($key->cacheMode & Cache::MODE_REFRESH) || ! $region->contains($entityKey)) {
// Cancel put result if entity put fail // Cancel put result if entity put fail
@ -332,15 +332,15 @@ class DefaultQueryCache implements QueryCache
} }
} }
return array( return [
'targetEntity' => $assocMetadata->rootEntityName, 'targetEntity' => $assocMetadata->rootEntityName,
'identifier' => $assocIdentifier, 'identifier' => $assocIdentifier,
'type' => $assoc['type'] 'type' => $assoc['type']
); ];
} }
// Handle *-to-many associations // Handle *-to-many associations
$list = array(); $list = [];
foreach ($assocValue as $assocItemIndex => $assocItem) { foreach ($assocValue as $assocItemIndex => $assocItem) {
$assocIdentifier = $this->uow->getEntityIdentifier($assocItem); $assocIdentifier = $this->uow->getEntityIdentifier($assocItem);
@ -356,11 +356,11 @@ class DefaultQueryCache implements QueryCache
$list[$assocItemIndex] = $assocIdentifier; $list[$assocItemIndex] = $assocIdentifier;
} }
return array( return [
'targetEntity' => $assocMetadata->rootEntityName, 'targetEntity' => $assocMetadata->rootEntityName,
'type' => $assoc['type'], 'type' => $assoc['type'],
'list' => $list, 'list' => $list,
); ];
} }
/** /**
@ -372,7 +372,7 @@ class DefaultQueryCache implements QueryCache
*/ */
private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity) private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity)
{ {
$path = array(); $path = [];
$alias = $assocAlias; $alias = $assocAlias;
while (isset($rsm->parentAliasMap[$alias])) { while (isset($rsm->parentAliasMap[$alias])) {
@ -380,10 +380,11 @@ class DefaultQueryCache implements QueryCache
$field = $rsm->relationMap[$alias]; $field = $rsm->relationMap[$alias];
$class = $rsm->aliasMap[$parent]; $class = $rsm->aliasMap[$parent];
array_unshift($path, array( array_unshift($path, [
'field' => $field, 'field' => $field,
'class' => $class 'class' => $class
)); ]
);
$alias = $parent; $alias = $parent;
} }
@ -417,7 +418,7 @@ class DefaultQueryCache implements QueryCache
return $this->getAssociationPathValue($value, $path); return $this->getAssociationPathValue($value, $path);
} }
$values = array(); $values = [];
foreach ($value as $item) { foreach ($value as $item) {
$values[] = $this->getAssociationPathValue($item, $path); $values[] = $this->getAssociationPathValue($item, $path);

View File

@ -35,7 +35,7 @@ class CacheLoggerChain implements CacheLogger
/** /**
* @var array<\Doctrine\ORM\Cache\Logging\CacheLogger> * @var array<\Doctrine\ORM\Cache\Logging\CacheLogger>
*/ */
private $loggers = array(); private $loggers = [];
/** /**
* @param string $name * @param string $name

View File

@ -35,17 +35,17 @@ class StatisticsCacheLogger implements CacheLogger
/** /**
* @var array * @var array
*/ */
private $cacheMissCountMap = array(); private $cacheMissCountMap = [];
/** /**
* @var array * @var array
*/ */
private $cacheHitCountMap = array(); private $cacheHitCountMap = [];
/** /**
* @var array * @var array
*/ */
private $cachePutCountMap = array(); private $cachePutCountMap = [];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -214,9 +214,9 @@ class StatisticsCacheLogger implements CacheLogger
*/ */
public function clearStats() public function clearStats()
{ {
$this->cachePutCountMap = array(); $this->cachePutCountMap = [];
$this->cacheHitCountMap = array(); $this->cacheHitCountMap = [];
$this->cacheMissCountMap = array(); $this->cacheMissCountMap = [];
} }
/** /**

View File

@ -70,7 +70,7 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister
/** /**
* @var array * @var array
*/ */
protected $queuedCache = array(); protected $queuedCache = [];
/** /**
* @var \Doctrine\ORM\Cache\Region * @var \Doctrine\ORM\Cache\Region

View File

@ -46,7 +46,7 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPers
} }
} }
$this->queuedCache = array(); $this->queuedCache = [];
} }
/** /**
@ -54,7 +54,7 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPers
*/ */
public function afterTransactionRolledBack() public function afterTransactionRolledBack()
{ {
$this->queuedCache = array(); $this->queuedCache = [];
} }
/** /**
@ -96,9 +96,9 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPers
$this->persister->update($collection); $this->persister->update($collection);
$this->queuedCache['update'][spl_object_hash($collection)] = array( $this->queuedCache['update'][spl_object_hash($collection)] = [
'key' => $key, 'key' => $key,
'list' => $collection 'list' => $collection
); ];
} }
} }

View File

@ -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; return;
} }
$this->queuedCache['delete'][spl_object_hash($collection)] = array( $this->queuedCache['delete'][spl_object_hash($collection)] = [
'key' => $key, 'key' => $key,
'lock' => $lock 'lock' => $lock
); ];
} }
/** /**
@ -126,9 +126,9 @@ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister
return; return;
} }
$this->queuedCache['update'][spl_object_hash($collection)] = array( $this->queuedCache['update'][spl_object_hash($collection)] = [
'key' => $key, 'key' => $key,
'lock' => $lock 'lock' => $lock
); ];
} }
} }

View File

@ -64,7 +64,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
/** /**
* @var array * @var array
*/ */
protected $queuedCache = array(); protected $queuedCache = [];
/** /**
* @var \Doctrine\ORM\Cache\Region * @var \Doctrine\ORM\Cache\Region
@ -160,7 +160,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getCountSQL($criteria = array()) public function getCountSQL($criteria = [])
{ {
return $this->persister->getCountSQL($criteria); return $this->persister->getCountSQL($criteria);
} }
@ -249,7 +249,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
private function storeJoinedAssociations($entity) private function storeJoinedAssociations($entity)
{ {
if ($this->joinedAssociations === null) { if ($this->joinedAssociations === null) {
$associations = array(); $associations = [];
foreach ($this->class->associationMappings as $name => $assoc) { foreach ($this->class->associationMappings as $name => $assoc) {
if (isset($assoc['cache']) && if (isset($assoc['cache']) &&
@ -360,7 +360,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
/** /**
* {@inheritdoc} * {@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) { if ($entity !== null || $assoc !== null || ! empty($hints) || $lockMode !== null) {
return $this->persister->load($criteria, $entity, $assoc, $hints, $lockMode, $limit, $orderBy); return $this->persister->load($criteria, $entity, $assoc, $hints, $lockMode, $limit, $orderBy);
@ -386,7 +386,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
return null; return null;
} }
$cached = $queryCache->put($queryKey, $rsm, array($result)); $cached = $queryCache->put($queryKey, $rsm, [$result]);
if ($this->cacheLogger) { if ($this->cacheLogger) {
if ($result) { if ($result) {
@ -404,7 +404,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
/** /**
* {@inheritdoc} * {@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); $query = $this->persister->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy);
$hash = $this->getHash($query, $criteria, null, null, null); $hash = $this->getHash($query, $criteria, null, null, null);
@ -494,7 +494,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function count($criteria = array()) public function count($criteria = [])
{ {
return $this->persister->count($criteria); return $this->persister->count($criteria);
} }
@ -612,7 +612,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister
/** /**
* {@inheritdoc} * {@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); return $this->persister->loadOneToOneEntity($assoc, $sourceEntity, $identifier);
} }

View File

@ -62,7 +62,7 @@ class NonStrictReadWriteCachedEntityPersister extends AbstractEntityPersister
$this->timestampRegion->update($this->timestampKey); $this->timestampRegion->update($this->timestampKey);
} }
$this->queuedCache = array(); $this->queuedCache = [];
} }
/** /**
@ -70,7 +70,7 @@ class NonStrictReadWriteCachedEntityPersister extends AbstractEntityPersister
*/ */
public function afterTransactionRolledBack() public function afterTransactionRolledBack()
{ {
$this->queuedCache = array(); $this->queuedCache = [];
} }
/** /**

View File

@ -73,7 +73,7 @@ class ReadWriteCachedEntityPersister extends AbstractEntityPersister
$this->timestampRegion->update($this->timestampKey); $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; return $deleted;
} }
$this->queuedCache['delete'][] = array( $this->queuedCache['delete'][] = [
'lock' => $lock, 'lock' => $lock,
'key' => $key 'key' => $key
); ];
return $deleted; return $deleted;
} }
@ -135,9 +135,9 @@ class ReadWriteCachedEntityPersister extends AbstractEntityPersister
return; return;
} }
$this->queuedCache['update'][] = array( $this->queuedCache['update'][] = [
'lock' => $lock, 'lock' => $lock,
'key' => $key 'key' => $key
); ];
} }
} }

View File

@ -44,7 +44,7 @@ interface QueryCache
* *
* @return boolean * @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 * @param \Doctrine\ORM\Cache\QueryCacheKey $key
@ -53,7 +53,7 @@ interface QueryCache
* *
* @return array|null * @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 * @return \Doctrine\ORM\Cache\Region

View File

@ -56,7 +56,7 @@ class DefaultMultiGetRegion extends DefaultRegion
*/ */
public function getMultiple(CollectionCacheEntry $collection) public function getMultiple(CollectionCacheEntry $collection)
{ {
$keysToRetrieve = array(); $keysToRetrieve = [];
foreach ($collection->identifiers as $index => $key) { foreach ($collection->identifiers as $index => $key) {
$keysToRetrieve[$index] = $this->getCacheEntryKey($key); $keysToRetrieve[$index] = $this->getCacheEntryKey($key);
@ -67,7 +67,7 @@ class DefaultMultiGetRegion extends DefaultRegion
return null; return null;
} }
$returnableItems = array(); $returnableItems = [];
foreach ($keysToRetrieve as $index => $key) { foreach ($keysToRetrieve as $index => $key) {
$returnableItems[$index] = $items[$key]; $returnableItems[$index] = $items[$key];
} }

View File

@ -102,7 +102,7 @@ class DefaultRegion implements Region
*/ */
public function getMultiple(CollectionCacheEntry $collection) public function getMultiple(CollectionCacheEntry $collection)
{ {
$result = array(); $result = [];
foreach ($collection->identifiers as $key) { foreach ($collection->identifiers as $key) {
$entryKey = $this->getCacheEntryKey($key); $entryKey = $this->getCacheEntryKey($key);

View File

@ -31,12 +31,12 @@ class RegionsConfiguration
/** /**
* @var array * @var array
*/ */
private $lifetimes = array(); private $lifetimes = [];
/** /**
* @var array * @var array
*/ */
private $lockLifetimes = array(); private $lockLifetimes = [];
/** /**
* @var integer * @var integer

View File

@ -149,7 +149,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
* *
* @return AnnotationDriver * @return AnnotationDriver
*/ */
public function newDefaultAnnotationDriver($paths = array(), $useSimpleAnnotationReader = true) public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true)
{ {
AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); 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) 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) public function setCustomHydrationModes($modes)
{ {
$this->_attributes['customHydrationModes'] = array(); $this->_attributes['customHydrationModes'] = [];
foreach ($modes as $modeName => $hydrator) { foreach ($modes as $modeName => $hydrator) {
$this->addCustomHydrationMode($modeName, $hydrator); $this->addCustomHydrationMode($modeName, $hydrator);
@ -881,7 +881,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/ */
public function getDefaultQueryHints() public function getDefaultQueryHints()
{ {
return isset($this->_attributes['defaultQueryHints']) ? $this->_attributes['defaultQueryHints'] : array(); return isset($this->_attributes['defaultQueryHints']) ? $this->_attributes['defaultQueryHints'] : [];
} }
/** /**

View File

@ -386,7 +386,7 @@ use Doctrine\Common\Util\ClassUtils;
throw ORMInvalidArgumentException::invalidCompositeIdentifier(); throw ORMInvalidArgumentException::invalidCompositeIdentifier();
} }
$id = array($class->identifier[0] => $id); $id = [$class->identifier[0] => $id];
} }
foreach ($id as $i => $value) { foreach ($id as $i => $value) {
@ -399,7 +399,7 @@ use Doctrine\Common\Util\ClassUtils;
} }
} }
$sortedId = array(); $sortedId = [];
foreach ($class->identifier as $identifier) { foreach ($class->identifier as $identifier) {
if ( ! isset($id[$identifier])) { if ( ! isset($id[$identifier])) {
@ -458,7 +458,7 @@ use Doctrine\Common\Util\ClassUtils;
throw TransactionRequiredException::transactionRequired(); throw TransactionRequiredException::transactionRequired();
} }
return $persister->load($sortedId, null, null, array(), $lockMode); return $persister->load($sortedId, null, null, [], $lockMode);
default: default:
return $persister->loadById($sortedId); return $persister->loadById($sortedId);
@ -473,10 +473,10 @@ use Doctrine\Common\Util\ClassUtils;
$class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\'));
if ( ! is_array($id)) { if ( ! is_array($id)) {
$id = array($class->identifier[0] => $id); $id = [$class->identifier[0] => $id];
} }
$sortedId = array(); $sortedId = [];
foreach ($class->identifier as $identifier) { foreach ($class->identifier as $identifier) {
if ( ! isset($id[$identifier])) { if ( ! isset($id[$identifier])) {
@ -502,7 +502,7 @@ use Doctrine\Common\Util\ClassUtils;
$entity = $this->proxyFactory->getProxy($class->name, $sortedId); $entity = $this->proxyFactory->getProxy($class->name, $sortedId);
$this->unitOfWork->registerManaged($entity, $sortedId, array()); $this->unitOfWork->registerManaged($entity, $sortedId, []);
return $entity; return $entity;
} }
@ -520,14 +520,14 @@ use Doctrine\Common\Util\ClassUtils;
} }
if ( ! is_array($identifier)) { if ( ! is_array($identifier)) {
$identifier = array($class->identifier[0] => $identifier); $identifier = [$class->identifier[0] => $identifier];
} }
$entity = $class->newInstance(); $entity = $class->newInstance();
$class->setIdentifierValues($entity, $identifier); $class->setIdentifierValues($entity, $identifier);
$this->unitOfWork->registerManaged($entity, $identifier, array()); $this->unitOfWork->registerManaged($entity, $identifier, []);
$this->unitOfWork->markReadOnly($entity); $this->unitOfWork->markReadOnly($entity);
return $entity; return $entity;

View File

@ -37,7 +37,7 @@ class EntityNotFoundException extends ORMException
*/ */
public static function fromClassNameAndIdentifier($className, array $id) public static function fromClassNameAndIdentifier($className, array $id)
{ {
$ids = array(); $ids = [];
foreach ($id as $key => $value) { foreach ($id as $key => $value) {
$ids[] = $key . '(' . $value . ')'; $ids[] = $key . '(' . $value . ')';

View File

@ -161,7 +161,7 @@ class EntityRepository implements ObjectRepository, Selectable
*/ */
public function findAll() 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); $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);
} }
/** /**

View File

@ -44,7 +44,7 @@ class AssignedGenerator extends AbstractIdGenerator
{ {
$class = $em->getClassMetadata(get_class($entity)); $class = $em->getClassMetadata(get_class($entity));
$idFields = $class->getIdentifierFieldNames(); $idFields = $class->getIdentifierFieldNames();
$identifier = array(); $identifier = [];
foreach ($idFields as $idField) { foreach ($idFields as $idField) {
$value = $class->getFieldValue($entity, $idField); $value = $class->getFieldValue($entity, $idField);

View File

@ -108,10 +108,12 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable
*/ */
public function serialize() public function serialize()
{ {
return serialize(array( return serialize(
[
'allocationSize' => $this->_allocationSize, 'allocationSize' => $this->_allocationSize,
'sequenceName' => $this->_sequenceName 'sequenceName' => $this->_sequenceName
)); ]
);
} }
/** /**

View File

@ -92,7 +92,7 @@ class TableGenerator extends AbstractIdGenerator
$this->_tableName, $this->_sequenceName, $this->_allocationSize $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 // no affected rows, concurrency issue, throw exception
} }
} else { } else {

View File

@ -54,14 +54,14 @@ class CommitOrderCalculator
* *
* @var array<stdClass> * @var array<stdClass>
*/ */
private $nodeList = array(); private $nodeList = [];
/** /**
* Volatile variable holding calculated nodes during sorting process. * Volatile variable holding calculated nodes during sorting process.
* *
* @var array * @var array
*/ */
private $sortedNodeList = array(); private $sortedNodeList = [];
/** /**
* Checks for node (vertex) existence in graph. * Checks for node (vertex) existence in graph.
@ -90,7 +90,7 @@ class CommitOrderCalculator
$vertex->hash = $hash; $vertex->hash = $hash;
$vertex->state = self::NOT_VISITED; $vertex->state = self::NOT_VISITED;
$vertex->value = $node; $vertex->value = $node;
$vertex->dependencyList = array(); $vertex->dependencyList = [];
$this->nodeList[$hash] = $vertex; $this->nodeList[$hash] = $vertex;
} }
@ -136,8 +136,8 @@ class CommitOrderCalculator
$sortedList = $this->sortedNodeList; $sortedList = $this->sortedNodeList;
$this->nodeList = array(); $this->nodeList = [];
$this->sortedNodeList = array(); $this->sortedNodeList = [];
return array_reverse($sortedList); return array_reverse($sortedList);
} }

View File

@ -69,14 +69,14 @@ abstract class AbstractHydrator
* *
* @var array * @var array
*/ */
protected $_metadataCache = array(); protected $_metadataCache = [];
/** /**
* The cache used during row-by-row hydration. * The cache used during row-by-row hydration.
* *
* @var array * @var array
*/ */
protected $_cache = array(); protected $_cache = [];
/** /**
* The statement that provides the data to hydrate. * The statement that provides the data to hydrate.
@ -113,7 +113,7 @@ abstract class AbstractHydrator
* *
* @return IterableResult * @return IterableResult
*/ */
public function iterate($stmt, $resultSetMapping, array $hints = array()) public function iterate($stmt, $resultSetMapping, array $hints = [])
{ {
$this->_stmt = $stmt; $this->_stmt = $stmt;
$this->_rsm = $resultSetMapping; $this->_rsm = $resultSetMapping;
@ -121,7 +121,7 @@ abstract class AbstractHydrator
$evm = $this->_em->getEventManager(); $evm = $this->_em->getEventManager();
$evm->addEventListener(array(Events::onClear), $this); $evm->addEventListener([Events::onClear], $this);
$this->prepare(); $this->prepare();
@ -137,7 +137,7 @@ abstract class AbstractHydrator
* *
* @return array * @return array
*/ */
public function hydrateAll($stmt, $resultSetMapping, array $hints = array()) public function hydrateAll($stmt, $resultSetMapping, array $hints = [])
{ {
$this->_stmt = $stmt; $this->_stmt = $stmt;
$this->_rsm = $resultSetMapping; $this->_rsm = $resultSetMapping;
@ -168,7 +168,7 @@ abstract class AbstractHydrator
return false; return false;
} }
$result = array(); $result = [];
$this->hydrateRowData($row, $result); $this->hydrateRowData($row, $result);
@ -209,8 +209,8 @@ abstract class AbstractHydrator
$this->_stmt = null; $this->_stmt = null;
$this->_rsm = null; $this->_rsm = null;
$this->_cache = array(); $this->_cache = [];
$this->_metadataCache = array(); $this->_metadataCache = [];
} }
/** /**
@ -255,7 +255,7 @@ abstract class AbstractHydrator
*/ */
protected function gatherRowData(array $data, array &$id, array &$nonemptyComponents) protected function gatherRowData(array $data, array &$id, array &$nonemptyComponents)
{ {
$rowData = array('data' => array()); $rowData = ['data' => []];
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (($cacheKeyInfo = $this->hydrateColumnInfo($key)) === null) { if (($cacheKeyInfo = $this->hydrateColumnInfo($key)) === null) {
@ -323,7 +323,7 @@ abstract class AbstractHydrator
*/ */
protected function gatherScalarRowData(&$data) protected function gatherScalarRowData(&$data)
{ {
$rowData = array(); $rowData = [];
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (($cacheKeyInfo = $this->hydrateColumnInfo($key)) === null) { if (($cacheKeyInfo = $this->hydrateColumnInfo($key)) === null) {
@ -369,18 +369,18 @@ abstract class AbstractHydrator
$fieldName = $this->_rsm->fieldMappings[$key]; $fieldName = $this->_rsm->fieldMappings[$key];
$fieldMapping = $classMetadata->fieldMappings[$fieldName]; $fieldMapping = $classMetadata->fieldMappings[$fieldName];
return $this->_cache[$key] = array( return $this->_cache[$key] = [
'isIdentifier' => in_array($fieldName, $classMetadata->identifier), 'isIdentifier' => in_array($fieldName, $classMetadata->identifier),
'fieldName' => $fieldName, 'fieldName' => $fieldName,
'type' => Type::getType($fieldMapping['type']), 'type' => Type::getType($fieldMapping['type']),
'dqlAlias' => $this->_rsm->columnOwnerMap[$key], 'dqlAlias' => $this->_rsm->columnOwnerMap[$key],
); ];
case (isset($this->_rsm->newObjectMappings[$key])): case (isset($this->_rsm->newObjectMappings[$key])):
// WARNING: A NEW object is also a scalar, so it must be declared before! // WARNING: A NEW object is also a scalar, so it must be declared before!
$mapping = $this->_rsm->newObjectMappings[$key]; $mapping = $this->_rsm->newObjectMappings[$key];
return $this->_cache[$key] = array( return $this->_cache[$key] = [
'isScalar' => true, 'isScalar' => true,
'isNewObjectParameter' => true, 'isNewObjectParameter' => true,
'fieldName' => $this->_rsm->scalarMappings[$key], 'fieldName' => $this->_rsm->scalarMappings[$key],
@ -388,14 +388,14 @@ abstract class AbstractHydrator
'argIndex' => $mapping['argIndex'], 'argIndex' => $mapping['argIndex'],
'objIndex' => $mapping['objIndex'], 'objIndex' => $mapping['objIndex'],
'class' => new \ReflectionClass($mapping['className']), 'class' => new \ReflectionClass($mapping['className']),
); ];
case (isset($this->_rsm->scalarMappings[$key])): case (isset($this->_rsm->scalarMappings[$key])):
return $this->_cache[$key] = array( return $this->_cache[$key] = [
'isScalar' => true, 'isScalar' => true,
'fieldName' => $this->_rsm->scalarMappings[$key], 'fieldName' => $this->_rsm->scalarMappings[$key],
'type' => Type::getType($this->_rsm->typeMappings[$key]), 'type' => Type::getType($this->_rsm->typeMappings[$key]),
); ];
case (isset($this->_rsm->metaMappings[$key])): case (isset($this->_rsm->metaMappings[$key])):
// Meta column (has meaning in relational schema only, i.e. foreign keys or discriminator columns). // 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 // Cache metadata fetch
$this->getClassMetadata($this->_rsm->aliasMap[$dqlAlias]); $this->getClassMetadata($this->_rsm->aliasMap[$dqlAlias]);
return $this->_cache[$key] = array( return $this->_cache[$key] = [
'isIdentifier' => isset($this->_rsm->isIdentifierColumn[$dqlAlias][$key]), 'isIdentifier' => isset($this->_rsm->isIdentifierColumn[$dqlAlias][$key]),
'isMetaColumn' => true, 'isMetaColumn' => true,
'fieldName' => $fieldName, 'fieldName' => $fieldName,
'type' => $type, 'type' => $type,
'dqlAlias' => $dqlAlias, 'dqlAlias' => $dqlAlias,
); ];
} }
// this column is a left over, maybe from a LIMIT query hack for example in Oracle or DB2 // 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) protected function registerManaged(ClassMetadata $class, $entity, array $data)
{ {
if ($class->isIdentifierComposite) { if ($class->isIdentifierComposite) {
$id = array(); $id = [];
foreach ($class->identifier as $fieldName) { foreach ($class->identifier as $fieldName) {
$id[$fieldName] = isset($class->associationMappings[$fieldName]) $id[$fieldName] = isset($class->associationMappings[$fieldName])
@ -461,11 +461,11 @@ abstract class AbstractHydrator
} }
} else { } else {
$fieldName = $class->identifier[0]; $fieldName = $class->identifier[0];
$id = array( $id = [
$fieldName => isset($class->associationMappings[$fieldName]) $fieldName => isset($class->associationMappings[$fieldName])
? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
: $data[$fieldName] : $data[$fieldName]
); ];
} }
$this->_em->getUnitOfWork()->registerManaged($entity, $id, $data); $this->_em->getUnitOfWork()->registerManaged($entity, $id, $data);

View File

@ -35,7 +35,7 @@ class ArrayHydrator extends AbstractHydrator
/** /**
* @var array * @var array
*/ */
private $_rootAliases = array(); private $_rootAliases = [];
/** /**
* @var bool * @var bool
@ -45,17 +45,17 @@ class ArrayHydrator extends AbstractHydrator
/** /**
* @var array * @var array
*/ */
private $_identifierMap = array(); private $_identifierMap = [];
/** /**
* @var array * @var array
*/ */
private $_resultPointers = array(); private $_resultPointers = [];
/** /**
* @var array * @var array
*/ */
private $_idTemplate = array(); private $_idTemplate = [];
/** /**
* @var int * @var int
@ -70,8 +70,8 @@ class ArrayHydrator extends AbstractHydrator
$this->_isSimpleQuery = count($this->_rsm->aliasMap) <= 1; $this->_isSimpleQuery = count($this->_rsm->aliasMap) <= 1;
foreach ($this->_rsm->aliasMap as $dqlAlias => $className) { foreach ($this->_rsm->aliasMap as $dqlAlias => $className) {
$this->_identifierMap[$dqlAlias] = array(); $this->_identifierMap[$dqlAlias] = [];
$this->_resultPointers[$dqlAlias] = array(); $this->_resultPointers[$dqlAlias] = [];
$this->_idTemplate[$dqlAlias] = ''; $this->_idTemplate[$dqlAlias] = '';
} }
} }
@ -81,7 +81,7 @@ class ArrayHydrator extends AbstractHydrator
*/ */
protected function hydrateAllData() protected function hydrateAllData()
{ {
$result = array(); $result = [];
while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) {
$this->hydrateRowData($data, $result); $this->hydrateRowData($data, $result);
@ -97,7 +97,7 @@ class ArrayHydrator extends AbstractHydrator
{ {
// 1) Initialize // 1) Initialize
$id = $this->_idTemplate; // initialize the id-memory $id = $this->_idTemplate; // initialize the id-memory
$nonemptyComponents = array(); $nonemptyComponents = [];
$rowData = $this->gatherRowData($row, $id, $nonemptyComponents); $rowData = $this->gatherRowData($row, $id, $nonemptyComponents);
// 2) Now hydrate the data found in the current row. // 2) Now hydrate the data found in the current row.
@ -138,7 +138,7 @@ class ArrayHydrator extends AbstractHydrator
$oneToOne = false; $oneToOne = false;
if ( ! isset($baseElement[$relationAlias])) { if ( ! isset($baseElement[$relationAlias])) {
$baseElement[$relationAlias] = array(); $baseElement[$relationAlias] = [];
} }
if (isset($nonemptyComponents[$dqlAlias])) { 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 this row has a NULL value for the root result id then make it a null result.
if ( ! isset($nonemptyComponents[$dqlAlias]) ) { if ( ! isset($nonemptyComponents[$dqlAlias]) ) {
$result[] = $this->_rsm->isMixed $result[] = $this->_rsm->isMixed
? array($entityKey => null) ? [$entityKey => null]
: null; : null;
$resultKey = $this->_resultCounter; $resultKey = $this->_resultCounter;
@ -199,7 +199,7 @@ class ArrayHydrator extends AbstractHydrator
// Check for an existing element // Check for an existing element
if ($this->_isSimpleQuery || ! isset($this->_identifierMap[$dqlAlias][$id[$dqlAlias]])) { if ($this->_isSimpleQuery || ! isset($this->_identifierMap[$dqlAlias][$id[$dqlAlias]])) {
$element = $this->_rsm->isMixed $element = $this->_rsm->isMixed
? array($entityKey => $data) ? [$entityKey => $data]
: $data; : $data;
if (isset($this->_rsm->indexByMap[$dqlAlias])) { if (isset($this->_rsm->indexByMap[$dqlAlias])) {

View File

@ -42,17 +42,17 @@ class ObjectHydrator extends AbstractHydrator
/** /**
* @var array * @var array
*/ */
private $identifierMap = array(); private $identifierMap = [];
/** /**
* @var array * @var array
*/ */
private $resultPointers = array(); private $resultPointers = [];
/** /**
* @var array * @var array
*/ */
private $idTemplate = array(); private $idTemplate = [];
/** /**
* @var integer * @var integer
@ -62,17 +62,17 @@ class ObjectHydrator extends AbstractHydrator
/** /**
* @var array * @var array
*/ */
private $rootAliases = array(); private $rootAliases = [];
/** /**
* @var array * @var array
*/ */
private $initializedCollections = array(); private $initializedCollections = [];
/** /**
* @var array * @var array
*/ */
private $existingCollections = array(); private $existingCollections = [];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -84,7 +84,7 @@ class ObjectHydrator extends AbstractHydrator
} }
foreach ($this->_rsm->aliasMap as $dqlAlias => $className) { foreach ($this->_rsm->aliasMap as $dqlAlias => $className) {
$this->identifierMap[$dqlAlias] = array(); $this->identifierMap[$dqlAlias] = [];
$this->idTemplate[$dqlAlias] = ''; $this->idTemplate[$dqlAlias] = '';
// Remember which associations are "fetch joined", so that we know where to inject // Remember which associations are "fetch joined", so that we know where to inject
@ -142,7 +142,7 @@ class ObjectHydrator extends AbstractHydrator
$this->identifierMap = $this->identifierMap =
$this->initializedCollections = $this->initializedCollections =
$this->existingCollections = $this->existingCollections =
$this->resultPointers = array(); $this->resultPointers = [];
if ($eagerLoad) { if ($eagerLoad) {
$this->_uow->triggerEagerLoads(); $this->_uow->triggerEagerLoads();
@ -156,7 +156,7 @@ class ObjectHydrator extends AbstractHydrator
*/ */
protected function hydrateAllData() protected function hydrateAllData()
{ {
$result = array(); $result = [];
while ($row = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $this->_stmt->fetch(PDO::FETCH_ASSOC)) {
$this->hydrateRowData($row, $result); $this->hydrateRowData($row, $result);
@ -326,7 +326,7 @@ class ObjectHydrator extends AbstractHydrator
{ {
// Initialize // Initialize
$id = $this->idTemplate; // initialize the id-memory $id = $this->idTemplate; // initialize the id-memory
$nonemptyComponents = array(); $nonemptyComponents = [];
// Split the row data into chunks of class data. // Split the row data into chunks of class data.
$rowData = $this->gatherRowData($row, $id, $nonemptyComponents); $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 this row has a NULL value for the root result id then make it a null result.
if ( ! isset($nonemptyComponents[$dqlAlias]) ) { if ( ! isset($nonemptyComponents[$dqlAlias]) ) {
if ($this->_rsm->isMixed) { if ($this->_rsm->isMixed) {
$result[] = array($entityKey => null); $result[] = [$entityKey => null];
} else { } else {
$result[] = null; $result[] = null;
} }
@ -492,7 +492,7 @@ class ObjectHydrator extends AbstractHydrator
$element = $this->getEntity($data, $dqlAlias); $element = $this->getEntity($data, $dqlAlias);
if ($this->_rsm->isMixed) { if ($this->_rsm->isMixed) {
$element = array($entityKey => $element); $element = [$entityKey => $element];
} }
if (isset($this->_rsm->indexByMap[$dqlAlias])) { if (isset($this->_rsm->indexByMap[$dqlAlias])) {

View File

@ -35,7 +35,7 @@ class ScalarHydrator extends AbstractHydrator
*/ */
protected function hydrateAllData() protected function hydrateAllData()
{ {
$result = array(); $result = [];
while ($data = $this->_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($data = $this->_stmt->fetch(\PDO::FETCH_ASSOC)) {
$this->hydrateRowData($data, $result); $this->hydrateRowData($data, $result);

View File

@ -62,7 +62,7 @@ class SimpleObjectHydrator extends AbstractHydrator
*/ */
protected function hydrateAllData() protected function hydrateAllData()
{ {
$result = array(); $result = [];
while ($row = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $this->_stmt->fetch(PDO::FETCH_ASSOC)) {
$this->hydrateRowData($row, $result); $this->hydrateRowData($row, $result);
@ -79,7 +79,7 @@ class SimpleObjectHydrator extends AbstractHydrator
protected function hydrateRowData(array $sqlResult, array &$result) protected function hydrateRowData(array $sqlResult, array &$result)
{ {
$entityName = $this->class->name; $entityName = $this->class->name;
$data = array(); $data = [];
// We need to find the correct entity class name if we have inheritance in resultset // We need to find the correct entity class name if we have inheritance in resultset
if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) {

View File

@ -47,7 +47,7 @@ final class HydrationCompleteHandler
/** /**
* @var array[] * @var array[]
*/ */
private $deferredPostLoadInvocations = array(); private $deferredPostLoadInvocations = [];
/** /**
* Constructor for this object * Constructor for this object
@ -75,7 +75,7 @@ final class HydrationCompleteHandler
return; return;
} }
$this->deferredPostLoadInvocations[] = array($class, $invoke, $entity); $this->deferredPostLoadInvocations[] = [$class, $invoke, $entity];
} }
/** /**
@ -86,7 +86,7 @@ final class HydrationCompleteHandler
public function hydrationComplete() public function hydrationComplete()
{ {
$toInvoke = $this->deferredPostLoadInvocations; $toInvoke = $this->deferredPostLoadInvocations;
$this->deferredPostLoadInvocations = array(); $this->deferredPostLoadInvocations = [];
foreach ($toInvoke as $classAndEntity) { foreach ($toInvoke as $classAndEntity) {
list($class, $invoke, $entity) = $classAndEntity; list($class, $invoke, $entity) = $classAndEntity;

View File

@ -84,7 +84,7 @@ class AssociationBuilder
*/ */
public function cascadeAll() public function cascadeAll()
{ {
$this->mapping['cascade'] = array("ALL"); $this->mapping['cascade'] = ["ALL"];
return $this; return $this;
} }
@ -183,14 +183,14 @@ class AssociationBuilder
*/ */
public function addJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null) public function addJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null)
{ {
$this->joinColumns[] = array( $this->joinColumns[] = [
'name' => $columnName, 'name' => $columnName,
'referencedColumnName' => $referencedColumnName, 'referencedColumnName' => $referencedColumnName,
'nullable' => $nullable, 'nullable' => $nullable,
'unique' => $unique, 'unique' => $unique,
'onDelete' => $onDelete, 'onDelete' => $onDelete,
'columnDefinition' => $columnDef, 'columnDefinition' => $columnDef,
); ];
return $this; return $this;
} }

View File

@ -91,11 +91,13 @@ class ClassMetadataBuilder
*/ */
public function addEmbedded($fieldName, $class, $columnPrefix = null) public function addEmbedded($fieldName, $class, $columnPrefix = null)
{ {
$this->cm->mapEmbedded(array( $this->cm->mapEmbedded(
[
'fieldName' => $fieldName, 'fieldName' => $fieldName,
'class' => $class, 'class' => $class,
'columnPrefix' => $columnPrefix 'columnPrefix' => $columnPrefix
)); ]
);
return $this; return $this;
} }
@ -135,7 +137,7 @@ class ClassMetadataBuilder
*/ */
public function setTable($name) public function setTable($name)
{ {
$this->cm->setPrimaryTable(array('name' => $name)); $this->cm->setPrimaryTable(['name' => $name]);
return $this; return $this;
} }
@ -151,10 +153,10 @@ class ClassMetadataBuilder
public function addIndex(array $columns, $name) public function addIndex(array $columns, $name)
{ {
if (!isset($this->cm->table['indexes'])) { 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; return $this;
} }
@ -170,10 +172,10 @@ class ClassMetadataBuilder
public function addUniqueConstraint(array $columns, $name) public function addUniqueConstraint(array $columns, $name)
{ {
if ( ! isset($this->cm->table['uniqueConstraints'])) { 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; return $this;
} }
@ -188,10 +190,12 @@ class ClassMetadataBuilder
*/ */
public function addNamedQuery($name, $dqlQuery) public function addNamedQuery($name, $dqlQuery)
{ {
$this->cm->addNamedQuery(array( $this->cm->addNamedQuery(
[
'name' => $name, 'name' => $name,
'query' => $dqlQuery, 'query' => $dqlQuery,
)); ]
);
return $this; return $this;
} }
@ -231,11 +235,13 @@ class ClassMetadataBuilder
*/ */
public function setDiscriminatorColumn($name, $type = 'string', $length = 255) public function setDiscriminatorColumn($name, $type = 'string', $length = 255)
{ {
$this->cm->setDiscriminatorColumn(array( $this->cm->setDiscriminatorColumn(
[
'name' => $name, 'name' => $name,
'type' => $type, 'type' => $type,
'length' => $length, 'length' => $length,
)); ]
);
return $this; return $this;
} }
@ -303,7 +309,7 @@ class ClassMetadataBuilder
* *
* @return ClassMetadataBuilder * @return ClassMetadataBuilder
*/ */
public function addField($name, $type, array $mapping = array()) public function addField($name, $type, array $mapping = [])
{ {
$mapping['fieldName'] = $name; $mapping['fieldName'] = $name;
$mapping['type'] = $type; $mapping['type'] = $type;
@ -325,10 +331,10 @@ class ClassMetadataBuilder
{ {
return new FieldBuilder( return new FieldBuilder(
$this, $this,
array( [
'fieldName' => $name, 'fieldName' => $name,
'type' => $type 'type' => $type
) ]
); );
} }
@ -344,11 +350,11 @@ class ClassMetadataBuilder
{ {
return new EmbeddedBuilder( return new EmbeddedBuilder(
$this, $this,
array( [
'fieldName' => $fieldName, 'fieldName' => $fieldName,
'class' => $class, 'class' => $class,
'columnPrefix' => null 'columnPrefix' => null
) ]
); );
} }
@ -386,10 +392,10 @@ class ClassMetadataBuilder
{ {
return new AssociationBuilder( return new AssociationBuilder(
$this, $this,
array( [
'fieldName' => $name, 'fieldName' => $name,
'targetEntity' => $targetEntity 'targetEntity' => $targetEntity
), ],
ClassMetadata::MANY_TO_ONE ClassMetadata::MANY_TO_ONE
); );
} }
@ -406,10 +412,10 @@ class ClassMetadataBuilder
{ {
return new AssociationBuilder( return new AssociationBuilder(
$this, $this,
array( [
'fieldName' => $name, 'fieldName' => $name,
'targetEntity' => $targetEntity 'targetEntity' => $targetEntity
), ],
ClassMetadata::ONE_TO_ONE ClassMetadata::ONE_TO_ONE
); );
} }
@ -463,10 +469,10 @@ class ClassMetadataBuilder
{ {
return new ManyToManyAssociationBuilder( return new ManyToManyAssociationBuilder(
$this, $this,
array( [
'fieldName' => $name, 'fieldName' => $name,
'targetEntity' => $targetEntity 'targetEntity' => $targetEntity
), ],
ClassMetadata::MANY_TO_MANY ClassMetadata::MANY_TO_MANY
); );
} }
@ -520,10 +526,10 @@ class ClassMetadataBuilder
{ {
return new OneToManyAssociationBuilder( return new OneToManyAssociationBuilder(
$this, $this,
array( [
'fieldName' => $name, 'fieldName' => $name,
'targetEntity' => $targetEntity 'targetEntity' => $targetEntity
), ],
ClassMetadata::ONE_TO_MANY ClassMetadata::ONE_TO_MANY
); );
} }

View File

@ -34,7 +34,7 @@ class EntityListenerBuilder
/** /**
* @var array Hash-map to handle event names. * @var array Hash-map to handle event names.
*/ */
static private $events = array( static private $events = [
Events::preRemove => true, Events::preRemove => true,
Events::postRemove => true, Events::postRemove => true,
Events::prePersist => true, Events::prePersist => true,
@ -43,7 +43,7 @@ class EntityListenerBuilder
Events::postUpdate => true, Events::postUpdate => true,
Events::postLoad => true, Events::postLoad => true,
Events::preFlush => true Events::preFlush => true
); ];
/** /**
* Lookup the entity class to find methods that match to event lifecycle names * Lookup the entity class to find methods that match to event lifecycle names

View File

@ -226,11 +226,11 @@ class FieldBuilder
*/ */
public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initialValue = 1) public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initialValue = 1)
{ {
$this->sequenceDef = array( $this->sequenceDef = [
'sequenceName' => $sequenceName, 'sequenceName' => $sequenceName,
'allocationSize' => $allocationSize, 'allocationSize' => $allocationSize,
'initialValue' => $initialValue, 'initialValue' => $initialValue,
); ];
return $this; return $this;
} }

View File

@ -37,7 +37,7 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder
/** /**
* @var array * @var array
*/ */
private $inverseJoinColumns = array(); private $inverseJoinColumns = [];
/** /**
* @param string $name * @param string $name
@ -65,14 +65,14 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder
*/ */
public function addInverseJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null) public function addInverseJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null)
{ {
$this->inverseJoinColumns[] = array( $this->inverseJoinColumns[] = [
'name' => $columnName, 'name' => $columnName,
'referencedColumnName' => $referencedColumnName, 'referencedColumnName' => $referencedColumnName,
'nullable' => $nullable, 'nullable' => $nullable,
'unique' => $unique, 'unique' => $unique,
'onDelete' => $onDelete, 'onDelete' => $onDelete,
'columnDefinition' => $columnDef, 'columnDefinition' => $columnDef,
); ];
return $this; return $this;
} }
@ -83,7 +83,7 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder
public function build() public function build()
{ {
$mapping = $this->mapping; $mapping = $this->mapping;
$mapping['joinTable'] = array(); $mapping['joinTable'] = [];
if ($this->joinColumns) { if ($this->joinColumns) {
$mapping['joinTable']['joinColumns'] = $this->joinColumns; $mapping['joinTable']['joinColumns'] = $this->joinColumns;
} }

View File

@ -68,7 +68,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
/** /**
* @var array * @var array
*/ */
private $embeddablesActiveNesting = array(); private $embeddablesActiveNesting = [];
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -350,9 +350,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
{ {
$allClasses = $this->driver->getAllClassNames(); $allClasses = $this->driver->getAllClassNames();
$fqcn = $class->getName(); $fqcn = $class->getName();
$map = array($this->getShortName($class->name) => $fqcn); $map = [$this->getShortName($class->name) => $fqcn];
$duplicates = array(); $duplicates = [];
foreach ($allClasses as $subClassCandidate) { foreach ($allClasses as $subClassCandidate) {
if (is_subclass_of($subClassCandidate, $fqcn)) { if (is_subclass_of($subClassCandidate, $fqcn)) {
$shortName = $this->getShortName($subClassCandidate); $shortName = $this->getShortName($subClassCandidate);
@ -475,7 +475,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
$embeddableMetadata = $this->getMetadataFor($embeddableClass['class']); $embeddableMetadata = $this->getMetadataFor($embeddableClass['class']);
$parentClass->mapEmbedded(array( $parentClass->mapEmbedded(
[
'fieldName' => $prefix . '.' . $property, 'fieldName' => $prefix . '.' . $property,
'class' => $embeddableMetadata->name, 'class' => $embeddableMetadata->name,
'columnPrefix' => $embeddableClass['columnPrefix'], 'columnPrefix' => $embeddableClass['columnPrefix'],
@ -483,7 +484,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
? $prefix . '.' . $embeddableClass['declaredField'] ? $prefix . '.' . $embeddableClass['declaredField']
: $prefix, : $prefix,
'originalField' => $embeddableClass['originalField'] ?: $property, 'originalField' => $embeddableClass['originalField'] ?: $property,
)); ]
);
} }
} }
@ -501,7 +503,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
return; return;
} }
foreach (array('uniqueConstraints', 'indexes') as $indexType) { foreach (['uniqueConstraints', 'indexes'] as $indexType) {
if (isset($parentClass->table[$indexType])) { if (isset($parentClass->table[$indexType])) {
foreach ($parentClass->table[$indexType] as $indexName => $index) { foreach ($parentClass->table[$indexType] as $indexName => $index) {
if (isset($subClass->table[$indexType][$indexName])) { if (isset($subClass->table[$indexType][$indexName])) {
@ -528,10 +530,12 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
{ {
foreach ($parentClass->namedQueries as $name => $query) { foreach ($parentClass->namedQueries as $name => $query) {
if ( ! isset ($subClass->namedQueries[$name])) { if ( ! isset ($subClass->namedQueries[$name])) {
$subClass->addNamedQuery(array( $subClass->addNamedQuery(
[
'name' => $query['name'], 'name' => $query['name'],
'query' => $query['query'] 'query' => $query['query']
)); ]
);
} }
} }
} }
@ -550,13 +554,15 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
{ {
foreach ($parentClass->namedNativeQueries as $name => $query) { foreach ($parentClass->namedNativeQueries as $name => $query) {
if ( ! isset ($subClass->namedNativeQueries[$name])) { if ( ! isset ($subClass->namedNativeQueries[$name])) {
$subClass->addNamedNativeQuery(array( $subClass->addNamedNativeQuery(
[
'name' => $query['name'], 'name' => $query['name'],
'query' => $query['query'], 'query' => $query['query'],
'isSelfClass' => $query['isSelfClass'], 'isSelfClass' => $query['isSelfClass'],
'resultSetMapping' => $query['resultSetMapping'], 'resultSetMapping' => $query['resultSetMapping'],
'resultClass' => $query['isSelfClass'] ? $subClass->name : $query['resultClass'], 'resultClass' => $query['isSelfClass'] ? $subClass->name : $query['resultClass'],
)); ]
);
} }
} }
} }
@ -575,21 +581,23 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
{ {
foreach ($parentClass->sqlResultSetMappings as $name => $mapping) { foreach ($parentClass->sqlResultSetMappings as $name => $mapping) {
if ( ! isset ($subClass->sqlResultSetMappings[$name])) { if ( ! isset ($subClass->sqlResultSetMappings[$name])) {
$entities = array(); $entities = [];
foreach ($mapping['entities'] as $entity) { foreach ($mapping['entities'] as $entity) {
$entities[] = array( $entities[] = [
'fields' => $entity['fields'], 'fields' => $entity['fields'],
'isSelfClass' => $entity['isSelfClass'], 'isSelfClass' => $entity['isSelfClass'],
'discriminatorColumn' => $entity['discriminatorColumn'], 'discriminatorColumn' => $entity['discriminatorColumn'],
'entityClass' => $entity['isSelfClass'] ? $subClass->name : $entity['entityClass'], 'entityClass' => $entity['isSelfClass'] ? $subClass->name : $entity['entityClass'],
); ];
} }
$subClass->addSqlResultSetMapping(array( $subClass->addSqlResultSetMapping(
[
'name' => $mapping['name'], 'name' => $mapping['name'],
'columns' => $mapping['columns'], 'columns' => $mapping['columns'],
'entities' => $entities, 'entities' => $entities,
)); ]
);
} }
} }
} }
@ -629,9 +637,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
$quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']); $quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
$sequencePrefix = $class->getSequencePrefix($this->getTargetPlatform()); $sequencePrefix = $class->getSequencePrefix($this->getTargetPlatform());
$sequenceName = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName); $sequenceName = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName);
$definition = array( $definition = [
'sequenceName' => $this->getTargetPlatform()->fixSchemaElementName($sequenceName) 'sequenceName' => $this->getTargetPlatform()->fixSchemaElementName($sequenceName)
); ];
if ($quoted) { if ($quoted) {
$definition['quoted'] = true; $definition['quoted'] = true;
@ -661,11 +669,11 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
$sequenceName = $class->getSequenceName($this->getTargetPlatform()); $sequenceName = $class->getSequenceName($this->getTargetPlatform());
$quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']); $quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
$definition = array( $definition = [
'sequenceName' => $this->getTargetPlatform()->fixSchemaElementName($sequenceName), 'sequenceName' => $this->getTargetPlatform()->fixSchemaElementName($sequenceName),
'allocationSize' => 1, 'allocationSize' => 1,
'initialValue' => 1, 'initialValue' => 1,
); ];
if ($quoted) { if ($quoted) {
$definition['quoted'] = true; $definition['quoted'] = true;

View File

@ -275,28 +275,28 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @var array * @var array
*/ */
public $parentClasses = array(); public $parentClasses = [];
/** /**
* READ-ONLY: The names of all subclasses (descendants). * READ-ONLY: The names of all subclasses (descendants).
* *
* @var array * @var array
*/ */
public $subClasses = array(); public $subClasses = [];
/** /**
* READ-ONLY: The names of all embedded classes based on properties. * READ-ONLY: The names of all embedded classes based on properties.
* *
* @var array * @var array
*/ */
public $embeddedClasses = array(); public $embeddedClasses = [];
/** /**
* READ-ONLY: The named queries allowed to be called directly from Repository. * READ-ONLY: The named queries allowed to be called directly from Repository.
* *
* @var array * @var array
*/ */
public $namedQueries = array(); public $namedQueries = [];
/** /**
* READ-ONLY: The named native queries allowed to be called directly from Repository. * READ-ONLY: The named native queries allowed to be called directly from Repository.
@ -313,7 +313,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @var array * @var array
*/ */
public $namedNativeQueries = array(); public $namedNativeQueries = [];
/** /**
* READ-ONLY: The mappings of the results of native SQL queries. * READ-ONLY: The mappings of the results of native SQL queries.
@ -329,7 +329,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @var array * @var array
*/ */
public $sqlResultSetMappings = array(); public $sqlResultSetMappings = [];
/** /**
* READ-ONLY: The field names of all fields that are part of the identifier/primary key * 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 * @var array
*/ */
public $identifier = array(); public $identifier = [];
/** /**
* READ-ONLY: The inheritance mapping type used by the class. * READ-ONLY: The inheritance mapping type used by the class.
@ -394,7 +394,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @var array * @var array
*/ */
public $fieldMappings = array(); public $fieldMappings = [];
/** /**
* READ-ONLY: An array of field names. Used to look up field names from column names. * 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 * @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. * 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. * @deprecated 3.0 Remove this.
*/ */
public $columnNames = array(); public $columnNames = [];
/** /**
* READ-ONLY: The discriminator value of this class. * READ-ONLY: The discriminator value of this class.
@ -437,7 +437,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @see discriminatorColumn * @see discriminatorColumn
*/ */
public $discriminatorMap = array(); public $discriminatorMap = [];
/** /**
* READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE
@ -465,14 +465,14 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @var array[] * @var array[]
*/ */
public $lifecycleCallbacks = array(); public $lifecycleCallbacks = [];
/** /**
* READ-ONLY: The registered entity listeners. * READ-ONLY: The registered entity listeners.
* *
* @var array * @var array
*/ */
public $entityListeners = array(); public $entityListeners = [];
/** /**
* READ-ONLY: The association mappings of this class. * READ-ONLY: The association mappings of this class.
@ -529,7 +529,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @var array * @var array
*/ */
public $associationMappings = array(); public $associationMappings = [];
/** /**
* READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite.
@ -642,7 +642,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @var \ReflectionProperty[] * @var \ReflectionProperty[]
*/ */
public $reflFields = array(); public $reflFields = [];
/** /**
* @var \Doctrine\Instantiator\InstantiatorInterface|null * @var \Doctrine\Instantiator\InstantiatorInterface|null
@ -715,7 +715,7 @@ class ClassMetadataInfo implements ClassMetadata
public function getIdentifierValues($entity) public function getIdentifierValues($entity)
{ {
if ($this->isIdentifierComposite) { if ($this->isIdentifierComposite) {
$id = array(); $id = [];
foreach ($this->identifier as $idField) { foreach ($this->identifier as $idField) {
$value = $this->reflFields[$idField]->getValue($entity); $value = $this->reflFields[$idField]->getValue($entity);
@ -732,10 +732,10 @@ class ClassMetadataInfo implements ClassMetadata
$value = $this->reflFields[$id]->getValue($entity); $value = $this->reflFields[$id]->getValue($entity);
if (null === $value) { if (null === $value) {
return array(); return [];
} }
return array($id => $value); return [$id => $value];
} }
/** /**
@ -810,7 +810,7 @@ class ClassMetadataInfo implements ClassMetadata
public function __sleep() public function __sleep()
{ {
// This metadata is always serialized/cached. // This metadata is always serialized/cached.
$serialized = array( $serialized = [
'associationMappings', 'associationMappings',
'columnNames', //TODO: 3.0 Remove this. Can use fieldMappings[$fieldName]['columnName'] 'columnNames', //TODO: 3.0 Remove this. Can use fieldMappings[$fieldName]['columnName']
'fieldMappings', 'fieldMappings',
@ -823,7 +823,7 @@ class ClassMetadataInfo implements ClassMetadata
'table', 'table',
'rootEntityName', 'rootEntityName',
'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime. 'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime.
); ];
// The rest of the metadata is only serialized if necessary. // The rest of the metadata is only serialized if necessary.
if ($this->changeTrackingPolicy != self::CHANGETRACKING_DEFERRED_IMPLICIT) { if ($this->changeTrackingPolicy != self::CHANGETRACKING_DEFERRED_IMPLICIT) {
@ -925,7 +925,7 @@ class ClassMetadataInfo implements ClassMetadata
$this->reflClass = $reflService->getClass($this->name); $this->reflClass = $reflService->getClass($this->name);
$this->instantiator = $this->instantiator ?: new Instantiator(); $this->instantiator = $this->instantiator ?: new Instantiator();
$parentReflFields = array(); $parentReflFields = [];
foreach ($this->embeddedClasses as $property => $embeddedClass) { foreach ($this->embeddedClasses as $property => $embeddedClass) {
if (isset($embeddedClass['declaredField'])) { if (isset($embeddedClass['declaredField'])) {
@ -1533,9 +1533,9 @@ class ClassMetadataInfo implements ClassMetadata
} }
// Cascades // 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)) { if (in_array('all', $cascades)) {
$cascades = $allCascades; $cascades = $allCascades;
} elseif (count($cascades) !== count(array_intersect($cascades, $allCascades))) { } elseif (count($cascades) !== count(array_intersect($cascades, $allCascades))) {
@ -1577,15 +1577,15 @@ class ClassMetadataInfo implements ClassMetadata
if ($mapping['isOwningSide']) { if ($mapping['isOwningSide']) {
if (empty($mapping['joinColumns'])) { if (empty($mapping['joinColumns'])) {
// Apply default join column // Apply default join column
$mapping['joinColumns'] = array( $mapping['joinColumns'] = [
array( [
'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name), 'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name),
'referencedColumnName' => $this->namingStrategy->referenceColumnName() 'referencedColumnName' => $this->namingStrategy->referenceColumnName()
) ]
); ];
} }
$uniqueConstraintColumns = array(); $uniqueConstraintColumns = [];
foreach ($mapping['joinColumns'] as &$joinColumn) { foreach ($mapping['joinColumns'] as &$joinColumn) {
if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { 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."); 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 'columns' => $uniqueConstraintColumns
); ];
} }
$mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']); $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']);
@ -1699,26 +1699,26 @@ class ClassMetadataInfo implements ClassMetadata
&& (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns']))); && (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns'])));
if ( ! isset($mapping['joinTable']['joinColumns'])) { if ( ! isset($mapping['joinTable']['joinColumns'])) {
$mapping['joinTable']['joinColumns'] = array( $mapping['joinTable']['joinColumns'] = [
array( [
'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null), 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null),
'referencedColumnName' => $this->namingStrategy->referenceColumnName(), 'referencedColumnName' => $this->namingStrategy->referenceColumnName(),
'onDelete' => 'CASCADE' 'onDelete' => 'CASCADE'
) ]
); ];
} }
if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) { if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) {
$mapping['joinTable']['inverseJoinColumns'] = array( $mapping['joinTable']['inverseJoinColumns'] = [
array( [
'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null), 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null),
'referencedColumnName' => $this->namingStrategy->referenceColumnName(), 'referencedColumnName' => $this->namingStrategy->referenceColumnName(),
'onDelete' => 'CASCADE' 'onDelete' => 'CASCADE'
) ]
); ];
} }
$mapping['joinTableColumns'] = array(); $mapping['joinTableColumns'] = [];
foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) { foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) {
if (empty($joinColumn['name'])) { if (empty($joinColumn['name'])) {
@ -1874,7 +1874,7 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function getIdentifierColumnNames() public function getIdentifierColumnNames()
{ {
$columnNames = array(); $columnNames = [];
foreach ($this->identifier as $idProperty) { foreach ($this->identifier as $idProperty) {
if (isset($this->fieldMappings[$idProperty])) { if (isset($this->fieldMappings[$idProperty])) {
@ -2411,11 +2411,11 @@ class ClassMetadataInfo implements ClassMetadata
$query = $queryMapping['query']; $query = $queryMapping['query'];
$dql = str_replace('__CLASS__', $this->name, $query); $dql = str_replace('__CLASS__', $this->name, $query);
$this->namedQueries[$name] = array( $this->namedQueries[$name] = [
'name' => $name, 'name' => $name,
'query' => $query, 'query' => $query,
'dql' => $dql, 'dql' => $dql,
); ];
} }
/** /**
@ -2657,7 +2657,7 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function getLifecycleCallbacks($event) 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); $class = $this->fullyQualifiedClassName($class);
$listener = array( $listener = [
'class' => $class, 'class' => $class,
'method' => $method, 'method' => $method,
); ];
if ( ! class_exists($class)) { if ( ! class_exists($class)) {
throw MappingException::entityListenerClassNotFound($class, $this->name); throw MappingException::entityListenerClassNotFound($class, $this->name);
@ -2753,7 +2753,7 @@ class ClassMetadataInfo implements ClassMetadata
$columnDef['type'] = "string"; $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']); throw MappingException::invalidDiscriminatorColumnType($this->name, $columnDef['type']);
} }
@ -3021,7 +3021,7 @@ class ClassMetadataInfo implements ClassMetadata
$this->versionField = $mapping['fieldName']; $this->versionField = $mapping['fieldName'];
if ( ! isset($mapping['default'])) { if ( ! isset($mapping['default'])) {
if (in_array($mapping['type'], array('integer', 'bigint', 'smallint'))) { if (in_array($mapping['type'], ['integer', 'bigint', 'smallint'])) {
$mapping['default'] = 1; $mapping['default'] = 1;
} else if ($mapping['type'] == 'datetime') { } else if ($mapping['type'] == 'datetime') {
$mapping['default'] = 'CURRENT_TIMESTAMP'; $mapping['default'] = 'CURRENT_TIMESTAMP';
@ -3115,7 +3115,7 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function getQuotedIdentifierColumnNames($platform) public function getQuotedIdentifierColumnNames($platform)
{ {
$quotedColumnNames = array(); $quotedColumnNames = [];
foreach ($this->identifier as $idProperty) { foreach ($this->identifier as $idProperty) {
if (isset($this->fieldMappings[$idProperty])) { if (isset($this->fieldMappings[$idProperty])) {
@ -3217,7 +3217,7 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function getAssociationsByTargetClass($targetClass) public function getAssociationsByTargetClass($targetClass)
{ {
$relations = array(); $relations = [];
foreach ($this->associationMappings as $mapping) { foreach ($this->associationMappings as $mapping) {
if ($mapping['targetEntity'] == $targetClass) { if ($mapping['targetEntity'] == $targetClass) {
@ -3273,12 +3273,12 @@ class ClassMetadataInfo implements ClassMetadata
{ {
$this->assertFieldNotMapped($mapping['fieldName']); $this->assertFieldNotMapped($mapping['fieldName']);
$this->embeddedClasses[$mapping['fieldName']] = array( $this->embeddedClasses[$mapping['fieldName']] = [
'class' => $this->fullyQualifiedClassName($mapping['class']), 'class' => $this->fullyQualifiedClassName($mapping['class']),
'columnPrefix' => $mapping['columnPrefix'], 'columnPrefix' => $mapping['columnPrefix'],
'declaredField' => isset($mapping['declaredField']) ? $mapping['declaredField'] : null, 'declaredField' => isset($mapping['declaredField']) ? $mapping['declaredField'] : null,
'originalField' => isset($mapping['originalField']) ? $mapping['originalField'] : null, 'originalField' => isset($mapping['originalField']) ? $mapping['originalField'] : null,
); ];
} }
/** /**

View File

@ -67,7 +67,7 @@ final class Column implements Annotation
/** /**
* @var array * @var array
*/ */
public $options = array(); public $options = [];
/** /**
* @var string * @var string

View File

@ -31,7 +31,7 @@ class DefaultEntityListenerResolver implements EntityListenerResolver
/** /**
* @var array Map to store entity listener instances. * @var array Map to store entity listener instances.
*/ */
private $instances = array(); private $instances = [];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -39,7 +39,7 @@ class DefaultEntityListenerResolver implements EntityListenerResolver
public function clear($className = null) public function clear($className = null)
{ {
if ($className === null) { if ($className === null) {
$this->instances = array(); $this->instances = [];
return; return;
} }

View File

@ -116,7 +116,7 @@ class DefaultQuoteStrategy implements QuoteStrategy
*/ */
public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform) public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform)
{ {
$quotedColumnNames = array(); $quotedColumnNames = [];
foreach ($class->identifier as $fieldName) { foreach ($class->identifier as $fieldName) {
if (isset($class->fieldMappings[$fieldName])) { if (isset($class->fieldMappings[$fieldName])) {

View File

@ -42,10 +42,10 @@ class AnnotationDriver extends AbstractAnnotationDriver
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
protected $entityAnnotationClasses = array( protected $entityAnnotationClasses = [
'Doctrine\ORM\Mapping\Entity' => 1, 'Doctrine\ORM\Mapping\Entity' => 1,
'Doctrine\ORM\Mapping\MappedSuperclass' => 2, 'Doctrine\ORM\Mapping\MappedSuperclass' => 2,
); ];
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -97,14 +97,14 @@ class AnnotationDriver extends AbstractAnnotationDriver
// Evaluate Table annotation // Evaluate Table annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\Table'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\Table'])) {
$tableAnnot = $classAnnotations['Doctrine\ORM\Mapping\Table']; $tableAnnot = $classAnnotations['Doctrine\ORM\Mapping\Table'];
$primaryTable = array( $primaryTable = [
'name' => $tableAnnot->name, 'name' => $tableAnnot->name,
'schema' => $tableAnnot->schema 'schema' => $tableAnnot->schema
); ];
if ($tableAnnot->indexes !== null) { if ($tableAnnot->indexes !== null) {
foreach ($tableAnnot->indexes as $indexAnnot) { foreach ($tableAnnot->indexes as $indexAnnot) {
$index = array('columns' => $indexAnnot->columns); $index = ['columns' => $indexAnnot->columns];
if ( ! empty($indexAnnot->flags)) { if ( ! empty($indexAnnot->flags)) {
$index['flags'] = $indexAnnot->flags; $index['flags'] = $indexAnnot->flags;
@ -124,7 +124,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
if ($tableAnnot->uniqueConstraints !== null) { if ($tableAnnot->uniqueConstraints !== null) {
foreach ($tableAnnot->uniqueConstraints as $uniqueConstraintAnnot) { foreach ($tableAnnot->uniqueConstraints as $uniqueConstraintAnnot) {
$uniqueConstraint = array('columns' => $uniqueConstraintAnnot->columns); $uniqueConstraint = ['columns' => $uniqueConstraintAnnot->columns];
if ( ! empty($uniqueConstraintAnnot->options)) { if ( ! empty($uniqueConstraintAnnot->options)) {
$uniqueConstraint['options'] = $uniqueConstraintAnnot->options; $uniqueConstraint['options'] = $uniqueConstraintAnnot->options;
@ -148,10 +148,10 @@ class AnnotationDriver extends AbstractAnnotationDriver
// Evaluate @Cache annotation // Evaluate @Cache annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\Cache'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\Cache'])) {
$cacheAnnot = $classAnnotations['Doctrine\ORM\Mapping\Cache']; $cacheAnnot = $classAnnotations['Doctrine\ORM\Mapping\Cache'];
$cacheMap = array( $cacheMap = [
'region' => $cacheAnnot->region, 'region' => $cacheAnnot->region,
'usage' => constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), 'usage' => constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage),
); ];
$metadata->enableCache($cacheMap); $metadata->enableCache($cacheMap);
} }
@ -161,12 +161,14 @@ class AnnotationDriver extends AbstractAnnotationDriver
$namedNativeQueriesAnnot = $classAnnotations['Doctrine\ORM\Mapping\NamedNativeQueries']; $namedNativeQueriesAnnot = $classAnnotations['Doctrine\ORM\Mapping\NamedNativeQueries'];
foreach ($namedNativeQueriesAnnot->value as $namedNativeQuery) { foreach ($namedNativeQueriesAnnot->value as $namedNativeQuery) {
$metadata->addNamedNativeQuery(array( $metadata->addNamedNativeQuery(
[
'name' => $namedNativeQuery->name, 'name' => $namedNativeQuery->name,
'query' => $namedNativeQuery->query, 'query' => $namedNativeQuery->query,
'resultClass' => $namedNativeQuery->resultClass, 'resultClass' => $namedNativeQuery->resultClass,
'resultSetMapping' => $namedNativeQuery->resultSetMapping, 'resultSetMapping' => $namedNativeQuery->resultSetMapping,
)); ]
);
} }
} }
@ -175,36 +177,38 @@ class AnnotationDriver extends AbstractAnnotationDriver
$sqlResultSetMappingsAnnot = $classAnnotations['Doctrine\ORM\Mapping\SqlResultSetMappings']; $sqlResultSetMappingsAnnot = $classAnnotations['Doctrine\ORM\Mapping\SqlResultSetMappings'];
foreach ($sqlResultSetMappingsAnnot->value as $resultSetMapping) { foreach ($sqlResultSetMappingsAnnot->value as $resultSetMapping) {
$entities = array(); $entities = [];
$columns = array(); $columns = [];
foreach ($resultSetMapping->entities as $entityResultAnnot) { foreach ($resultSetMapping->entities as $entityResultAnnot) {
$entityResult = array( $entityResult = [
'fields' => array(), 'fields' => [],
'entityClass' => $entityResultAnnot->entityClass, 'entityClass' => $entityResultAnnot->entityClass,
'discriminatorColumn' => $entityResultAnnot->discriminatorColumn, 'discriminatorColumn' => $entityResultAnnot->discriminatorColumn,
); ];
foreach ($entityResultAnnot->fields as $fieldResultAnnot) { foreach ($entityResultAnnot->fields as $fieldResultAnnot) {
$entityResult['fields'][] = array( $entityResult['fields'][] = [
'name' => $fieldResultAnnot->name, 'name' => $fieldResultAnnot->name,
'column' => $fieldResultAnnot->column 'column' => $fieldResultAnnot->column
); ];
} }
$entities[] = $entityResult; $entities[] = $entityResult;
} }
foreach ($resultSetMapping->columns as $columnResultAnnot) { foreach ($resultSetMapping->columns as $columnResultAnnot) {
$columns[] = array( $columns[] = [
'name' => $columnResultAnnot->name, 'name' => $columnResultAnnot->name,
); ];
} }
$metadata->addSqlResultSetMapping(array( $metadata->addSqlResultSetMapping(
[
'name' => $resultSetMapping->name, 'name' => $resultSetMapping->name,
'entities' => $entities, 'entities' => $entities,
'columns' => $columns 'columns' => $columns
)); ]
);
} }
} }
@ -220,10 +224,12 @@ class AnnotationDriver extends AbstractAnnotationDriver
if ( ! ($namedQuery instanceof \Doctrine\ORM\Mapping\NamedQuery)) { if ( ! ($namedQuery instanceof \Doctrine\ORM\Mapping\NamedQuery)) {
throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations."); throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations.");
} }
$metadata->addNamedQuery(array( $metadata->addNamedQuery(
[
'name' => $namedQuery->name, 'name' => $namedQuery->name,
'query' => $namedQuery->query 'query' => $namedQuery->query
)); ]
);
} }
} }
@ -240,14 +246,16 @@ class AnnotationDriver extends AbstractAnnotationDriver
if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'])) {
$discrColumnAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn']; $discrColumnAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'];
$metadata->setDiscriminatorColumn(array( $metadata->setDiscriminatorColumn(
[
'name' => $discrColumnAnnot->name, 'name' => $discrColumnAnnot->name,
'type' => $discrColumnAnnot->type ?: 'string', 'type' => $discrColumnAnnot->type ?: 'string',
'length' => $discrColumnAnnot->length ?: 255, 'length' => $discrColumnAnnot->length ?: 255,
'columnDefinition' => $discrColumnAnnot->columnDefinition, 'columnDefinition' => $discrColumnAnnot->columnDefinition,
)); ]
);
} else { } else {
$metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]);
} }
// Evaluate DiscriminatorMap annotation // Evaluate DiscriminatorMap annotation
@ -278,18 +286,21 @@ class AnnotationDriver extends AbstractAnnotationDriver
continue; continue;
} }
$mapping = array(); $mapping = [];
$mapping['fieldName'] = $property->getName(); $mapping['fieldName'] = $property->getName();
// Evaluate @Cache annotation // Evaluate @Cache annotation
if (($cacheAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Cache')) !== null) { if (($cacheAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Cache')) !== null) {
$mapping['cache'] = $metadata->getAssociationCacheDefaults($mapping['fieldName'], array( $mapping['cache'] = $metadata->getAssociationCacheDefaults(
$mapping['fieldName'],
[
'usage' => constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), 'usage' => constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage),
'region' => $cacheAnnot->region, 'region' => $cacheAnnot->region,
)); ]
);
} }
// Check for JoinColumn/JoinColumns annotations // Check for JoinColumn/JoinColumns annotations
$joinColumns = array(); $joinColumns = [];
if ($joinColumnAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinColumn')) { if ($joinColumnAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinColumn')) {
$joinColumns[] = $this->joinColumnToArray($joinColumnAnnot); $joinColumns[] = $this->joinColumnToArray($joinColumnAnnot);
@ -324,17 +335,21 @@ class AnnotationDriver extends AbstractAnnotationDriver
// Check for SequenceGenerator/TableGenerator definition // Check for SequenceGenerator/TableGenerator definition
if ($seqGeneratorAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\SequenceGenerator')) { if ($seqGeneratorAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\SequenceGenerator')) {
$metadata->setSequenceGeneratorDefinition(array( $metadata->setSequenceGeneratorDefinition(
[
'sequenceName' => $seqGeneratorAnnot->sequenceName, 'sequenceName' => $seqGeneratorAnnot->sequenceName,
'allocationSize' => $seqGeneratorAnnot->allocationSize, 'allocationSize' => $seqGeneratorAnnot->allocationSize,
'initialValue' => $seqGeneratorAnnot->initialValue 'initialValue' => $seqGeneratorAnnot->initialValue
)); ]
);
} else if ($this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\TableGenerator')) { } else if ($this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\TableGenerator')) {
throw MappingException::tableIdGeneratorNotImplemented($className); throw MappingException::tableIdGeneratorNotImplemented($className);
} else if ($customGeneratorAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\CustomIdGenerator')) { } else if ($customGeneratorAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\CustomIdGenerator')) {
$metadata->setCustomGeneratorDefinition(array( $metadata->setCustomGeneratorDefinition(
[
'class' => $customGeneratorAnnot->class 'class' => $customGeneratorAnnot->class
)); ]
);
} }
} else if ($oneToOneAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\OneToOne')) { } else if ($oneToOneAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\OneToOne')) {
if ($idAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Id')) { 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); $mapping['fetch'] = $this->getFetchMode($className, $manyToOneAnnot->fetch);
$metadata->mapManyToOne($mapping); $metadata->mapManyToOne($mapping);
} else if ($manyToManyAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\ManyToMany')) { } else if ($manyToManyAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\ManyToMany')) {
$joinTable = array(); $joinTable = [];
if ($joinTableAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinTable')) { if ($joinTableAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinTable')) {
$joinTable = array( $joinTable = [
'name' => $joinTableAnnot->name, 'name' => $joinTableAnnot->name,
'schema' => $joinTableAnnot->schema 'schema' => $joinTableAnnot->schema
); ];
foreach ($joinTableAnnot->joinColumns as $joinColumn) { foreach ($joinTableAnnot->joinColumns as $joinColumn) {
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn); $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn);
@ -418,12 +433,12 @@ class AnnotationDriver extends AbstractAnnotationDriver
$associationOverridesAnnot = $classAnnotations['Doctrine\ORM\Mapping\AssociationOverrides']; $associationOverridesAnnot = $classAnnotations['Doctrine\ORM\Mapping\AssociationOverrides'];
foreach ($associationOverridesAnnot->value as $associationOverride) { foreach ($associationOverridesAnnot->value as $associationOverride) {
$override = array(); $override = [];
$fieldName = $associationOverride->name; $fieldName = $associationOverride->name;
// Check for JoinColumn/JoinColumns annotations // Check for JoinColumn/JoinColumns annotations
if ($associationOverride->joinColumns) { if ($associationOverride->joinColumns) {
$joinColumns = array(); $joinColumns = [];
foreach ($associationOverride->joinColumns as $joinColumn) { foreach ($associationOverride->joinColumns as $joinColumn) {
$joinColumns[] = $this->joinColumnToArray($joinColumn); $joinColumns[] = $this->joinColumnToArray($joinColumn);
@ -435,10 +450,10 @@ class AnnotationDriver extends AbstractAnnotationDriver
// Check for JoinTable annotations // Check for JoinTable annotations
if ($associationOverride->joinTable) { if ($associationOverride->joinTable) {
$joinTableAnnot = $associationOverride->joinTable; $joinTableAnnot = $associationOverride->joinTable;
$joinTable = array( $joinTable = [
'name' => $joinTableAnnot->name, 'name' => $joinTableAnnot->name,
'schema' => $joinTableAnnot->schema 'schema' => $joinTableAnnot->schema
); ];
foreach ($joinTableAnnot->joinColumns as $joinColumn) { foreach ($joinTableAnnot->joinColumns as $joinColumn) {
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn); $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn);
@ -542,40 +557,40 @@ class AnnotationDriver extends AbstractAnnotationDriver
*/ */
private function getMethodCallbacks(\ReflectionMethod $method) private function getMethodCallbacks(\ReflectionMethod $method)
{ {
$callbacks = array(); $callbacks = [];
$annotations = $this->reader->getMethodAnnotations($method); $annotations = $this->reader->getMethodAnnotations($method);
foreach ($annotations as $annot) { foreach ($annotations as $annot) {
if ($annot instanceof \Doctrine\ORM\Mapping\PrePersist) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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) private function joinColumnToArray(JoinColumn $joinColumn)
{ {
return array( return [
'name' => $joinColumn->name, 'name' => $joinColumn->name,
'unique' => $joinColumn->unique, 'unique' => $joinColumn->unique,
'nullable' => $joinColumn->nullable, 'nullable' => $joinColumn->nullable,
'onDelete' => $joinColumn->onDelete, 'onDelete' => $joinColumn->onDelete,
'columnDefinition' => $joinColumn->columnDefinition, 'columnDefinition' => $joinColumn->columnDefinition,
'referencedColumnName' => $joinColumn->referencedColumnName, 'referencedColumnName' => $joinColumn->referencedColumnName,
); ];
} }
/** /**
@ -610,7 +625,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
*/ */
private function columnToArray($fieldName, Column $column) private function columnToArray($fieldName, Column $column)
{ {
$mapping = array( $mapping = [
'fieldName' => $fieldName, 'fieldName' => $fieldName,
'type' => $column->type, 'type' => $column->type,
'scale' => $column->scale, 'scale' => $column->scale,
@ -618,7 +633,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
'unique' => $column->unique, 'unique' => $column->unique,
'nullable' => $column->nullable, 'nullable' => $column->nullable,
'precision' => $column->precision 'precision' => $column->precision
); ];
if ($column->options) { if ($column->options) {
$mapping['options'] = $column->options; $mapping['options'] = $column->options;
@ -643,7 +658,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
* *
* @return AnnotationDriver * @return AnnotationDriver
*/ */
static public function create($paths = array(), AnnotationReader $reader = null) static public function create($paths = [], AnnotationReader $reader = null)
{ {
if ($reader == null) { if ($reader == null) {
$reader = new AnnotationReader(); $reader = new AnnotationReader();

View File

@ -54,22 +54,22 @@ class DatabaseDriver implements MappingDriver
/** /**
* @var array * @var array
*/ */
private $classToTableNames = array(); private $classToTableNames = [];
/** /**
* @var array * @var array
*/ */
private $manyToManyTables = array(); private $manyToManyTables = [];
/** /**
* @var array * @var array
*/ */
private $classNamesForTables = array(); private $classNamesForTables = [];
/** /**
* @var array * @var array
*/ */
private $fieldNamesForColumns = array(); private $fieldNamesForColumns = [];
/** /**
* The namespace for the generated entities. * The namespace for the generated entities.
@ -153,7 +153,7 @@ class DatabaseDriver implements MappingDriver
*/ */
public function setTables($entityTables, $manyToManyTables) public function setTables($entityTables, $manyToManyTables)
{ {
$this->tables = $this->manyToManyTables = $this->classToTableNames = array(); $this->tables = $this->manyToManyTables = $this->classToTableNames = [];
foreach ($entityTables as $table) { foreach ($entityTables as $table) {
$className = $this->getClassNameForTable($table->getName()); $className = $this->getClassNameForTable($table->getName());
@ -212,36 +212,36 @@ class DatabaseDriver implements MappingDriver
$localColumn = current($myFk->getColumns()); $localColumn = current($myFk->getColumns());
$associationMapping = array(); $associationMapping = [];
$associationMapping['fieldName'] = $this->getFieldNameForColumn($manyTable->getName(), current($otherFk->getColumns()), true); $associationMapping['fieldName'] = $this->getFieldNameForColumn($manyTable->getName(), current($otherFk->getColumns()), true);
$associationMapping['targetEntity'] = $this->getClassNameForTable($otherFk->getForeignTableName()); $associationMapping['targetEntity'] = $this->getClassNameForTable($otherFk->getForeignTableName());
if (current($manyTable->getColumns())->getName() == $localColumn) { if (current($manyTable->getColumns())->getName() == $localColumn) {
$associationMapping['inversedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true); $associationMapping['inversedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true);
$associationMapping['joinTable'] = array( $associationMapping['joinTable'] = [
'name' => strtolower($manyTable->getName()), 'name' => strtolower($manyTable->getName()),
'joinColumns' => array(), 'joinColumns' => [],
'inverseJoinColumns' => array(), 'inverseJoinColumns' => [],
); ];
$fkCols = $myFk->getForeignColumns(); $fkCols = $myFk->getForeignColumns();
$cols = $myFk->getColumns(); $cols = $myFk->getColumns();
for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) { for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) {
$associationMapping['joinTable']['joinColumns'][] = array( $associationMapping['joinTable']['joinColumns'][] = [
'name' => $cols[$i], 'name' => $cols[$i],
'referencedColumnName' => $fkCols[$i], 'referencedColumnName' => $fkCols[$i],
); ];
} }
$fkCols = $otherFk->getForeignColumns(); $fkCols = $otherFk->getForeignColumns();
$cols = $otherFk->getColumns(); $cols = $otherFk->getColumns();
for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) { for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) {
$associationMapping['joinTable']['inverseJoinColumns'][] = array( $associationMapping['joinTable']['inverseJoinColumns'][] = [
'name' => $cols[$i], 'name' => $cols[$i],
'referencedColumnName' => $fkCols[$i], 'referencedColumnName' => $fkCols[$i],
); ];
} }
} else { } else {
$associationMapping['mappedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true); $associationMapping['mappedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true);
@ -265,20 +265,20 @@ class DatabaseDriver implements MappingDriver
return; return;
} }
$tables = array(); $tables = [];
foreach ($this->_sm->listTableNames() as $tableName) { foreach ($this->_sm->listTableNames() as $tableName) {
$tables[$tableName] = $this->_sm->listTableDetails($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) { foreach ($tables as $tableName => $table) {
$foreignKeys = ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) $foreignKeys = ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints())
? $table->getForeignKeys() ? $table->getForeignKeys()
: array(); : [];
$allForeignKeyColumns = array(); $allForeignKeyColumns = [];
foreach ($foreignKeys as $foreignKey) { foreach ($foreignKeys as $foreignKey) {
$allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns()); $allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns());
@ -345,14 +345,14 @@ class DatabaseDriver implements MappingDriver
$columns = $this->tables[$tableName]->getColumns(); $columns = $this->tables[$tableName]->getColumns();
$primaryKeys = $this->getTablePrimaryKeys($this->tables[$tableName]); $primaryKeys = $this->getTablePrimaryKeys($this->tables[$tableName]);
$foreignKeys = $this->getTableForeignKeys($this->tables[$tableName]); $foreignKeys = $this->getTableForeignKeys($this->tables[$tableName]);
$allForeignKeys = array(); $allForeignKeys = [];
foreach ($foreignKeys as $foreignKey) { foreach ($foreignKeys as $foreignKey) {
$allForeignKeys = array_merge($allForeignKeys, $foreignKey->getLocalColumns()); $allForeignKeys = array_merge($allForeignKeys, $foreignKey->getLocalColumns());
} }
$ids = array(); $ids = [];
$fieldMappings = array(); $fieldMappings = [];
foreach ($columns as $column) { foreach ($columns as $column) {
if (in_array($column->getName(), $allForeignKeys)) { if (in_array($column->getName(), $allForeignKeys)) {
@ -389,12 +389,12 @@ class DatabaseDriver implements MappingDriver
*/ */
private function buildFieldMapping($tableName, Column $column) private function buildFieldMapping($tableName, Column $column)
{ {
$fieldMapping = array( $fieldMapping = [
'fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false), 'fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false),
'columnName' => $column->getName(), 'columnName' => $column->getName(),
'type' => $column->getType()->getName(), 'type' => $column->getType()->getName(),
'nullable' => ( ! $column->getNotNull()), 'nullable' => ( ! $column->getNotNull()),
); ];
// Type specific elements // Type specific elements
switch ($fieldMapping['type']) { switch ($fieldMapping['type']) {
@ -452,10 +452,10 @@ class DatabaseDriver implements MappingDriver
$fkColumns = $foreignKey->getColumns(); $fkColumns = $foreignKey->getColumns();
$fkForeignColumns = $foreignKey->getForeignColumns(); $fkForeignColumns = $foreignKey->getForeignColumns();
$localColumn = current($fkColumns); $localColumn = current($fkColumns);
$associationMapping = array( $associationMapping = [
'fieldName' => $this->getFieldNameForColumn($tableName, $localColumn, true), 'fieldName' => $this->getFieldNameForColumn($tableName, $localColumn, true),
'targetEntity' => $this->getClassNameForTable($foreignTableName), 'targetEntity' => $this->getClassNameForTable($foreignTableName),
); ];
if (isset($metadata->fieldMappings[$associationMapping['fieldName']])) { if (isset($metadata->fieldMappings[$associationMapping['fieldName']])) {
$associationMapping['fieldName'] .= '2'; // "foo" => "foo2" $associationMapping['fieldName'] .= '2'; // "foo" => "foo2"
@ -466,10 +466,10 @@ class DatabaseDriver implements MappingDriver
} }
for ($i = 0, $fkColumnsCount = count($fkColumns); $i < $fkColumnsCount; $i++) { for ($i = 0, $fkColumnsCount = count($fkColumns); $i < $fkColumnsCount; $i++) {
$associationMapping['joinColumns'][] = array( $associationMapping['joinColumns'][] = [
'name' => $fkColumns[$i], 'name' => $fkColumns[$i],
'referencedColumnName' => $fkForeignColumns[$i], 'referencedColumnName' => $fkForeignColumns[$i],
); ];
} }
// Here we need to check if $fkColumns are the same as $primaryKeys // 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()) return ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints())
? $table->getForeignKeys() ? $table->getForeignKeys()
: array(); : [];
} }
/** /**
@ -510,7 +510,7 @@ class DatabaseDriver implements MappingDriver
// Do nothing // Do nothing
} }
return array(); return [];
} }
/** /**

View File

@ -76,7 +76,7 @@ class XmlDriver extends FileDriver
} }
// Evaluate <entity...> attributes // Evaluate <entity...> attributes
$primaryTable = array(); $primaryTable = [];
if (isset($xmlRoot['table'])) { if (isset($xmlRoot['table'])) {
$primaryTable['name'] = (string) $xmlRoot['table']; $primaryTable['name'] = (string) $xmlRoot['table'];
@ -96,44 +96,48 @@ class XmlDriver extends FileDriver
// Evaluate named queries // Evaluate named queries
if (isset($xmlRoot->{'named-queries'})) { if (isset($xmlRoot->{'named-queries'})) {
foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) { foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) {
$metadata->addNamedQuery(array( $metadata->addNamedQuery(
[
'name' => (string) $namedQueryElement['name'], 'name' => (string) $namedQueryElement['name'],
'query' => (string) $namedQueryElement['query'] 'query' => (string) $namedQueryElement['query']
)); ]
);
} }
} }
// Evaluate native named queries // Evaluate native named queries
if (isset($xmlRoot->{'named-native-queries'})) { if (isset($xmlRoot->{'named-native-queries'})) {
foreach ($xmlRoot->{'named-native-queries'}->{'named-native-query'} as $nativeQueryElement) { foreach ($xmlRoot->{'named-native-queries'}->{'named-native-query'} as $nativeQueryElement) {
$metadata->addNamedNativeQuery(array( $metadata->addNamedNativeQuery(
[
'name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null, 'name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null,
'query' => isset($nativeQueryElement->query) ? (string) $nativeQueryElement->query : null, 'query' => isset($nativeQueryElement->query) ? (string) $nativeQueryElement->query : null,
'resultClass' => isset($nativeQueryElement['result-class']) ? (string) $nativeQueryElement['result-class'] : null, 'resultClass' => isset($nativeQueryElement['result-class']) ? (string) $nativeQueryElement['result-class'] : null,
'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string) $nativeQueryElement['result-set-mapping'] : null, 'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string) $nativeQueryElement['result-set-mapping'] : null,
)); ]
);
} }
} }
// Evaluate sql result set mapping // Evaluate sql result set mapping
if (isset($xmlRoot->{'sql-result-set-mappings'})) { if (isset($xmlRoot->{'sql-result-set-mappings'})) {
foreach ($xmlRoot->{'sql-result-set-mappings'}->{'sql-result-set-mapping'} as $rsmElement) { foreach ($xmlRoot->{'sql-result-set-mappings'}->{'sql-result-set-mapping'} as $rsmElement) {
$entities = array(); $entities = [];
$columns = array(); $columns = [];
foreach ($rsmElement as $entityElement) { foreach ($rsmElement as $entityElement) {
//<entity-result/> //<entity-result/>
if (isset($entityElement['entity-class'])) { if (isset($entityElement['entity-class'])) {
$entityResult = array( $entityResult = [
'fields' => array(), 'fields' => [],
'entityClass' => (string) $entityElement['entity-class'], 'entityClass' => (string) $entityElement['entity-class'],
'discriminatorColumn' => isset($entityElement['discriminator-column']) ? (string) $entityElement['discriminator-column'] : null, 'discriminatorColumn' => isset($entityElement['discriminator-column']) ? (string) $entityElement['discriminator-column'] : null,
); ];
foreach ($entityElement as $fieldElement) { foreach ($entityElement as $fieldElement) {
$entityResult['fields'][] = array( $entityResult['fields'][] = [
'name' => isset($fieldElement['name']) ? (string) $fieldElement['name'] : null, 'name' => isset($fieldElement['name']) ? (string) $fieldElement['name'] : null,
'column' => isset($fieldElement['column']) ? (string) $fieldElement['column'] : null, 'column' => isset($fieldElement['column']) ? (string) $fieldElement['column'] : null,
); ];
} }
$entities[] = $entityResult; $entities[] = $entityResult;
@ -141,17 +145,19 @@ class XmlDriver extends FileDriver
//<column-result/> //<column-result/>
if (isset($entityElement['name'])) { if (isset($entityElement['name'])) {
$columns[] = array( $columns[] = [
'name' => (string) $entityElement['name'], 'name' => (string) $entityElement['name'],
); ];
} }
} }
$metadata->addSqlResultSetMapping(array( $metadata->addSqlResultSetMapping(
[
'name' => (string) $rsmElement['name'], 'name' => (string) $rsmElement['name'],
'entities' => $entities, 'entities' => $entities,
'columns' => $columns 'columns' => $columns
)); ]
);
} }
} }
@ -163,19 +169,21 @@ class XmlDriver extends FileDriver
// Evaluate <discriminator-column...> // Evaluate <discriminator-column...>
if (isset($xmlRoot->{'discriminator-column'})) { if (isset($xmlRoot->{'discriminator-column'})) {
$discrColumn = $xmlRoot->{'discriminator-column'}; $discrColumn = $xmlRoot->{'discriminator-column'};
$metadata->setDiscriminatorColumn(array( $metadata->setDiscriminatorColumn(
[
'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null,
'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string', 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string',
'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255, 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255,
'columnDefinition' => isset($discrColumn['column-definition']) ? (string) $discrColumn['column-definition'] : null 'columnDefinition' => isset($discrColumn['column-definition']) ? (string) $discrColumn['column-definition'] : null
)); ]
);
} else { } else {
$metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]);
} }
// Evaluate <discriminator-map...> // Evaluate <discriminator-map...>
if (isset($xmlRoot->{'discriminator-map'})) { if (isset($xmlRoot->{'discriminator-map'})) {
$map = array(); $map = [];
foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} as $discrMapElement) { foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} as $discrMapElement) {
$map[(string) $discrMapElement['value']] = (string) $discrMapElement['class']; $map[(string) $discrMapElement['value']] = (string) $discrMapElement['class'];
} }
@ -193,9 +201,9 @@ class XmlDriver extends FileDriver
// Evaluate <indexes...> // Evaluate <indexes...>
if (isset($xmlRoot->indexes)) { if (isset($xmlRoot->indexes)) {
$metadata->table['indexes'] = array(); $metadata->table['indexes'] = [];
foreach ($xmlRoot->indexes->index as $indexXml) { foreach ($xmlRoot->indexes->index as $indexXml) {
$index = array('columns' => explode(',', (string) $indexXml['columns'])); $index = ['columns' => explode(',', (string) $indexXml['columns'])];
if (isset($indexXml['flags'])) { if (isset($indexXml['flags'])) {
$index['flags'] = explode(',', (string) $indexXml['flags']); $index['flags'] = explode(',', (string) $indexXml['flags']);
@ -215,10 +223,9 @@ class XmlDriver extends FileDriver
// Evaluate <unique-constraints..> // Evaluate <unique-constraints..>
if (isset($xmlRoot->{'unique-constraints'})) { if (isset($xmlRoot->{'unique-constraints'})) {
$metadata->table['uniqueConstraints'] = array(); $metadata->table['uniqueConstraints'] = [];
foreach ($xmlRoot->{'unique-constraints'}->{'unique-constraint'} as $uniqueXml) { 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)) { if (isset($uniqueXml->options)) {
$unique['options'] = $this->_parseOptions($uniqueXml->options->children()); $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 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 // The internal SimpleXmlIterator get resetted, to this generate a duplicate field exception
$mappings = array(); $mappings = [];
// Evaluate <field ...> mappings // Evaluate <field ...> mappings
if (isset($xmlRoot->field)) { if (isset($xmlRoot->field)) {
foreach ($xmlRoot->field as $fieldMapping) { foreach ($xmlRoot->field as $fieldMapping) {
@ -263,11 +270,11 @@ class XmlDriver extends FileDriver
? $this->evaluateBoolean($embeddedMapping['use-column-prefix']) ? $this->evaluateBoolean($embeddedMapping['use-column-prefix'])
: true; : true;
$mapping = array( $mapping = [
'fieldName' => (string) $embeddedMapping['name'], 'fieldName' => (string) $embeddedMapping['name'],
'class' => (string) $embeddedMapping['class'], 'class' => (string) $embeddedMapping['class'],
'columnPrefix' => $useColumnPrefix ? $columnPrefix : false 'columnPrefix' => $useColumnPrefix ? $columnPrefix : false
); ];
$metadata->mapEmbedded($mapping); $metadata->mapEmbedded($mapping);
} }
@ -282,17 +289,17 @@ class XmlDriver extends FileDriver
} }
// Evaluate <id ...> mappings // Evaluate <id ...> mappings
$associationIds = array(); $associationIds = [];
foreach ($xmlRoot->id as $idElement) { foreach ($xmlRoot->id as $idElement) {
if (isset($idElement['association-key']) && $this->evaluateBoolean($idElement['association-key'])) { if (isset($idElement['association-key']) && $this->evaluateBoolean($idElement['association-key'])) {
$associationIds[(string) $idElement['name']] = true; $associationIds[(string) $idElement['name']] = true;
continue; continue;
} }
$mapping = array( $mapping = [
'id' => true, 'id' => true,
'fieldName' => (string) $idElement['name'] 'fieldName' => (string) $idElement['name']
); ];
if (isset($idElement['type'])) { if (isset($idElement['type'])) {
$mapping['type'] = (string) $idElement['type']; $mapping['type'] = (string) $idElement['type'];
@ -326,16 +333,20 @@ class XmlDriver extends FileDriver
// Check for SequenceGenerator/TableGenerator definition // Check for SequenceGenerator/TableGenerator definition
if (isset($idElement->{'sequence-generator'})) { if (isset($idElement->{'sequence-generator'})) {
$seqGenerator = $idElement->{'sequence-generator'}; $seqGenerator = $idElement->{'sequence-generator'};
$metadata->setSequenceGeneratorDefinition(array( $metadata->setSequenceGeneratorDefinition(
[
'sequenceName' => (string) $seqGenerator['sequence-name'], 'sequenceName' => (string) $seqGenerator['sequence-name'],
'allocationSize' => (string) $seqGenerator['allocation-size'], 'allocationSize' => (string) $seqGenerator['allocation-size'],
'initialValue' => (string) $seqGenerator['initial-value'] 'initialValue' => (string) $seqGenerator['initial-value']
)); ]
);
} else if (isset($idElement->{'custom-id-generator'})) { } else if (isset($idElement->{'custom-id-generator'})) {
$customGenerator = $idElement->{'custom-id-generator'}; $customGenerator = $idElement->{'custom-id-generator'};
$metadata->setCustomGeneratorDefinition(array( $metadata->setCustomGeneratorDefinition(
[
'class' => (string) $customGenerator['class'] 'class' => (string) $customGenerator['class']
)); ]
);
} else if (isset($idElement->{'table-generator'})) { } else if (isset($idElement->{'table-generator'})) {
throw MappingException::tableIdGeneratorNotImplemented($className); throw MappingException::tableIdGeneratorNotImplemented($className);
} }
@ -344,10 +355,10 @@ class XmlDriver extends FileDriver
// Evaluate <one-to-one ...> mappings // Evaluate <one-to-one ...> mappings
if (isset($xmlRoot->{'one-to-one'})) { if (isset($xmlRoot->{'one-to-one'})) {
foreach ($xmlRoot->{'one-to-one'} as $oneToOneElement) { foreach ($xmlRoot->{'one-to-one'} as $oneToOneElement) {
$mapping = array( $mapping = [
'fieldName' => (string) $oneToOneElement['field'], 'fieldName' => (string) $oneToOneElement['field'],
'targetEntity' => (string) $oneToOneElement['target-entity'] 'targetEntity' => (string) $oneToOneElement['target-entity']
); ];
if (isset($associationIds[$mapping['fieldName']])) { if (isset($associationIds[$mapping['fieldName']])) {
$mapping['id'] = true; $mapping['id'] = true;
@ -363,7 +374,7 @@ class XmlDriver extends FileDriver
if (isset($oneToOneElement['inversed-by'])) { if (isset($oneToOneElement['inversed-by'])) {
$mapping['inversedBy'] = (string) $oneToOneElement['inversed-by']; $mapping['inversedBy'] = (string) $oneToOneElement['inversed-by'];
} }
$joinColumns = array(); $joinColumns = [];
if (isset($oneToOneElement->{'join-column'})) { if (isset($oneToOneElement->{'join-column'})) {
$joinColumns[] = $this->joinColumnToArray($oneToOneElement->{'join-column'}); $joinColumns[] = $this->joinColumnToArray($oneToOneElement->{'join-column'});
@ -396,11 +407,11 @@ class XmlDriver extends FileDriver
// Evaluate <one-to-many ...> mappings // Evaluate <one-to-many ...> mappings
if (isset($xmlRoot->{'one-to-many'})) { if (isset($xmlRoot->{'one-to-many'})) {
foreach ($xmlRoot->{'one-to-many'} as $oneToManyElement) { foreach ($xmlRoot->{'one-to-many'} as $oneToManyElement) {
$mapping = array( $mapping = [
'fieldName' => (string) $oneToManyElement['field'], 'fieldName' => (string) $oneToManyElement['field'],
'targetEntity' => (string) $oneToManyElement['target-entity'], 'targetEntity' => (string) $oneToManyElement['target-entity'],
'mappedBy' => (string) $oneToManyElement['mapped-by'] 'mappedBy' => (string) $oneToManyElement['mapped-by']
); ];
if (isset($oneToManyElement['fetch'])) { if (isset($oneToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string) $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'})) { if (isset($oneToManyElement->{'order-by'})) {
$orderBy = array(); $orderBy = [];
foreach ($oneToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) { foreach ($oneToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) {
$orderBy[(string) $orderByField['name']] = (string) $orderByField['direction']; $orderBy[(string) $orderByField['name']] = (string) $orderByField['direction'];
} }
@ -440,10 +451,10 @@ class XmlDriver extends FileDriver
// Evaluate <many-to-one ...> mappings // Evaluate <many-to-one ...> mappings
if (isset($xmlRoot->{'many-to-one'})) { if (isset($xmlRoot->{'many-to-one'})) {
foreach ($xmlRoot->{'many-to-one'} as $manyToOneElement) { foreach ($xmlRoot->{'many-to-one'} as $manyToOneElement) {
$mapping = array( $mapping = [
'fieldName' => (string) $manyToOneElement['field'], 'fieldName' => (string) $manyToOneElement['field'],
'targetEntity' => (string) $manyToOneElement['target-entity'] 'targetEntity' => (string) $manyToOneElement['target-entity']
); ];
if (isset($associationIds[$mapping['fieldName']])) { if (isset($associationIds[$mapping['fieldName']])) {
$mapping['id'] = true; $mapping['id'] = true;
@ -457,7 +468,7 @@ class XmlDriver extends FileDriver
$mapping['inversedBy'] = (string) $manyToOneElement['inversed-by']; $mapping['inversedBy'] = (string) $manyToOneElement['inversed-by'];
} }
$joinColumns = array(); $joinColumns = [];
if (isset($manyToOneElement->{'join-column'})) { if (isset($manyToOneElement->{'join-column'})) {
$joinColumns[] = $this->joinColumnToArray($manyToOneElement->{'join-column'}); $joinColumns[] = $this->joinColumnToArray($manyToOneElement->{'join-column'});
@ -486,10 +497,10 @@ class XmlDriver extends FileDriver
// Evaluate <many-to-many ...> mappings // Evaluate <many-to-many ...> mappings
if (isset($xmlRoot->{'many-to-many'})) { if (isset($xmlRoot->{'many-to-many'})) {
foreach ($xmlRoot->{'many-to-many'} as $manyToManyElement) { foreach ($xmlRoot->{'many-to-many'} as $manyToManyElement) {
$mapping = array( $mapping = [
'fieldName' => (string) $manyToManyElement['field'], 'fieldName' => (string) $manyToManyElement['field'],
'targetEntity' => (string) $manyToManyElement['target-entity'] 'targetEntity' => (string) $manyToManyElement['target-entity']
); ];
if (isset($manyToManyElement['fetch'])) { if (isset($manyToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string) $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'}; $joinTableElement = $manyToManyElement->{'join-table'};
$joinTable = array( $joinTable = [
'name' => (string) $joinTableElement['name'] 'name' => (string) $joinTableElement['name']
); ];
if (isset($joinTableElement['schema'])) { if (isset($joinTableElement['schema'])) {
$joinTable['schema'] = (string) $joinTableElement['schema']; $joinTable['schema'] = (string) $joinTableElement['schema'];
@ -531,7 +542,7 @@ class XmlDriver extends FileDriver
} }
if (isset($manyToManyElement->{'order-by'})) { if (isset($manyToManyElement->{'order-by'})) {
$orderBy = array(); $orderBy = [];
foreach ($manyToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) { foreach ($manyToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) {
$orderBy[(string) $orderByField['name']] = (string) $orderByField['direction']; $orderBy[(string) $orderByField['name']] = (string) $orderByField['direction'];
} }
@ -569,11 +580,11 @@ class XmlDriver extends FileDriver
if (isset($xmlRoot->{'association-overrides'})) { if (isset($xmlRoot->{'association-overrides'})) {
foreach ($xmlRoot->{'association-overrides'}->{'association-override'} as $overrideElement) { foreach ($xmlRoot->{'association-overrides'}->{'association-override'} as $overrideElement) {
$fieldName = (string) $overrideElement['name']; $fieldName = (string) $overrideElement['name'];
$override = array(); $override = [];
// Check for join-columns // Check for join-columns
if (isset($overrideElement->{'join-columns'})) { if (isset($overrideElement->{'join-columns'})) {
$joinColumns = array(); $joinColumns = [];
foreach ($overrideElement->{'join-columns'}->{'join-column'} as $joinColumnElement) { foreach ($overrideElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
$joinColumns[] = $this->joinColumnToArray($joinColumnElement); $joinColumns[] = $this->joinColumnToArray($joinColumnElement);
} }
@ -585,10 +596,10 @@ class XmlDriver extends FileDriver
$joinTable = null; $joinTable = null;
$joinTableElement = $overrideElement->{'join-table'}; $joinTableElement = $overrideElement->{'join-table'};
$joinTable = array( $joinTable = [
'name' => (string) $joinTableElement['name'], 'name' => (string) $joinTableElement['name'],
'schema' => (string) $joinTableElement['schema'] 'schema' => (string) $joinTableElement['schema']
); ];
if (isset($joinTableElement->{'join-columns'})) { if (isset($joinTableElement->{'join-columns'})) {
foreach ($joinTableElement->{'join-columns'}->{'join-column'} as $joinColumnElement) { foreach ($joinTableElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
@ -651,7 +662,7 @@ class XmlDriver extends FileDriver
*/ */
private function _parseOptions(SimpleXMLElement $options) private function _parseOptions(SimpleXMLElement $options)
{ {
$array = array(); $array = [];
/* @var $option SimpleXMLElement */ /* @var $option SimpleXMLElement */
foreach ($options as $option) { foreach ($options as $option) {
@ -686,10 +697,10 @@ class XmlDriver extends FileDriver
*/ */
private function joinColumnToArray(SimpleXMLElement $joinColumnElement) private function joinColumnToArray(SimpleXMLElement $joinColumnElement)
{ {
$joinColumn = array( $joinColumn = [
'name' => (string) $joinColumnElement['name'], 'name' => (string) $joinColumnElement['name'],
'referencedColumnName' => (string) $joinColumnElement['referenced-column-name'] 'referencedColumnName' => (string) $joinColumnElement['referenced-column-name']
); ];
if (isset($joinColumnElement['unique'])) { if (isset($joinColumnElement['unique'])) {
$joinColumn['unique'] = $this->evaluateBoolean($joinColumnElement['unique']); $joinColumn['unique'] = $this->evaluateBoolean($joinColumnElement['unique']);
@ -719,9 +730,9 @@ class XmlDriver extends FileDriver
*/ */
private function columnToArray(SimpleXMLElement $fieldMapping) private function columnToArray(SimpleXMLElement $fieldMapping)
{ {
$mapping = array( $mapping = [
'fieldName' => (string) $fieldMapping['name'], 'fieldName' => (string) $fieldMapping['name'],
); ];
if (isset($fieldMapping['type'])) { if (isset($fieldMapping['type'])) {
$mapping['type'] = (string) $fieldMapping['type']; $mapping['type'] = (string) $fieldMapping['type'];
@ -786,10 +797,10 @@ class XmlDriver extends FileDriver
$usage = constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $usage); $usage = constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $usage);
} }
return array( return [
'usage' => $usage, 'usage' => $usage,
'region' => $region, 'region' => $region,
); ];
} }
/** /**
@ -801,7 +812,7 @@ class XmlDriver extends FileDriver
*/ */
private function _getCascadeMappings(SimpleXMLElement $cascadeElement) private function _getCascadeMappings(SimpleXMLElement $cascadeElement)
{ {
$cascades = array(); $cascades = [];
/* @var $action SimpleXmlElement */ /* @var $action SimpleXmlElement */
foreach ($cascadeElement->children() as $action) { foreach ($cascadeElement->children() as $action) {
// According to the JPA specifications, XML uses "cascade-persist" // According to the JPA specifications, XML uses "cascade-persist"
@ -820,7 +831,7 @@ class XmlDriver extends FileDriver
*/ */
protected function loadMappingFile($file) protected function loadMappingFile($file)
{ {
$result = array(); $result = [];
$xmlElement = simplexml_load_file($file); $xmlElement = simplexml_load_file($file);
if (isset($xmlElement->entity)) { if (isset($xmlElement->entity)) {

View File

@ -73,7 +73,7 @@ class YamlDriver extends FileDriver
} }
// Evaluate root level properties // Evaluate root level properties
$primaryTable = array(); $primaryTable = [];
if (isset($element['table'])) { if (isset($element['table'])) {
$primaryTable['name'] = $element['table']; $primaryTable['name'] = $element['table'];
@ -94,7 +94,7 @@ class YamlDriver extends FileDriver
if (isset($element['namedQueries'])) { if (isset($element['namedQueries'])) {
foreach ($element['namedQueries'] as $name => $queryMapping) { foreach ($element['namedQueries'] as $name => $queryMapping) {
if (is_string($queryMapping)) { if (is_string($queryMapping)) {
$queryMapping = array('query' => $queryMapping); $queryMapping = ['query' => $queryMapping];
} }
if ( ! isset($queryMapping['name'])) { if ( ! isset($queryMapping['name'])) {
@ -111,12 +111,14 @@ class YamlDriver extends FileDriver
if (!isset($mappingElement['name'])) { if (!isset($mappingElement['name'])) {
$mappingElement['name'] = $name; $mappingElement['name'] = $name;
} }
$metadata->addNamedNativeQuery(array( $metadata->addNamedNativeQuery(
[
'name' => $mappingElement['name'], 'name' => $mappingElement['name'],
'query' => isset($mappingElement['query']) ? $mappingElement['query'] : null, 'query' => isset($mappingElement['query']) ? $mappingElement['query'] : null,
'resultClass' => isset($mappingElement['resultClass']) ? $mappingElement['resultClass'] : null, 'resultClass' => isset($mappingElement['resultClass']) ? $mappingElement['resultClass'] : null,
'resultSetMapping' => isset($mappingElement['resultSetMapping']) ? $mappingElement['resultSetMapping'] : null, 'resultSetMapping' => isset($mappingElement['resultSetMapping']) ? $mappingElement['resultSetMapping'] : null,
)); ]
);
} }
} }
@ -127,22 +129,22 @@ class YamlDriver extends FileDriver
$resultSetMapping['name'] = $name; $resultSetMapping['name'] = $name;
} }
$entities = array(); $entities = [];
$columns = array(); $columns = [];
if (isset($resultSetMapping['entityResult'])) { if (isset($resultSetMapping['entityResult'])) {
foreach ($resultSetMapping['entityResult'] as $entityResultElement) { foreach ($resultSetMapping['entityResult'] as $entityResultElement) {
$entityResult = array( $entityResult = [
'fields' => array(), 'fields' => [],
'entityClass' => isset($entityResultElement['entityClass']) ? $entityResultElement['entityClass'] : null, 'entityClass' => isset($entityResultElement['entityClass']) ? $entityResultElement['entityClass'] : null,
'discriminatorColumn' => isset($entityResultElement['discriminatorColumn']) ? $entityResultElement['discriminatorColumn'] : null, 'discriminatorColumn' => isset($entityResultElement['discriminatorColumn']) ? $entityResultElement['discriminatorColumn'] : null,
); ];
if (isset($entityResultElement['fieldResult'])) { if (isset($entityResultElement['fieldResult'])) {
foreach ($entityResultElement['fieldResult'] as $fieldResultElement) { foreach ($entityResultElement['fieldResult'] as $fieldResultElement) {
$entityResult['fields'][] = array( $entityResult['fields'][] = [
'name' => isset($fieldResultElement['name']) ? $fieldResultElement['name'] : null, 'name' => isset($fieldResultElement['name']) ? $fieldResultElement['name'] : null,
'column' => isset($fieldResultElement['column']) ? $fieldResultElement['column'] : null, 'column' => isset($fieldResultElement['column']) ? $fieldResultElement['column'] : null,
); ];
} }
} }
@ -153,17 +155,19 @@ class YamlDriver extends FileDriver
if (isset($resultSetMapping['columnResult'])) { if (isset($resultSetMapping['columnResult'])) {
foreach ($resultSetMapping['columnResult'] as $columnResultAnnot) { foreach ($resultSetMapping['columnResult'] as $columnResultAnnot) {
$columns[] = array( $columns[] = [
'name' => isset($columnResultAnnot['name']) ? $columnResultAnnot['name'] : null, 'name' => isset($columnResultAnnot['name']) ? $columnResultAnnot['name'] : null,
); ];
} }
} }
$metadata->addSqlResultSetMapping(array( $metadata->addSqlResultSetMapping(
[
'name' => $resultSetMapping['name'], 'name' => $resultSetMapping['name'],
'entities' => $entities, 'entities' => $entities,
'columns' => $columns 'columns' => $columns
)); ]
);
} }
} }
@ -174,14 +178,16 @@ class YamlDriver extends FileDriver
// Evaluate discriminatorColumn // Evaluate discriminatorColumn
if (isset($element['discriminatorColumn'])) { if (isset($element['discriminatorColumn'])) {
$discrColumn = $element['discriminatorColumn']; $discrColumn = $element['discriminatorColumn'];
$metadata->setDiscriminatorColumn(array( $metadata->setDiscriminatorColumn(
[
'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null,
'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string', 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string',
'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255, 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255,
'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string) $discrColumn['columnDefinition'] : null 'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string) $discrColumn['columnDefinition'] : null
)); ]
);
} else { } else {
$metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]);
} }
// Evaluate discriminatorMap // Evaluate discriminatorMap
@ -206,9 +212,9 @@ class YamlDriver extends FileDriver
} }
if (is_string($indexYml['columns'])) { if (is_string($indexYml['columns'])) {
$index = array('columns' => array_map('trim', explode(',', $indexYml['columns']))); $index = ['columns' => array_map('trim', explode(',', $indexYml['columns']))];
} else { } else {
$index = array('columns' => $indexYml['columns']); $index = ['columns' => $indexYml['columns']];
} }
if (isset($indexYml['flags'])) { if (isset($indexYml['flags'])) {
@ -235,9 +241,9 @@ class YamlDriver extends FileDriver
} }
if (is_string($uniqueYml['columns'])) { if (is_string($uniqueYml['columns'])) {
$unique = array('columns' => array_map('trim', explode(',', $uniqueYml['columns']))); $unique = ['columns' => array_map('trim', explode(',', $uniqueYml['columns']))];
} else { } else {
$unique = array('columns' => $uniqueYml['columns']); $unique = ['columns' => $uniqueYml['columns']];
} }
if (isset($uniqueYml['options'])) { if (isset($uniqueYml['options'])) {
@ -252,7 +258,7 @@ class YamlDriver extends FileDriver
$metadata->table['options'] = $element['options']; $metadata->table['options'] = $element['options'];
} }
$associationIds = array(); $associationIds = [];
if (isset($element['id'])) { if (isset($element['id'])) {
// Evaluate identifier settings // Evaluate identifier settings
foreach ($element['id'] as $name => $idElement) { foreach ($element['id'] as $name => $idElement) {
@ -261,10 +267,10 @@ class YamlDriver extends FileDriver
continue; continue;
} }
$mapping = array( $mapping = [
'id' => true, 'id' => true,
'fieldName' => $name 'fieldName' => $name
); ];
if (isset($idElement['type'])) { if (isset($idElement['type'])) {
$mapping['type'] = $idElement['type']; $mapping['type'] = $idElement['type'];
@ -297,9 +303,11 @@ class YamlDriver extends FileDriver
$metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']); $metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']);
} else if (isset($idElement['customIdGenerator'])) { } else if (isset($idElement['customIdGenerator'])) {
$customGenerator = $idElement['customIdGenerator']; $customGenerator = $idElement['customIdGenerator'];
$metadata->setCustomGeneratorDefinition(array( $metadata->setCustomGeneratorDefinition(
[
'class' => (string) $customGenerator['class'] 'class' => (string) $customGenerator['class']
)); ]
);
} else if (isset($idElement['tableGenerator'])) { } else if (isset($idElement['tableGenerator'])) {
throw MappingException::tableIdGeneratorNotImplemented($className); throw MappingException::tableIdGeneratorNotImplemented($className);
} }
@ -331,11 +339,11 @@ class YamlDriver extends FileDriver
if (isset($element['embedded'])) { if (isset($element['embedded'])) {
foreach ($element['embedded'] as $name => $embeddedMapping) { foreach ($element['embedded'] as $name => $embeddedMapping) {
$mapping = array( $mapping = [
'fieldName' => $name, 'fieldName' => $name,
'class' => $embeddedMapping['class'], 'class' => $embeddedMapping['class'],
'columnPrefix' => isset($embeddedMapping['columnPrefix']) ? $embeddedMapping['columnPrefix'] : null, 'columnPrefix' => isset($embeddedMapping['columnPrefix']) ? $embeddedMapping['columnPrefix'] : null,
); ];
$metadata->mapEmbedded($mapping); $metadata->mapEmbedded($mapping);
} }
} }
@ -343,10 +351,10 @@ class YamlDriver extends FileDriver
// Evaluate oneToOne relationships // Evaluate oneToOne relationships
if (isset($element['oneToOne'])) { if (isset($element['oneToOne'])) {
foreach ($element['oneToOne'] as $name => $oneToOneElement) { foreach ($element['oneToOne'] as $name => $oneToOneElement) {
$mapping = array( $mapping = [
'fieldName' => $name, 'fieldName' => $name,
'targetEntity' => $oneToOneElement['targetEntity'] 'targetEntity' => $oneToOneElement['targetEntity']
); ];
if (isset($associationIds[$mapping['fieldName']])) { if (isset($associationIds[$mapping['fieldName']])) {
$mapping['id'] = true; $mapping['id'] = true;
@ -363,7 +371,7 @@ class YamlDriver extends FileDriver
$mapping['inversedBy'] = $oneToOneElement['inversedBy']; $mapping['inversedBy'] = $oneToOneElement['inversedBy'];
} }
$joinColumns = array(); $joinColumns = [];
if (isset($oneToOneElement['joinColumn'])) { if (isset($oneToOneElement['joinColumn'])) {
$joinColumns[] = $this->joinColumnToArray($oneToOneElement['joinColumn']); $joinColumns[] = $this->joinColumnToArray($oneToOneElement['joinColumn']);
@ -400,11 +408,11 @@ class YamlDriver extends FileDriver
// Evaluate oneToMany relationships // Evaluate oneToMany relationships
if (isset($element['oneToMany'])) { if (isset($element['oneToMany'])) {
foreach ($element['oneToMany'] as $name => $oneToManyElement) { foreach ($element['oneToMany'] as $name => $oneToManyElement) {
$mapping = array( $mapping = [
'fieldName' => $name, 'fieldName' => $name,
'targetEntity' => $oneToManyElement['targetEntity'], 'targetEntity' => $oneToManyElement['targetEntity'],
'mappedBy' => $oneToManyElement['mappedBy'] 'mappedBy' => $oneToManyElement['mappedBy']
); ];
if (isset($oneToManyElement['fetch'])) { if (isset($oneToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $oneToManyElement['fetch']); $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $oneToManyElement['fetch']);
@ -439,10 +447,10 @@ class YamlDriver extends FileDriver
// Evaluate manyToOne relationships // Evaluate manyToOne relationships
if (isset($element['manyToOne'])) { if (isset($element['manyToOne'])) {
foreach ($element['manyToOne'] as $name => $manyToOneElement) { foreach ($element['manyToOne'] as $name => $manyToOneElement) {
$mapping = array( $mapping = [
'fieldName' => $name, 'fieldName' => $name,
'targetEntity' => $manyToOneElement['targetEntity'] 'targetEntity' => $manyToOneElement['targetEntity']
); ];
if (isset($associationIds[$mapping['fieldName']])) { if (isset($associationIds[$mapping['fieldName']])) {
$mapping['id'] = true; $mapping['id'] = true;
@ -456,7 +464,7 @@ class YamlDriver extends FileDriver
$mapping['inversedBy'] = $manyToOneElement['inversedBy']; $mapping['inversedBy'] = $manyToOneElement['inversedBy'];
} }
$joinColumns = array(); $joinColumns = [];
if (isset($manyToOneElement['joinColumn'])) { if (isset($manyToOneElement['joinColumn'])) {
$joinColumns[] = $this->joinColumnToArray($manyToOneElement['joinColumn']); $joinColumns[] = $this->joinColumnToArray($manyToOneElement['joinColumn']);
@ -488,10 +496,10 @@ class YamlDriver extends FileDriver
// Evaluate manyToMany relationships // Evaluate manyToMany relationships
if (isset($element['manyToMany'])) { if (isset($element['manyToMany'])) {
foreach ($element['manyToMany'] as $name => $manyToManyElement) { foreach ($element['manyToMany'] as $name => $manyToManyElement) {
$mapping = array( $mapping = [
'fieldName' => $name, 'fieldName' => $name,
'targetEntity' => $manyToManyElement['targetEntity'] 'targetEntity' => $manyToManyElement['targetEntity']
); ];
if (isset($manyToManyElement['fetch'])) { if (isset($manyToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $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'])) { } else if (isset($manyToManyElement['joinTable'])) {
$joinTableElement = $manyToManyElement['joinTable']; $joinTableElement = $manyToManyElement['joinTable'];
$joinTable = array( $joinTable = [
'name' => $joinTableElement['name'] 'name' => $joinTableElement['name']
); ];
if (isset($joinTableElement['schema'])) { if (isset($joinTableElement['schema'])) {
$joinTable['schema'] = $joinTableElement['schema']; $joinTable['schema'] = $joinTableElement['schema'];
@ -564,11 +572,11 @@ class YamlDriver extends FileDriver
if (isset($element['associationOverride']) && is_array($element['associationOverride'])) { if (isset($element['associationOverride']) && is_array($element['associationOverride'])) {
foreach ($element['associationOverride'] as $fieldName => $associationOverrideElement) { foreach ($element['associationOverride'] as $fieldName => $associationOverrideElement) {
$override = array(); $override = [];
// Check for joinColumn // Check for joinColumn
if (isset($associationOverrideElement['joinColumn'])) { if (isset($associationOverrideElement['joinColumn'])) {
$joinColumns = array(); $joinColumns = [];
foreach ($associationOverrideElement['joinColumn'] as $name => $joinColumnElement) { foreach ($associationOverrideElement['joinColumn'] as $name => $joinColumnElement) {
if ( ! isset($joinColumnElement['name'])) { if ( ! isset($joinColumnElement['name'])) {
$joinColumnElement['name'] = $name; $joinColumnElement['name'] = $name;
@ -582,9 +590,9 @@ class YamlDriver extends FileDriver
if (isset($associationOverrideElement['joinTable'])) { if (isset($associationOverrideElement['joinTable'])) {
$joinTableElement = $associationOverrideElement['joinTable']; $joinTableElement = $associationOverrideElement['joinTable'];
$joinTable = array( $joinTable = [
'name' => $joinTableElement['name'] 'name' => $joinTableElement['name']
); ];
if (isset($joinTableElement['schema'])) { if (isset($joinTableElement['schema'])) {
$joinTable['schema'] = $joinTableElement['schema']; $joinTable['schema'] = $joinTableElement['schema'];
@ -665,7 +673,7 @@ class YamlDriver extends FileDriver
*/ */
private function joinColumnToArray($joinColumnElement) private function joinColumnToArray($joinColumnElement)
{ {
$joinColumn = array(); $joinColumn = [];
if (isset($joinColumnElement['referencedColumnName'])) { if (isset($joinColumnElement['referencedColumnName'])) {
$joinColumn['referencedColumnName'] = (string) $joinColumnElement['referencedColumnName']; $joinColumn['referencedColumnName'] = (string) $joinColumnElement['referencedColumnName'];
} }
@ -707,9 +715,9 @@ class YamlDriver extends FileDriver
*/ */
private function columnToArray($fieldName, $column) private function columnToArray($fieldName, $column)
{ {
$mapping = array( $mapping = [
'fieldName' => $fieldName 'fieldName' => $fieldName
); ];
if (isset($column['type'])) { if (isset($column['type'])) {
$params = explode('(', $column['type']); $params = explode('(', $column['type']);
@ -781,10 +789,10 @@ class YamlDriver extends FileDriver
$usage = constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $usage); $usage = constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $usage);
} }
return array( return [
'usage' => $usage, 'usage' => $usage,
'region' => $region, 'region' => $region,
); ];
} }
/** /**

View File

@ -37,5 +37,5 @@ final class EntityListeners implements Annotation
* *
* @var array<string> * @var array<string>
*/ */
public $value = array(); public $value = [];
} }

View File

@ -45,7 +45,7 @@ final class EntityResult implements Annotation
* *
* @var array<\Doctrine\ORM\Mapping\FieldResult> * @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. * Specifies the column name of the column in the SELECT list that is used to determine the type of the entity instance.

View File

@ -38,10 +38,10 @@ final class JoinTable implements Annotation
/** /**
* @var array<\Doctrine\ORM\Mapping\JoinColumn> * @var array<\Doctrine\ORM\Mapping\JoinColumn>
*/ */
public $joinColumns = array(); public $joinColumns = [];
/** /**
* @var array<\Doctrine\ORM\Mapping\JoinColumn> * @var array<\Doctrine\ORM\Mapping\JoinColumn>
*/ */
public $inverseJoinColumns = array(); public $inverseJoinColumns = [];
} }

View File

@ -36,5 +36,5 @@ final class NamedNativeQueries implements Annotation
* *
* @var array<\Doctrine\ORM\Mapping\NamedNativeQuery> * @var array<\Doctrine\ORM\Mapping\NamedNativeQuery>
*/ */
public $value = array(); public $value = [];
} }

View File

@ -43,12 +43,12 @@ final class SqlResultSetMapping implements Annotation
* *
* @var array<\Doctrine\ORM\Mapping\EntityResult> * @var array<\Doctrine\ORM\Mapping\EntityResult>
*/ */
public $entities = array(); public $entities = [];
/** /**
* Specifies the result set mapping to scalar values. * Specifies the result set mapping to scalar values.
* *
* @var array<\Doctrine\ORM\Mapping\ColumnResult> * @var array<\Doctrine\ORM\Mapping\ColumnResult>
*/ */
public $columns = array(); public $columns = [];
} }

View File

@ -36,5 +36,5 @@ final class SqlResultSetMappings implements Annotation
* *
* @var array<\Doctrine\ORM\Mapping\SqlResultSetMapping> * @var array<\Doctrine\ORM\Mapping\SqlResultSetMapping>
*/ */
public $value = array(); public $value = [];
} }

View File

@ -48,5 +48,5 @@ final class Table implements Annotation
/** /**
* @var array * @var array
*/ */
public $options = array(); public $options = [];
} }

View File

@ -63,8 +63,8 @@ final class NativeQuery extends AbstractQuery
*/ */
protected function _doExecute() protected function _doExecute()
{ {
$parameters = array(); $parameters = [];
$types = array(); $types = [];
foreach ($this->getParameters() as $parameter) { foreach ($this->getParameters() as $parameter) {
$name = $parameter->getName(); $name = $parameter->getName();

View File

@ -49,7 +49,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
* *
* @var array * @var array
*/ */
private $snapshot = array(); private $snapshot = [];
/** /**
* The entity that owns this collection. * The entity that owns this collection.
@ -585,7 +585,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
*/ */
public function __sleep() public function __sleep()
{ {
return array('collection', 'initialized'); return ['collection', 'initialized'];
} }
/** /**
@ -633,7 +633,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
$this->initialize(); $this->initialize();
$this->owner = null; $this->owner = null;
$this->snapshot = array(); $this->snapshot = [];
$this->changed(); $this->changed();
} }
@ -695,7 +695,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
protected function doInitialize() protected function doInitialize()
{ {
// Has NEW objects added through add(). Remember them. // Has NEW objects added through add(). Remember them.
$newObjects = array(); $newObjects = [];
if ($this->isDirty) { if ($this->isDirty) {
$newObjects = $this->collection->toArray(); $newObjects = $this->collection->toArray();

View File

@ -47,7 +47,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
return; // ignore inverse side return; // ignore inverse side
} }
$types = array(); $types = [];
$class = $this->em->getClassMetadata($mapping['sourceEntity']); $class = $this->em->getClassMetadata($mapping['sourceEntity']);
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
@ -104,7 +104,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
? $mapping['inversedBy'] ? $mapping['inversedBy']
: $mapping['mappedBy']; : $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) public function count(PersistentCollection $collection)
{ {
$conditions = array(); $conditions = [];
$params = array(); $params = [];
$types = array(); $types = [];
$mapping = $collection->getMapping(); $mapping = $collection->getMapping();
$id = $this->uow->getEntityIdentifier($collection->getOwner()); $id = $this->uow->getEntityIdentifier($collection->getOwner());
$sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']);
@ -238,7 +238,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$id = $this->uow->getEntityIdentifier($owner); $id = $this->uow->getEntityIdentifier($owner);
$targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
$onConditions = $this->getOnConditionSQL($mapping); $onConditions = $this->getOnConditionSQL($mapping);
$whereClauses = $params = array(); $whereClauses = $params = [];
if ( ! $mapping['isOwningSide']) { if ( ! $mapping['isOwningSide']) {
$associationSourceClass = $targetClass; $associationSourceClass = $targetClass;
@ -311,7 +311,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$filterSql = $this->generateFilterConditionSQL($rootClass, 'te'); $filterSql = $this->generateFilterConditionSQL($rootClass, 'te');
if ('' === $filterSql) { if ('' === $filterSql) {
return array('', ''); return ['', ''];
} }
// A join is needed if there is filtering on the target entity // A join is needed if there is filtering on the target entity
@ -319,7 +319,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$joinSql = ' JOIN ' . $tableName . ' te' $joinSql = ' JOIN ' . $tableName . ' te'
. ' ON' . implode(' AND ', $this->getOnConditionSQL($mapping)); . ' 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) protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias)
{ {
$filterClauses = array(); $filterClauses = [];
foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { foreach ($this->em->getFilters()->getEnabledFilters() as $filter) {
if ($filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { if ($filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
@ -363,7 +363,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
? $association['joinTable']['inverseJoinColumns'] ? $association['joinTable']['inverseJoinColumns']
: $association['joinTable']['joinColumns']; : $association['joinTable']['joinColumns'];
$conditions = array(); $conditions = [];
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
$joinColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $joinColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform);
@ -382,7 +382,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
*/ */
protected function getDeleteSQL(PersistentCollection $collection) protected function getDeleteSQL(PersistentCollection $collection)
{ {
$columns = array(); $columns = [];
$mapping = $collection->getMapping(); $mapping = $collection->getMapping();
$class = $this->em->getClassMetadata(get_class($collection->getOwner())); $class = $this->em->getClassMetadata(get_class($collection->getOwner()));
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform);
@ -408,12 +408,12 @@ class ManyToManyPersister extends AbstractCollectionPersister
// Optimization for single column identifier // Optimization for single column identifier
if (count($mapping['relationToSourceKeyColumns']) === 1) { if (count($mapping['relationToSourceKeyColumns']) === 1) {
return array(reset($identifier)); return [reset($identifier)];
} }
// Composite identifier // Composite identifier
$sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']);
$params = array(); $params = [];
foreach ($mapping['relationToSourceKeyColumns'] as $columnName => $refColumnName) { foreach ($mapping['relationToSourceKeyColumns'] as $columnName => $refColumnName) {
$params[] = isset($sourceClass->fieldNames[$refColumnName]) $params[] = isset($sourceClass->fieldNames[$refColumnName])
@ -437,8 +437,8 @@ class ManyToManyPersister extends AbstractCollectionPersister
$mapping = $collection->getMapping(); $mapping = $collection->getMapping();
$class = $this->em->getClassMetadata($mapping['sourceEntity']); $class = $this->em->getClassMetadata($mapping['sourceEntity']);
$targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
$columns = array(); $columns = [];
$types = array(); $types = [];
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
$columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
@ -450,11 +450,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
$types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em);
} }
return array( return [
'DELETE FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform) 'DELETE FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform)
. ' WHERE ' . implode(' = ? AND ', $columns) . ' = ?', . ' WHERE ' . implode(' = ? AND ', $columns) . ' = ?',
$types, $types,
); ];
} }
/** /**
@ -483,8 +483,8 @@ class ManyToManyPersister extends AbstractCollectionPersister
*/ */
protected function getInsertRowSQL(PersistentCollection $collection) protected function getInsertRowSQL(PersistentCollection $collection)
{ {
$columns = array(); $columns = [];
$types = array(); $types = [];
$mapping = $collection->getMapping(); $mapping = $collection->getMapping();
$class = $this->em->getClassMetadata($mapping['sourceEntity']); $class = $this->em->getClassMetadata($mapping['sourceEntity']);
$targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
@ -499,13 +499,13 @@ class ManyToManyPersister extends AbstractCollectionPersister
$types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em);
} }
return array( return [
'INSERT INTO ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform) 'INSERT INTO ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform)
. ' (' . implode(', ', $columns) . ')' . ' (' . implode(', ', $columns) . ')'
. ' VALUES' . ' VALUES'
. ' (' . implode(', ', array_fill(0, count($columns), '?')) . ')', . ' (' . implode(', ', array_fill(0, count($columns), '?')) . ')',
$types, $types,
); ];
} }
/** /**
@ -535,7 +535,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
*/ */
private function collectJoinTableColumnParameters(PersistentCollection $collection, $element) private function collectJoinTableColumnParameters(PersistentCollection $collection, $element)
{ {
$params = array(); $params = [];
$mapping = $collection->getMapping(); $mapping = $collection->getMapping();
$isComposite = count($mapping['joinTableColumns']) > 2; $isComposite = count($mapping['joinTableColumns']) > 2;
@ -602,14 +602,14 @@ class ManyToManyPersister extends AbstractCollectionPersister
} }
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $associationSourceClass, $this->platform). ' t'; $quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $associationSourceClass, $this->platform). ' t';
$whereClauses = array(); $whereClauses = [];
$params = array(); $params = [];
$types = array(); $types = [];
$joinNeeded = ! in_array($indexBy, $targetClass->identifier); $joinNeeded = ! in_array($indexBy, $targetClass->identifier);
if ($joinNeeded) { // extra join needed if indexBy is not a @id if ($joinNeeded) { // extra join needed if indexBy is not a @id
$joinConditions = array(); $joinConditions = [];
foreach ($joinColumns as $joinTableColumn) { foreach ($joinColumns as $joinTableColumn) {
$joinConditions[] = 't.' . $joinTableColumn['name'] . ' = tr.' . $joinTableColumn['referencedColumnName']; $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); $quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $sourceClass, $this->platform);
$whereClauses = array(); $whereClauses = [];
$params = array(); $params = [];
$types = array(); $types = [];
foreach ($mapping['joinTableColumns'] as $joinTableColumn) { foreach ($mapping['joinTableColumns'] as $joinTableColumn) {
$whereClauses[] = ($addFilters ? 't.' : '') . $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(); $expression = $criteria->getWhereExpression();
if ($expression === null) { if ($expression === null) {
return array(); return [];
} }
$valueVisitor = new SqlValueVisitor(); $valueVisitor = new SqlValueVisitor();

View File

@ -83,13 +83,13 @@ class OneToManyPersister extends AbstractCollectionPersister
$persister = $this->uow->getEntityPersister($mapping['targetEntity']); $persister = $this->uow->getEntityPersister($mapping['targetEntity']);
return $persister->load( return $persister->load(
array( [
$mapping['mappedBy'] => $collection->getOwner(), $mapping['mappedBy'] => $collection->getOwner(),
$mapping['indexBy'] => $index $mapping['indexBy'] => $index
), ],
null, null,
$mapping, $mapping,
array(), [],
null, null,
1 1
); );
@ -249,10 +249,10 @@ class OneToManyPersister extends AbstractCollectionPersister
$columnDefinitions = []; $columnDefinitions = [];
foreach ($idColumnNames as $idColumnName) { foreach ($idColumnNames as $idColumnName) {
$columnDefinitions[$idColumnName] = array( $columnDefinitions[$idColumnName] = [
'notnull' => true, 'notnull' => true,
'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $this->em)), 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $this->em)),
); ];
} }
$statement = $this->platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable $statement = $this->platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable
@ -271,7 +271,7 @@ class OneToManyPersister extends AbstractCollectionPersister
$numDeleted = $this->conn->executeUpdate($statement, $parameters); $numDeleted = $this->conn->executeUpdate($statement, $parameters);
// 3) Delete records on each table in the hierarchy // 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) { foreach (array_reverse($classNames) as $className) {
$tableName = $this->quoteStrategy->getTableName($this->em->getClassMetadata($className), $this->platform); $tableName = $this->quoteStrategy->getTableName($this->em->getClassMetadata($className), $this->platform);

View File

@ -86,7 +86,7 @@ class BasicEntityPersister implements EntityPersister
/** /**
* @var array * @var array
*/ */
static private $comparisonMap = array( static private $comparisonMap = [
Comparison::EQ => '= %s', Comparison::EQ => '= %s',
Comparison::IS => '= %s', Comparison::IS => '= %s',
Comparison::NEQ => '!= %s', Comparison::NEQ => '!= %s',
@ -97,7 +97,7 @@ class BasicEntityPersister implements EntityPersister
Comparison::IN => 'IN (%s)', Comparison::IN => 'IN (%s)',
Comparison::NIN => 'NOT IN (%s)', Comparison::NIN => 'NOT IN (%s)',
Comparison::CONTAINS => 'LIKE %s', Comparison::CONTAINS => 'LIKE %s',
); ];
/** /**
* Metadata object that describes the mapping of the mapped entity class. * Metadata object that describes the mapping of the mapped entity class.
@ -132,7 +132,7 @@ class BasicEntityPersister implements EntityPersister
* *
* @var array * @var array
*/ */
protected $queuedInserts = array(); protected $queuedInserts = [];
/** /**
* The map of column names to DBAL mapping types of all prepared columns used * 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 prepareInsertData($entity)
* @see prepareUpdateData($entity) * @see prepareUpdateData($entity)
*/ */
protected $columnTypes = array(); protected $columnTypes = [];
/** /**
* The map of quoted column names. * The map of quoted column names.
@ -153,7 +153,7 @@ class BasicEntityPersister implements EntityPersister
* @see prepareInsertData($entity) * @see prepareInsertData($entity)
* @see prepareUpdateData($entity) * @see prepareUpdateData($entity)
*/ */
protected $quotedColumns = array(); protected $quotedColumns = [];
/** /**
* The INSERT SQL statement used for entities handled by this persister. * The INSERT SQL statement used for entities handled by this persister.
@ -257,10 +257,10 @@ class BasicEntityPersister implements EntityPersister
public function executeInserts() public function executeInserts()
{ {
if ( ! $this->queuedInserts) { if ( ! $this->queuedInserts) {
return array(); return [];
} }
$postInsertIds = array(); $postInsertIds = [];
$idGenerator = $this->class->idGenerator; $idGenerator = $this->class->idGenerator;
$isPostInsertId = $idGenerator->isPostInsertGenerator(); $isPostInsertId = $idGenerator->isPostInsertGenerator();
@ -282,13 +282,13 @@ class BasicEntityPersister implements EntityPersister
if ($isPostInsertId) { if ($isPostInsertId) {
$generatedId = $idGenerator->generate($this->em, $entity); $generatedId = $idGenerator->generate($this->em, $entity);
$id = array( $id = [
$this->class->identifier[0] => $generatedId $this->class->identifier[0] => $generatedId
); ];
$postInsertIds[] = array( $postInsertIds[] = [
'generatedId' => $generatedId, 'generatedId' => $generatedId,
'entity' => $entity, 'entity' => $entity,
); ];
} else { } else {
$id = $this->class->getIdentifierValues($entity); $id = $this->class->getIdentifierValues($entity);
} }
@ -299,7 +299,7 @@ class BasicEntityPersister implements EntityPersister
} }
$stmt->closeCursor(); $stmt->closeCursor();
$this->queuedInserts = array(); $this->queuedInserts = [];
return $postInsertIds; return $postInsertIds;
} }
@ -389,9 +389,9 @@ class BasicEntityPersister implements EntityPersister
*/ */
protected final function updateTable($entity, $quotedTableName, array $updateData, $versioned = false) protected final function updateTable($entity, $quotedTableName, array $updateData, $versioned = false)
{ {
$set = array(); $set = [];
$types = array(); $types = [];
$params = array(); $params = [];
foreach ($updateData as $columnName => $value) { foreach ($updateData as $columnName => $value) {
$placeholder = '?'; $placeholder = '?';
@ -420,7 +420,7 @@ class BasicEntityPersister implements EntityPersister
$types[] = $this->columnTypes[$columnName]; $types[] = $this->columnTypes[$columnName];
} }
$where = array(); $where = [];
$identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
foreach ($this->class->identifier as $idField) { foreach ($this->class->identifier as $idField) {
@ -503,9 +503,9 @@ class BasicEntityPersister implements EntityPersister
$selfReferential = ($mapping['targetEntity'] == $mapping['sourceEntity']); $selfReferential = ($mapping['targetEntity'] == $mapping['sourceEntity']);
$class = $this->class; $class = $this->class;
$association = $mapping; $association = $mapping;
$otherColumns = array(); $otherColumns = [];
$otherKeys = array(); $otherKeys = [];
$keys = array(); $keys = [];
if ( ! $mapping['isOwningSide']) { if ( ! $mapping['isOwningSide']) {
$class = $this->em->getClassMetadata($mapping['targetEntity']); $class = $this->em->getClassMetadata($mapping['targetEntity']);
@ -603,7 +603,7 @@ class BasicEntityPersister implements EntityPersister
protected function prepareUpdateData($entity) protected function prepareUpdateData($entity)
{ {
$versionField = null; $versionField = null;
$result = array(); $result = [];
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
if (($versioned = $this->class->isVersioned) != false) { 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 // The associated entity $newVal is not yet persisted, so we must
// set $newVal = null, in order to insert a null value and schedule an // set $newVal = null, in order to insert a null value and schedule an
// extra update on the UnitOfWork. // extra update on the UnitOfWork.
$uow->scheduleExtraUpdate($entity, array($field => array(null, $newVal))); $uow->scheduleExtraUpdate($entity, [$field => [null, $newVal]]);
$newVal = null; $newVal = null;
} }
@ -705,7 +705,7 @@ class BasicEntityPersister implements EntityPersister
/** /**
* {@inheritdoc} * {@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); $this->switchPersisterContext(null, $limit);
@ -735,7 +735,7 @@ class BasicEntityPersister implements EntityPersister
/** /**
* {@inheritdoc} * {@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) { if (($foundEntity = $this->em->getUnitOfWork()->tryGetById($identifier, $assoc['targetEntity'])) != false) {
return $foundEntity; return $foundEntity;
@ -748,7 +748,7 @@ class BasicEntityPersister implements EntityPersister
// Mark inverse side as fetched in the hints, otherwise the UoW would // 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). // try to load it in a separate query (remember: to-one inverse sides can not be lazy).
$hints = array(); $hints = [];
if ($isInverseSingleValued) { if ($isInverseSingleValued) {
$hints['fetched']["r"][$assoc['inversedBy']] = true; $hints['fetched']["r"][$assoc['inversedBy']] = true;
@ -808,13 +808,13 @@ class BasicEntityPersister implements EntityPersister
$stmt = $this->conn->executeQuery($sql, $params, $types); $stmt = $this->conn->executeQuery($sql, $params, $types);
$hydrator = $this->em->newHydrator(Query::HYDRATE_OBJECT); $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} * {@inheritDoc}
*/ */
public function count($criteria = array()) public function count($criteria = [])
{ {
$sql = $this->getCountSQL($criteria); $sql = $this->getCountSQL($criteria);
@ -840,7 +840,8 @@ class BasicEntityPersister implements EntityPersister
$stmt = $this->conn->executeQuery($query, $params, $types); $stmt = $this->conn->executeQuery($query, $params, $types);
$hydrator = $this->em->newHydrator(($this->currentPersisterContext->selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); $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) public function expandCriteriaParameters(Criteria $criteria)
{ {
$expression = $criteria->getWhereExpression(); $expression = $criteria->getWhereExpression();
$sqlParams = array(); $sqlParams = [];
$sqlTypes = array(); $sqlTypes = [];
if ($expression === null) { if ($expression === null) {
return array($sqlParams, $sqlTypes); return [$sqlParams, $sqlTypes];
} }
$valueVisitor = new SqlValueVisitor(); $valueVisitor = new SqlValueVisitor();
@ -871,13 +872,13 @@ class BasicEntityPersister implements EntityPersister
$sqlTypes = array_merge($sqlTypes, $this->getTypes($field, $value, $this->class)); $sqlTypes = array_merge($sqlTypes, $this->getTypes($field, $value, $this->class));
} }
return array($sqlParams, $sqlTypes); return [$sqlParams, $sqlTypes];
} }
/** /**
* {@inheritdoc} * {@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); $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); $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) private function loadArrayFromStatement($assoc, $stmt)
{ {
$rsm = $this->currentPersisterContext->rsm; $rsm = $this->currentPersisterContext->rsm;
$hints = array(UnitOfWork::HINT_DEFEREAGERLOAD => true); $hints = [UnitOfWork::HINT_DEFEREAGERLOAD => true];
if (isset($assoc['indexBy'])) { if (isset($assoc['indexBy'])) {
$rsm = clone ($this->currentPersisterContext->rsm); // this is necessary because the "default rsm" should be changed. $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) private function loadCollectionFromStatement($assoc, $stmt, $coll)
{ {
$rsm = $this->currentPersisterContext->rsm; $rsm = $this->currentPersisterContext->rsm;
$hints = array( $hints = [
UnitOfWork::HINT_DEFEREAGERLOAD => true, UnitOfWork::HINT_DEFEREAGERLOAD => true,
'collection' => $coll 'collection' => $coll
); ];
if (isset($assoc['indexBy'])) { if (isset($assoc['indexBy'])) {
$rsm = clone ($this->currentPersisterContext->rsm); // this is necessary because the "default rsm" should be changed. $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']); $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']);
$class = $sourceClass; $class = $sourceClass;
$association = $assoc; $association = $assoc;
$criteria = array(); $criteria = [];
$parameters = array(); $parameters = [];
if ( ! $assoc['isOwningSide']) { if ( ! $assoc['isOwningSide']) {
$class = $this->em->getClassMetadata($assoc['targetEntity']); $class = $this->em->getClassMetadata($assoc['targetEntity']);
@ -1018,11 +1020,11 @@ class BasicEntityPersister implements EntityPersister
} }
$criteria[$quotedJoinTable . '.' . $quotedKeyColumn] = $value; $criteria[$quotedJoinTable . '.' . $quotedKeyColumn] = $value;
$parameters[] = array( $parameters[] = [
'value' => $value, 'value' => $value,
'field' => $field, 'field' => $field,
'class' => $sourceClass, 'class' => $sourceClass,
); ];
} }
$sql = $this->getSelectSQL($criteria, $assoc, null, $limit, $offset); $sql = $this->getSelectSQL($criteria, $assoc, null, $limit, $offset);
@ -1096,7 +1098,7 @@ class BasicEntityPersister implements EntityPersister
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getCountSQL($criteria = array()) public function getCountSQL($criteria = [])
{ {
$tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform);
$tableAlias = $this->getSQLTableAlias($this->class->name); $tableAlias = $this->getSQLTableAlias($this->class->name);
@ -1132,7 +1134,7 @@ class BasicEntityPersister implements EntityPersister
*/ */
protected final function getOrderBySQL(array $orderBy, $baseTableAlias) protected final function getOrderBySQL(array $orderBy, $baseTableAlias)
{ {
$orderByList = array(); $orderByList = [];
foreach ($orderBy as $fieldName => $orientation) { foreach ($orderBy as $fieldName => $orientation) {
@ -1194,7 +1196,7 @@ class BasicEntityPersister implements EntityPersister
return $this->currentPersisterContext->selectColumnListSql; return $this->currentPersisterContext->selectColumnListSql;
} }
$columnList = array(); $columnList = [];
$this->currentPersisterContext->rsm->addEntityResult($this->class->name, 'r'); // r for root $this->currentPersisterContext->rsm->addEntityResult($this->class->name, 'r'); // r for root
// Add regular columns to select list // Add regular columns to select list
@ -1247,7 +1249,7 @@ class BasicEntityPersister implements EntityPersister
} }
$association = $assoc; $association = $assoc;
$joinCondition = array(); $joinCondition = [];
if (isset($assoc['indexBy'])) { if (isset($assoc['indexBy'])) {
$this->currentPersisterContext->rsm->addIndexBy($assocAlias, $assoc['indexBy']); $this->currentPersisterContext->rsm->addIndexBy($assocAlias, $assoc['indexBy']);
@ -1315,7 +1317,7 @@ class BasicEntityPersister implements EntityPersister
return ''; return '';
} }
$columnList = array(); $columnList = [];
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']); $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
$isIdentifier = isset($assoc['id']) && $assoc['id'] === true; $isIdentifier = isset($assoc['id']) && $assoc['id'] === true;
$sqlTableAlias = $this->getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias)); $sqlTableAlias = $this->getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias));
@ -1343,7 +1345,7 @@ class BasicEntityPersister implements EntityPersister
*/ */
protected function getSelectManyToManyJoinSQL(array $manyToMany) protected function getSelectManyToManyJoinSQL(array $manyToMany)
{ {
$conditions = array(); $conditions = [];
$association = $manyToMany; $association = $manyToMany;
$sourceTableAlias = $this->getSQLTableAlias($this->class->name); $sourceTableAlias = $this->getSQLTableAlias($this->class->name);
@ -1385,7 +1387,7 @@ class BasicEntityPersister implements EntityPersister
return $this->insertSql; return $this->insertSql;
} }
$values = array(); $values = [];
$columns = array_unique($columns); $columns = array_unique($columns);
foreach ($columns as $column) { foreach ($columns as $column) {
@ -1419,7 +1421,7 @@ class BasicEntityPersister implements EntityPersister
*/ */
protected function getInsertColumnList() protected function getInsertColumnList()
{ {
$columns = array(); $columns = [];
foreach ($this->class->reflFields as $name => $field) { foreach ($this->class->reflFields as $name => $field) {
if ($this->class->isVersioned && $this->class->versionField == $name) { 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) public function getSelectConditionStatementSQL($field, $value, $assoc = null, $comparison = null)
{ {
$selectedColumns = array(); $selectedColumns = [];
$columns = $this->getSelectConditionStatementColumnSQL($field, $assoc); $columns = $this->getSelectConditionStatementColumnSQL($field, $assoc);
if (count($columns) > 1 && $comparison === Comparison::IN) { if (count($columns) > 1 && $comparison === Comparison::IN) {
@ -1660,13 +1662,13 @@ class BasicEntityPersister implements EntityPersister
? $this->class->fieldMappings[$field]['inherited'] ? $this->class->fieldMappings[$field]['inherited']
: $this->class->name; : $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])) { if (isset($this->class->associationMappings[$field])) {
$association = $this->class->associationMappings[$field]; $association = $this->class->associationMappings[$field];
// Many-To-Many requires join table check for joinColumn // Many-To-Many requires join table check for joinColumn
$columns = array(); $columns = [];
$class = $this->class; $class = $this->class;
if ($association['type'] === ClassMetadata::MANY_TO_MANY) { 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. // therefore checking for spaces and function calls which are not allowed.
// found a join column condition, not really a "field" // found a join column condition, not really a "field"
return array($field); return [$field];
} }
throw ORMException::unrecognizedField($field); throw ORMException::unrecognizedField($field);
@ -1725,7 +1727,7 @@ class BasicEntityPersister implements EntityPersister
*/ */
protected function getSelectConditionSQL(array $criteria, $assoc = null) protected function getSelectConditionSQL(array $criteria, $assoc = null)
{ {
$conditions = array(); $conditions = [];
foreach ($criteria as $field => $value) { foreach ($criteria as $field => $value) {
$conditions[] = $this->getSelectConditionStatementSQL($field, $value, $assoc); $conditions[] = $this->getSelectConditionStatementSQL($field, $value, $assoc);
@ -1770,8 +1772,8 @@ class BasicEntityPersister implements EntityPersister
{ {
$this->switchPersisterContext($offset, $limit); $this->switchPersisterContext($offset, $limit);
$criteria = array(); $criteria = [];
$parameters = array(); $parameters = [];
$owningAssoc = $this->class->associationMappings[$assoc['mappedBy']]; $owningAssoc = $this->class->associationMappings[$assoc['mappedBy']];
$sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']);
$tableAlias = $this->getSQLTableAlias(isset($owningAssoc['inherited']) ? $owningAssoc['inherited'] : $this->class->name); $tableAlias = $this->getSQLTableAlias(isset($owningAssoc['inherited']) ? $owningAssoc['inherited'] : $this->class->name);
@ -1787,11 +1789,11 @@ class BasicEntityPersister implements EntityPersister
} }
$criteria[$tableAlias . "." . $targetKeyColumn] = $value; $criteria[$tableAlias . "." . $targetKeyColumn] = $value;
$parameters[] = array( $parameters[] = [
'value' => $value, 'value' => $value,
'field' => $field, 'field' => $field,
'class' => $sourceClass, 'class' => $sourceClass,
); ];
continue; continue;
} }
@ -1800,11 +1802,11 @@ class BasicEntityPersister implements EntityPersister
$value = $sourceClass->reflFields[$field]->getValue($sourceEntity); $value = $sourceClass->reflFields[$field]->getValue($sourceEntity);
$criteria[$tableAlias . "." . $targetKeyColumn] = $value; $criteria[$tableAlias . "." . $targetKeyColumn] = $value;
$parameters[] = array( $parameters[] = [
'value' => $value, 'value' => $value,
'field' => $field, 'field' => $field,
'class' => $sourceClass, 'class' => $sourceClass,
); ];
} }
@ -1819,8 +1821,8 @@ class BasicEntityPersister implements EntityPersister
*/ */
public function expandParameters($criteria) public function expandParameters($criteria)
{ {
$params = array(); $params = [];
$types = array(); $types = [];
foreach ($criteria as $field => $value) { foreach ($criteria as $field => $value) {
if ($value === null) { if ($value === null) {
@ -1831,7 +1833,7 @@ class BasicEntityPersister implements EntityPersister
$params = array_merge($params, $this->getValues($value)); $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) private function expandToManyParameters($criteria)
{ {
$params = array(); $params = [];
$types = array(); $types = [];
foreach ($criteria as $criterion) { foreach ($criteria as $criterion) {
if ($criterion['value'] === null) { if ($criterion['value'] === null) {
@ -1860,7 +1862,7 @@ class BasicEntityPersister implements EntityPersister
$params = array_merge($params, $this->getValues($criterion['value'])); $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) private function getTypes($field, $value, ClassMetadata $class)
{ {
$types = array(); $types = [];
switch (true) { switch (true) {
case (isset($class->fieldMappings[$field])): case (isset($class->fieldMappings[$field])):
$types = array_merge($types, array($class->fieldMappings[$field]['type'])); $types = array_merge($types, [$class->fieldMappings[$field]['type']]);
break; break;
case (isset($class->associationMappings[$field])): case (isset($class->associationMappings[$field])):
@ -1926,19 +1928,19 @@ class BasicEntityPersister implements EntityPersister
private function getValues($value) private function getValues($value)
{ {
if (is_array($value)) { if (is_array($value)) {
$newValue = array(); $newValue = [];
foreach ($value as $itemValue) { foreach ($value as $itemValue) {
$newValue = array_merge($newValue, $this->getValues($itemValue)); $newValue = array_merge($newValue, $this->getValues($itemValue));
} }
return array($newValue); return [$newValue];
} }
if (is_object($value) && $this->em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) { if (is_object($value) && $this->em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) {
$class = $this->em->getClassMetadata(get_class($value)); $class = $this->em->getClassMetadata(get_class($value));
if ($class->isIdentifierComposite) { if ($class->isIdentifierComposite) {
$newValue = array(); $newValue = [];
foreach ($class->getIdentifierValues($value) as $innerValue) { foreach ($class->getIdentifierValues($value) as $innerValue) {
$newValue = array_merge($newValue, $this->getValues($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) protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias)
{ {
$filterClauses = array(); $filterClauses = [];
foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { foreach ($this->em->getFilters()->getEnabledFilters() as $filter) {
if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {

View File

@ -76,7 +76,7 @@ class CachedPersisterContext
* *
* @var array * @var array
*/ */
public $sqlTableAliases = array(); public $sqlTableAliases = [];
/** /**
* Whether this persistent context is considering limit operations applied to the selection queries * Whether this persistent context is considering limit operations applied to the selection queries

View File

@ -81,7 +81,7 @@ interface EntityPersister
* *
* @return string * @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. * Expands the parameters from the given criteria and use the correct binding types if found.
@ -165,7 +165,7 @@ interface EntityPersister
* *
* @return int * @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. * 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? * @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. * Loads an entity by identifier.
@ -225,7 +225,7 @@ interface EntityPersister
* *
* @throws \Doctrine\ORM\Mapping\MappingException * @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. * Refreshes a managed entity.
@ -260,7 +260,7 @@ interface EntityPersister
* *
* @return array * @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. * Gets (sliced or full) elements of the given collection.

View File

@ -45,14 +45,14 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
* *
* @var array * @var array
*/ */
private $owningTableMap = array(); private $owningTableMap = [];
/** /**
* Map of table to quoted table names. * Map of table to quoted table names.
* *
* @var array * @var array
*/ */
private $quotedTableMap = array(); private $quotedTableMap = [];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -127,10 +127,10 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
public function executeInserts() public function executeInserts()
{ {
if ( ! $this->queuedInserts) { if ( ! $this->queuedInserts) {
return array(); return [];
} }
$postInsertIds = array(); $postInsertIds = [];
$idGenerator = $this->class->idGenerator; $idGenerator = $this->class->idGenerator;
$isPostInsertId = $idGenerator->isPostInsertGenerator(); $isPostInsertId = $idGenerator->isPostInsertGenerator();
$rootClass = ($this->class->name !== $this->class->rootEntityName) $rootClass = ($this->class->name !== $this->class->rootEntityName)
@ -143,7 +143,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
$rootTableStmt = $this->conn->prepare($rootPersister->getInsertSQL()); $rootTableStmt = $this->conn->prepare($rootPersister->getInsertSQL());
// Prepare statements for sub tables. // Prepare statements for sub tables.
$subTableStmts = array(); $subTableStmts = [];
if ($rootClass !== $this->class) { if ($rootClass !== $this->class) {
$subTableStmts[$this->class->getTableName()] = $this->conn->prepare($this->getInsertSQL()); $subTableStmts[$this->class->getTableName()] = $this->conn->prepare($this->getInsertSQL());
@ -176,13 +176,13 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
if ($isPostInsertId) { if ($isPostInsertId) {
$generatedId = $idGenerator->generate($this->em, $entity); $generatedId = $idGenerator->generate($this->em, $entity);
$id = array( $id = [
$this->class->identifier[0] => $generatedId $this->class->identifier[0] => $generatedId
); ];
$postInsertIds[] = array( $postInsertIds[] = [
'generatedId' => $generatedId, 'generatedId' => $generatedId,
'entity' => $entity, 'entity' => $entity,
); ];
} else { } else {
$id = $this->em->getUnitOfWork()->getEntityIdentifier($entity); $id = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
} }
@ -198,7 +198,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
$paramIndex = 1; $paramIndex = 1;
$data = isset($insertData[$tableName]) $data = isset($insertData[$tableName])
? $insertData[$tableName] ? $insertData[$tableName]
: array(); : [];
foreach ((array) $id as $idName => $idVal) { foreach ((array) $id as $idName => $idVal) {
$type = isset($this->columnTypes[$idName]) ? $this->columnTypes[$idName] : Type::STRING; $type = isset($this->columnTypes[$idName]) ? $this->columnTypes[$idName] : Type::STRING;
@ -222,7 +222,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
$stmt->closeCursor(); $stmt->closeCursor();
} }
$this->queuedInserts = array(); $this->queuedInserts = [];
return $postInsertIds; return $postInsertIds;
} }
@ -258,7 +258,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
if ( ! isset($updateData[$versionedTable])) { if ( ! isset($updateData[$versionedTable])) {
$tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform); $tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform);
$this->updateTable($entity, $tableName, array(), true); $this->updateTable($entity, $tableName, [], true);
} }
$identifiers = $this->em->getUnitOfWork()->getEntityIdentifier($entity); $identifiers = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
@ -369,7 +369,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getCountSQL($criteria = array()) public function getCountSQL($criteria = [])
{ {
$tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform);
$baseTableAlias = $this->getSQLTableAlias($this->class->name); $baseTableAlias = $this->getSQLTableAlias($this->class->name);
@ -406,7 +406,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
// INNER JOIN parent tables // INNER JOIN parent tables
foreach ($this->class->parentClasses as $parentClassName) { foreach ($this->class->parentClasses as $parentClassName) {
$conditions = array(); $conditions = [];
$tableAlias = $this->getSQLTableAlias($parentClassName); $tableAlias = $this->getSQLTableAlias($parentClassName);
$parentClass = $this->em->getClassMetadata($parentClassName); $parentClass = $this->em->getClassMetadata($parentClassName);
$joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON ';
@ -433,7 +433,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
return $this->currentPersisterContext->selectColumnListSql; return $this->currentPersisterContext->selectColumnListSql;
} }
$columnList = array(); $columnList = [];
$discrColumn = $this->class->discriminatorColumn['name']; $discrColumn = $this->class->discriminatorColumn['name'];
$discrColumnType = $this->class->discriminatorColumn['type']; $discrColumnType = $this->class->discriminatorColumn['type'];
$baseTableAlias = $this->getSQLTableAlias($this->class->name); $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. // Identifier columns must always come first in the column list of subclasses.
$columns = $this->class->parentClasses $columns = $this->class->parentClasses
? $this->class->getIdentifierColumnNames() ? $this->class->getIdentifierColumnNames()
: array(); : [];
foreach ($this->class->reflFields as $name => $field) { foreach ($this->class->reflFields as $name => $field) {
if (isset($this->class->fieldMappings[$name]['inherited']) if (isset($this->class->fieldMappings[$name]['inherited'])
@ -599,7 +599,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
// INNER JOIN parent tables // INNER JOIN parent tables
foreach ($this->class->parentClasses as $parentClassName) { foreach ($this->class->parentClasses as $parentClassName) {
$conditions = array(); $conditions = [];
$parentClass = $this->em->getClassMetadata($parentClassName); $parentClass = $this->em->getClassMetadata($parentClassName);
$tableAlias = $this->getSQLTableAlias($parentClassName); $tableAlias = $this->getSQLTableAlias($parentClassName);
$joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON ';
@ -614,7 +614,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
// OUTER JOIN sub tables // OUTER JOIN sub tables
foreach ($this->class->subClasses as $subClassName) { foreach ($this->class->subClasses as $subClassName) {
$conditions = array(); $conditions = [];
$subClass = $this->em->getClassMetadata($subClassName); $subClass = $this->em->getClassMetadata($subClassName);
$tableAlias = $this->getSQLTableAlias($subClassName); $tableAlias = $this->getSQLTableAlias($subClassName);
$joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON '; $joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON ';

View File

@ -164,7 +164,7 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
*/ */
protected function getSelectConditionDiscriminatorValueSQL() protected function getSelectConditionDiscriminatorValueSQL()
{ {
$values = array(); $values = [];
if ($this->class->discriminatorValue !== null) { // discriminators can be 0 if ($this->class->discriminatorValue !== null) { // discriminators can be 0
$values[] = $this->conn->quote($this->class->discriminatorValue); $values[] = $this->conn->quote($this->class->discriminatorValue);

View File

@ -70,7 +70,7 @@ class SqlExpressionVisitor extends ExpressionVisitor
if (isset($this->classMetadata->associationMappings[$field]) && if (isset($this->classMetadata->associationMappings[$field]) &&
$value !== null && $value !== null &&
! is_object($value) && ! 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); throw PersisterException::matchingAssocationFieldRequiresObject($this->classMetadata->name, $field);
} }
@ -89,7 +89,7 @@ class SqlExpressionVisitor extends ExpressionVisitor
*/ */
public function walkCompositeExpression(CompositeExpression $expr) public function walkCompositeExpression(CompositeExpression $expr)
{ {
$expressionList = array(); $expressionList = [];
foreach ($expr->getExpressionList() as $child) { foreach ($expr->getExpressionList() as $child) {
$expressionList[] = $this->dispatch($child); $expressionList[] = $this->dispatch($child);

View File

@ -34,12 +34,12 @@ class SqlValueVisitor extends ExpressionVisitor
/** /**
* @var array * @var array
*/ */
private $values = array(); private $values = [];
/** /**
* @var array * @var array
*/ */
private $types = array(); private $types = [];
/** /**
* Converts a comparison expression into the target query language output. * Converts a comparison expression into the target query language output.
@ -61,7 +61,7 @@ class SqlValueVisitor extends ExpressionVisitor
} }
$this->values[] = $value; $this->values[] = $value;
$this->types[] = array($field, $value); $this->types[] = [$field, $value];
} }
/** /**
@ -97,7 +97,7 @@ class SqlValueVisitor extends ExpressionVisitor
*/ */
public function getParamsAndTypes() public function getParamsAndTypes()
{ {
return array($this->values, $this->types); return [$this->values, $this->types];
} }
/** /**

View File

@ -135,7 +135,7 @@ final class Query extends AbstractQuery
* *
* @var array * @var array
*/ */
private $_parsedTypes = array(); private $_parsedTypes = [];
/** /**
* Cached DQL query. * Cached DQL query.
@ -241,7 +241,7 @@ final class Query extends AbstractQuery
*/ */
private function _parse() private function _parse()
{ {
$types = array(); $types = [];
foreach ($this->parameters as $parameter) { foreach ($this->parameters as $parameter) {
/** @var Query\Parameter $parameter */ /** @var Query\Parameter $parameter */
@ -354,8 +354,8 @@ final class Query extends AbstractQuery
*/ */
private function processParameterMappings($paramMappings) private function processParameterMappings($paramMappings)
{ {
$sqlParams = array(); $sqlParams = [];
$types = array(); $types = [];
foreach ($this->parameters as $parameter) { foreach ($this->parameters as $parameter) {
$key = $parameter->getName(); $key = $parameter->getName();
@ -383,7 +383,7 @@ final class Query extends AbstractQuery
// optimized multi value sql positions away for now, // optimized multi value sql positions away for now,
// they are not allowed in DQL anyways. // they are not allowed in DQL anyways.
$value = array($value); $value = [$value];
$countValue = count($value); $countValue = count($value);
for ($i = 0, $l = count($sqlPositions); $i < $l; $i++) { for ($i = 0, $l = count($sqlPositions); $i < $l; $i++) {
@ -403,7 +403,7 @@ final class Query extends AbstractQuery
$types = array_values($types); $types = array_values($types);
} }
return array($sqlParams, $types); return [$sqlParams, $types];
} }
/** /**
@ -667,7 +667,7 @@ final class Query extends AbstractQuery
*/ */
public function setLockMode($lockMode) 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()) { if ( ! $this->_em->getConnection()->isTransactionActive()) {
throw TransactionRequiredException::transactionRequired(); throw TransactionRequiredException::transactionRequired();
} }

View File

@ -35,7 +35,7 @@ class CoalesceExpression extends Node
/** /**
* @var array * @var array
*/ */
public $scalarExpressions = array(); public $scalarExpressions = [];
/** /**
* @param array $scalarExpressions * @param array $scalarExpressions

View File

@ -33,7 +33,7 @@ class ConditionalExpression extends Node
/** /**
* @var array * @var array
*/ */
public $conditionalTerms = array(); public $conditionalTerms = [];
/** /**
* @param array $conditionalTerms * @param array $conditionalTerms

View File

@ -32,7 +32,7 @@ class ConditionalTerm extends Node
/** /**
* @var array * @var array
*/ */
public $conditionalFactors = array(); public $conditionalFactors = [];
/** /**
* @param array $conditionalFactors * @param array $conditionalFactors

View File

@ -34,7 +34,7 @@ class FromClause extends Node
/** /**
* @var array * @var array
*/ */
public $identificationVariableDeclarations = array(); public $identificationVariableDeclarations = [];
/** /**
* @param array $identificationVariableDeclarations * @param array $identificationVariableDeclarations

View File

@ -38,7 +38,7 @@ class ConcatFunction extends FunctionNode
public $secondStringPrimary; public $secondStringPrimary;
public $concatExpressions = array(); public $concatExpressions = [];
/** /**
* @override * @override
@ -47,13 +47,13 @@ class ConcatFunction extends FunctionNode
{ {
$platform = $sqlWalker->getConnection()->getDatabasePlatform(); $platform = $sqlWalker->getConnection()->getDatabasePlatform();
$args = array(); $args = [];
foreach ($this->concatExpressions as $expression) { foreach ($this->concatExpressions as $expression) {
$args[] = $sqlWalker->walkStringPrimary($expression); $args[] = $sqlWalker->walkStringPrimary($expression);
} }
return call_user_func_array(array($platform,'getConcatExpression'), $args); return call_user_func_array([$platform,'getConcatExpression'], $args);
} }
/** /**

View File

@ -35,7 +35,7 @@ class GeneralCaseExpression extends Node
/** /**
* @var array * @var array
*/ */
public $whenClauses = array(); public $whenClauses = [];
/** /**
* @var mixed * @var mixed

View File

@ -33,7 +33,7 @@ class GroupByClause extends Node
/** /**
* @var array * @var array
*/ */
public $groupByItems = array(); public $groupByItems = [];
/** /**
* @param array $groupByItems * @param array $groupByItems

View File

@ -43,7 +43,7 @@ class IdentificationVariableDeclaration extends Node
/** /**
* @var array * @var array
*/ */
public $joins = array(); public $joins = [];
/** /**
* @param RangeVariableDeclaration|null $rangeVariableDecl * @param RangeVariableDeclaration|null $rangeVariableDecl

View File

@ -42,7 +42,7 @@ class InExpression extends Node
/** /**
* @var array * @var array
*/ */
public $literals = array(); public $literals = [];
/** /**
* @var Subselect|null * @var Subselect|null

View File

@ -33,7 +33,7 @@ class OrderByClause extends Node
/** /**
* @var array * @var array
*/ */
public $orderByItems = array(); public $orderByItems = [];
/** /**
* @param array $orderByItems * @param array $orderByItems

View File

@ -38,7 +38,7 @@ class SelectClause extends Node
/** /**
* @var array * @var array
*/ */
public $selectExpressions = array(); public $selectExpressions = [];
/** /**
* @param array $selectExpressions * @param array $selectExpressions

View File

@ -33,7 +33,7 @@ class SimpleArithmeticExpression extends Node
/** /**
* @var array * @var array
*/ */
public $arithmeticTerms = array(); public $arithmeticTerms = [];
/** /**
* @param array $arithmeticTerms * @param array $arithmeticTerms

View File

@ -40,7 +40,7 @@ class SimpleCaseExpression extends Node
/** /**
* @var array * @var array
*/ */
public $simpleWhenClauses = array(); public $simpleWhenClauses = [];
/** /**
* @var mixed * @var mixed

View File

@ -33,7 +33,7 @@ class SubselectFromClause extends Node
/** /**
* @var array * @var array
*/ */
public $identificationVariableDeclarations = array(); public $identificationVariableDeclarations = [];
/** /**
* @param array $identificationVariableDeclarations * @param array $identificationVariableDeclarations

View File

@ -43,7 +43,7 @@ class UpdateClause extends Node
/** /**
* @var array * @var array
*/ */
public $updateItems = array(); public $updateItems = [];
/** /**
* @param string $abstractSchemaName * @param string $abstractSchemaName

View File

@ -81,7 +81,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
. ' SELECT t0.' . implode(', t0.', $idColumnNames); . ' SELECT t0.' . implode(', t0.', $idColumnNames);
$rangeDecl = new AST\RangeVariableDeclaration($primaryClass->name, $primaryDqlAlias); $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); $this->_insertSql .= $sqlWalker->walkFromClause($fromClause);
// Append WHERE clause, if there is one. // Append WHERE clause, if there is one.
@ -93,7 +93,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
$idSubselect = 'SELECT ' . $idColumnList . ' FROM ' . $tempTable; $idSubselect = 'SELECT ' . $idColumnList . ' FROM ' . $tempTable;
// 3. Create and store DELETE statements // 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) { foreach (array_reverse($classNames) as $className) {
$tableName = $quoteStrategy->getTableName($em->getClassMetadata($className), $platform); $tableName = $quoteStrategy->getTableName($em->getClassMetadata($className), $platform);
$this->_sqlStatements[] = 'DELETE FROM ' . $tableName $this->_sqlStatements[] = 'DELETE FROM ' . $tableName
@ -101,12 +101,12 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
} }
// 4. Store DDL for temporary identifier table. // 4. Store DDL for temporary identifier table.
$columnDefinitions = array(); $columnDefinitions = [];
foreach ($idColumnNames as $idColumnName) { foreach ($idColumnNames as $idColumnName) {
$columnDefinitions[$idColumnName] = array( $columnDefinitions[$idColumnName] = [
'notnull' => true, 'notnull' => true,
'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)), 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)),
); ];
} }
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')'; . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';

View File

@ -52,7 +52,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
/** /**
* @var array * @var array
*/ */
private $_sqlParameters = array(); private $_sqlParameters = [];
/** /**
* @var int * @var int
@ -92,7 +92,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
. ' SELECT t0.' . implode(', t0.', $idColumnNames); . ' SELECT t0.' . implode(', t0.', $idColumnNames);
$rangeDecl = new AST\RangeVariableDeclaration($primaryClass->name, $updateClause->aliasIdentificationVariable); $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); $this->_insertSql .= $sqlWalker->walkFromClause($fromClause);
@ -100,7 +100,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
$idSubselect = 'SELECT ' . $idColumnList . ' FROM ' . $tempTable; $idSubselect = 'SELECT ' . $idColumnList . ' FROM ' . $tempTable;
// 3. Create and store UPDATE statements // 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; $i = -1;
foreach (array_reverse($classNames) as $className) { foreach (array_reverse($classNames) as $className) {
@ -143,13 +143,13 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
} }
// 4. Store DDL for temporary identifier table. // 4. Store DDL for temporary identifier table.
$columnDefinitions = array(); $columnDefinitions = [];
foreach ($idColumnNames as $idColumnName) { foreach ($idColumnNames as $idColumnName) {
$columnDefinitions[$idColumnName] = array( $columnDefinitions[$idColumnName] = [
'notnull' => true, 'notnull' => true,
'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)), 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)),
); ];
} }
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
@ -176,8 +176,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
// Execute UPDATE statements // Execute UPDATE statements
foreach ($this->_sqlStatements as $key => $statement) { foreach ($this->_sqlStatements as $key => $statement) {
$paramValues = array(); $paramValues = [];
$paramTypes = array(); $paramTypes = [];
if (isset($this->_sqlParameters[$key])) { if (isset($this->_sqlParameters[$key])) {
foreach ($this->_sqlParameters[$key] as $parameterKey => $parameterName) { foreach ($this->_sqlParameters[$key] as $parameterKey => $parameterName) {

View File

@ -220,7 +220,7 @@ class Expr
*/ */
public function avg($x) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) public function substring($x, $from, $len = null)
{ {
$args = array($x, $from); $args = [$x, $from];
if (null !== $len) { if (null !== $len) {
$args[] = $len; $args[] = $len;
} }
@ -565,7 +565,7 @@ class Expr
*/ */
public function lower($x) 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) 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) public function length($x)
{ {
return new Expr\Func('LENGTH', array($x)); return new Expr\Func('LENGTH', [$x]);
} }
/** /**

View File

@ -38,12 +38,12 @@ class Andx extends Composite
/** /**
* @var array * @var array
*/ */
protected $allowedClasses = array( protected $allowedClasses = [
'Doctrine\ORM\Query\Expr\Comparison', 'Doctrine\ORM\Query\Expr\Comparison',
'Doctrine\ORM\Query\Expr\Func', 'Doctrine\ORM\Query\Expr\Func',
'Doctrine\ORM\Query\Expr\Orx', 'Doctrine\ORM\Query\Expr\Orx',
'Doctrine\ORM\Query\Expr\Andx', 'Doctrine\ORM\Query\Expr\Andx',
); ];
/** /**
* @return array * @return array

View File

@ -48,17 +48,17 @@ abstract class Base
/** /**
* @var array * @var array
*/ */
protected $allowedClasses = array(); protected $allowedClasses = [];
/** /**
* @var array * @var array
*/ */
protected $parts = array(); protected $parts = [];
/** /**
* @param array $args * @param array $args
*/ */
public function __construct($args = array()) public function __construct($args = [])
{ {
$this->addMultiple($args); $this->addMultiple($args);
} }
@ -68,7 +68,7 @@ abstract class Base
* *
* @return Base * @return Base
*/ */
public function addMultiple($args = array()) public function addMultiple($args = [])
{ {
foreach ((array) $args as $arg) { foreach ((array) $args as $arg) {
$this->add($arg); $this->add($arg);

View File

@ -39,7 +39,7 @@ class Composite extends Base
return (string) $this->parts[0]; return (string) $this->parts[0];
} }
$components = array(); $components = [];
foreach ($this->parts as $part) { foreach ($this->parts as $part) {
$components[] = $this->processQueryPart($part); $components[] = $this->processQueryPart($part);

View File

@ -48,12 +48,12 @@ class OrderBy
/** /**
* @var array * @var array
*/ */
protected $allowedClasses = array(); protected $allowedClasses = [];
/** /**
* @var array * @var array
*/ */
protected $parts = array(); protected $parts = [];
/** /**
* @param string|null $sort * @param string|null $sort

View File

@ -38,12 +38,12 @@ class Orx extends Composite
/** /**
* @var array * @var array
*/ */
protected $allowedClasses = array( protected $allowedClasses = [
'Doctrine\ORM\Query\Expr\Comparison', 'Doctrine\ORM\Query\Expr\Comparison',
'Doctrine\ORM\Query\Expr\Func', 'Doctrine\ORM\Query\Expr\Func',
'Doctrine\ORM\Query\Expr\Andx', 'Doctrine\ORM\Query\Expr\Andx',
'Doctrine\ORM\Query\Expr\Orx', 'Doctrine\ORM\Query\Expr\Orx',
); ];
/** /**
* @return array * @return array

View File

@ -43,9 +43,7 @@ class Select extends Base
/** /**
* @var array * @var array
*/ */
protected $allowedClasses = array( protected $allowedClasses = ['Doctrine\ORM\Query\Expr\Func'];
'Doctrine\ORM\Query\Expr\Func'
);
/** /**
* @return array * @return array

View File

@ -75,7 +75,7 @@ abstract class SQLFilter
$type = ParameterTypeInferer::inferType($value); $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 // Keep the parameters sorted for the hash
ksort($this->parameters); ksort($this->parameters);

View File

@ -59,7 +59,7 @@ class FilterCollection
* *
* @var \Doctrine\ORM\Query\Filter\SQLFilter[] * @var \Doctrine\ORM\Query\Filter\SQLFilter[]
*/ */
private $enabledFilters = array(); private $enabledFilters = [];
/** /**
* @var string The filter hash from the last time the query was parsed. * @var string The filter hash from the last time the query was parsed.

View File

@ -129,13 +129,13 @@ class Lexer extends \Doctrine\Common\Lexer
*/ */
protected function getCatchablePatterns() 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_]*(?:\\\[a-z_][a-z0-9_]*)*', // aliased name
'[a-z_\\\][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // identifier or qualified name '[a-z_\\\][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // identifier or qualified name
'(?:[0-9]+(?:[\.][0-9]+)*)(?:e[+-]?[0-9]+)?', // numbers '(?:[0-9]+(?:[\.][0-9]+)*)(?:e[+-]?[0-9]+)?', // numbers
"'(?:[^']|'')*'", // quoted strings "'(?:[^']|'')*'", // quoted strings
'\?[0-9]*|:[a-z_][a-z0-9_]*' // parameters '\?[0-9]*|:[a-z_][a-z0-9_]*' // parameters
); ];
} }
/** /**
@ -143,7 +143,7 @@ class Lexer extends \Doctrine\Common\Lexer
*/ */
protected function getNonCatchablePatterns() protected function getNonCatchablePatterns()
{ {
return array('\s+', '(.)'); return ['\s+', '(.)'];
} }
/** /**

View File

@ -40,21 +40,21 @@ class Parser
* *
* @var array * @var array
*/ */
private static $_STRING_FUNCTIONS = array( private static $_STRING_FUNCTIONS = [
'concat' => 'Doctrine\ORM\Query\AST\Functions\ConcatFunction', 'concat' => 'Doctrine\ORM\Query\AST\Functions\ConcatFunction',
'substring' => 'Doctrine\ORM\Query\AST\Functions\SubstringFunction', 'substring' => 'Doctrine\ORM\Query\AST\Functions\SubstringFunction',
'trim' => 'Doctrine\ORM\Query\AST\Functions\TrimFunction', 'trim' => 'Doctrine\ORM\Query\AST\Functions\TrimFunction',
'lower' => 'Doctrine\ORM\Query\AST\Functions\LowerFunction', 'lower' => 'Doctrine\ORM\Query\AST\Functions\LowerFunction',
'upper' => 'Doctrine\ORM\Query\AST\Functions\UpperFunction', 'upper' => 'Doctrine\ORM\Query\AST\Functions\UpperFunction',
'identity' => 'Doctrine\ORM\Query\AST\Functions\IdentityFunction', 'identity' => 'Doctrine\ORM\Query\AST\Functions\IdentityFunction',
); ];
/** /**
* READ-ONLY: Maps BUILT-IN numeric function names to AST class names. * READ-ONLY: Maps BUILT-IN numeric function names to AST class names.
* *
* @var array * @var array
*/ */
private static $_NUMERIC_FUNCTIONS = array( private static $_NUMERIC_FUNCTIONS = [
'length' => 'Doctrine\ORM\Query\AST\Functions\LengthFunction', 'length' => 'Doctrine\ORM\Query\AST\Functions\LengthFunction',
'locate' => 'Doctrine\ORM\Query\AST\Functions\LocateFunction', 'locate' => 'Doctrine\ORM\Query\AST\Functions\LocateFunction',
'abs' => 'Doctrine\ORM\Query\AST\Functions\AbsFunction', 'abs' => 'Doctrine\ORM\Query\AST\Functions\AbsFunction',
@ -64,20 +64,20 @@ class Parser
'date_diff' => 'Doctrine\ORM\Query\AST\Functions\DateDiffFunction', 'date_diff' => 'Doctrine\ORM\Query\AST\Functions\DateDiffFunction',
'bit_and' => 'Doctrine\ORM\Query\AST\Functions\BitAndFunction', 'bit_and' => 'Doctrine\ORM\Query\AST\Functions\BitAndFunction',
'bit_or' => 'Doctrine\ORM\Query\AST\Functions\BitOrFunction', 'bit_or' => 'Doctrine\ORM\Query\AST\Functions\BitOrFunction',
); ];
/** /**
* READ-ONLY: Maps BUILT-IN datetime function names to AST class names. * READ-ONLY: Maps BUILT-IN datetime function names to AST class names.
* *
* @var array * @var array
*/ */
private static $_DATETIME_FUNCTIONS = array( private static $_DATETIME_FUNCTIONS = [
'current_date' => 'Doctrine\ORM\Query\AST\Functions\CurrentDateFunction', 'current_date' => 'Doctrine\ORM\Query\AST\Functions\CurrentDateFunction',
'current_time' => 'Doctrine\ORM\Query\AST\Functions\CurrentTimeFunction', 'current_time' => 'Doctrine\ORM\Query\AST\Functions\CurrentTimeFunction',
'current_timestamp' => 'Doctrine\ORM\Query\AST\Functions\CurrentTimestampFunction', 'current_timestamp' => 'Doctrine\ORM\Query\AST\Functions\CurrentTimestampFunction',
'date_add' => 'Doctrine\ORM\Query\AST\Functions\DateAddFunction', 'date_add' => 'Doctrine\ORM\Query\AST\Functions\DateAddFunction',
'date_sub' => 'Doctrine\ORM\Query\AST\Functions\DateSubFunction', 'date_sub' => 'Doctrine\ORM\Query\AST\Functions\DateSubFunction',
); ];
/* /*
* Expressions that were encountered during parsing of identifiers and expressions * Expressions that were encountered during parsing of identifiers and expressions
@ -87,27 +87,27 @@ class Parser
/** /**
* @var array * @var array
*/ */
private $deferredIdentificationVariables = array(); private $deferredIdentificationVariables = [];
/** /**
* @var array * @var array
*/ */
private $deferredPartialObjectExpressions = array(); private $deferredPartialObjectExpressions = [];
/** /**
* @var array * @var array
*/ */
private $deferredPathExpressions = array(); private $deferredPathExpressions = [];
/** /**
* @var array * @var array
*/ */
private $deferredResultVariables = array(); private $deferredResultVariables = [];
/** /**
* @var array * @var array
*/ */
private $deferredNewObjectExpressions = array(); private $deferredNewObjectExpressions = [];
/** /**
* The lexer. * The lexer.
@ -142,7 +142,7 @@ class Parser
* *
* @var array * @var array
*/ */
private $queryComponents = array(); private $queryComponents = [];
/** /**
* Keeps the nesting level of defined ResultVariables. * Keeps the nesting level of defined ResultVariables.
@ -156,7 +156,7 @@ class Parser
* *
* @var array * @var array
*/ */
private $customTreeWalkers = array(); private $customTreeWalkers = [];
/** /**
* The custom last tree walker, if any, that is responsible for producing the output. * The custom last tree walker, if any, that is responsible for producing the output.
@ -168,7 +168,7 @@ class Parser
/** /**
* @var array * @var array
*/ */
private $identVariableExpressions = array(); private $identVariableExpressions = [];
/** /**
* Checks if a function is internally defined. Used to prevent overwriting * Checks if a function is internally defined. Used to prevent overwriting
@ -541,7 +541,7 @@ class Parser
*/ */
private function isMathOperator($token) 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) 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() 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)) { if ( ! ($expectedType & $fieldType)) {
// We need to recognize which was expected type(s) // We need to recognize which was expected type(s)
$expectedStringTypes = array(); $expectedStringTypes = [];
// Validate state field type // Validate state field type
if ($expectedType & AST\PathExpression::TYPE_STATE_FIELD) { if ($expectedType & AST\PathExpression::TYPE_STATE_FIELD) {
@ -929,11 +929,11 @@ class Parser
$identVariable = $this->lexer->token['value']; $identVariable = $this->lexer->token['value'];
$this->deferredIdentificationVariables[] = array( $this->deferredIdentificationVariables[] = [
'expression' => $identVariable, 'expression' => $identVariable,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $this->lexer->token, 'token' => $this->lexer->token,
); ];
return $identVariable; return $identVariable;
} }
@ -1028,11 +1028,11 @@ class Parser
$resultVariable = $this->lexer->token['value']; $resultVariable = $this->lexer->token['value'];
// Defer ResultVariable validation // Defer ResultVariable validation
$this->deferredResultVariables[] = array( $this->deferredResultVariables[] = [
'expression' => $resultVariable, 'expression' => $resultVariable,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $this->lexer->token, 'token' => $this->lexer->token,
); ];
return $resultVariable; return $resultVariable;
} }
@ -1100,11 +1100,11 @@ class Parser
$pathExpr = new AST\PathExpression($expectedTypes, $identVariable, $field); $pathExpr = new AST\PathExpression($expectedTypes, $identVariable, $field);
// Defer PathExpression validation if requested to be deferred // Defer PathExpression validation if requested to be deferred
$this->deferredPathExpressions[] = array( $this->deferredPathExpressions[] = [
'expression' => $pathExpr, 'expression' => $pathExpr,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $this->lexer->token, 'token' => $this->lexer->token,
); ];
return $pathExpr; return $pathExpr;
} }
@ -1183,7 +1183,7 @@ class Parser
} }
// Process SelectExpressions (1..N) // Process SelectExpressions (1..N)
$selectExpressions = array(); $selectExpressions = [];
$selectExpressions[] = $this->SelectExpression(); $selectExpressions[] = $this->SelectExpression();
while ($this->lexer->isNextToken(Lexer::T_COMMA)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
@ -1237,20 +1237,20 @@ class Parser
$class = $this->em->getClassMetadata($abstractSchemaName); $class = $this->em->getClassMetadata($abstractSchemaName);
// Building queryComponent // Building queryComponent
$queryComponent = array( $queryComponent = [
'metadata' => $class, 'metadata' => $class,
'parent' => null, 'parent' => null,
'relation' => null, 'relation' => null,
'map' => null, 'map' => null,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $token, 'token' => $token,
); ];
$this->queryComponents[$aliasIdentificationVariable] = $queryComponent; $this->queryComponents[$aliasIdentificationVariable] = $queryComponent;
$this->match(Lexer::T_SET); $this->match(Lexer::T_SET);
$updateItems = array(); $updateItems = [];
$updateItems[] = $this->UpdateItem(); $updateItems[] = $this->UpdateItem();
while ($this->lexer->isNextToken(Lexer::T_COMMA)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
@ -1295,14 +1295,14 @@ class Parser
$class = $this->em->getClassMetadata($deleteClause->abstractSchemaName); $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName);
// Building queryComponent // Building queryComponent
$queryComponent = array( $queryComponent = [
'metadata' => $class, 'metadata' => $class,
'parent' => null, 'parent' => null,
'relation' => null, 'relation' => null,
'map' => null, 'map' => null,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $token, 'token' => $token,
); ];
$this->queryComponents[$aliasIdentificationVariable] = $queryComponent; $this->queryComponents[$aliasIdentificationVariable] = $queryComponent;
@ -1318,7 +1318,7 @@ class Parser
{ {
$this->match(Lexer::T_FROM); $this->match(Lexer::T_FROM);
$identificationVariableDeclarations = array(); $identificationVariableDeclarations = [];
$identificationVariableDeclarations[] = $this->IdentificationVariableDeclaration(); $identificationVariableDeclarations[] = $this->IdentificationVariableDeclaration();
while ($this->lexer->isNextToken(Lexer::T_COMMA)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
@ -1339,7 +1339,7 @@ class Parser
{ {
$this->match(Lexer::T_FROM); $this->match(Lexer::T_FROM);
$identificationVariables = array(); $identificationVariables = [];
$identificationVariables[] = $this->SubselectIdentificationVariableDeclaration(); $identificationVariables[] = $this->SubselectIdentificationVariableDeclaration();
while ($this->lexer->isNextToken(Lexer::T_COMMA)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
@ -1385,7 +1385,7 @@ class Parser
$this->match(Lexer::T_GROUP); $this->match(Lexer::T_GROUP);
$this->match(Lexer::T_BY); $this->match(Lexer::T_BY);
$groupByItems = array($this->GroupByItem()); $groupByItems = [$this->GroupByItem()];
while ($this->lexer->isNextToken(Lexer::T_COMMA)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
$this->match(Lexer::T_COMMA); $this->match(Lexer::T_COMMA);
@ -1406,7 +1406,7 @@ class Parser
$this->match(Lexer::T_ORDER); $this->match(Lexer::T_ORDER);
$this->match(Lexer::T_BY); $this->match(Lexer::T_BY);
$orderByItems = array(); $orderByItems = [];
$orderByItems[] = $this->OrderByItem(); $orderByItems[] = $this->OrderByItem();
while ($this->lexer->isNextToken(Lexer::T_COMMA)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
@ -1583,7 +1583,7 @@ class Parser
*/ */
public function IdentificationVariableDeclaration() public function IdentificationVariableDeclaration()
{ {
$joins = array(); $joins = [];
$rangeVariableDeclaration = $this->RangeVariableDeclaration(); $rangeVariableDeclaration = $this->RangeVariableDeclaration();
$indexBy = $this->lexer->isNextToken(Lexer::T_INDEX) $indexBy = $this->lexer->isNextToken(Lexer::T_INDEX)
? $this->IndexBy() ? $this->IndexBy()
@ -1739,14 +1739,14 @@ class Parser
$classMetadata = $this->em->getClassMetadata($abstractSchemaName); $classMetadata = $this->em->getClassMetadata($abstractSchemaName);
// Building queryComponent // Building queryComponent
$queryComponent = array( $queryComponent = [
'metadata' => $classMetadata, 'metadata' => $classMetadata,
'parent' => null, 'parent' => null,
'relation' => null, 'relation' => null,
'map' => null, 'map' => null,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $token 'token' => $token
); ];
$this->queryComponents[$aliasIdentificationVariable] = $queryComponent; $this->queryComponents[$aliasIdentificationVariable] = $queryComponent;
@ -1776,14 +1776,14 @@ class Parser
$targetClass = $this->em->getClassMetadata($class->associationMappings[$field]['targetEntity']); $targetClass = $this->em->getClassMetadata($class->associationMappings[$field]['targetEntity']);
// Building queryComponent // Building queryComponent
$joinQueryComponent = array( $joinQueryComponent = [
'metadata' => $targetClass, 'metadata' => $targetClass,
'parent' => $joinAssociationPathExpression->identificationVariable, 'parent' => $joinAssociationPathExpression->identificationVariable,
'relation' => $class->getAssociationMapping($field), 'relation' => $class->getAssociationMapping($field),
'map' => null, 'map' => null,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $this->lexer->lookahead 'token' => $this->lexer->lookahead
); ];
$this->queryComponents[$aliasIdentificationVariable] = $joinQueryComponent; $this->queryComponents[$aliasIdentificationVariable] = $joinQueryComponent;
@ -1800,7 +1800,7 @@ class Parser
{ {
$this->match(Lexer::T_PARTIAL); $this->match(Lexer::T_PARTIAL);
$partialFieldSet = array(); $partialFieldSet = [];
$identificationVariable = $this->IdentificationVariable(); $identificationVariable = $this->IdentificationVariable();
@ -1839,11 +1839,11 @@ class Parser
$partialObjectExpression = new AST\PartialObjectExpression($identificationVariable, $partialFieldSet); $partialObjectExpression = new AST\PartialObjectExpression($identificationVariable, $partialFieldSet);
// Defer PartialObjectExpression validation // Defer PartialObjectExpression validation
$this->deferredPartialObjectExpressions[] = array( $this->deferredPartialObjectExpressions[] = [
'expression' => $partialObjectExpression, 'expression' => $partialObjectExpression,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $this->lexer->token, 'token' => $this->lexer->token,
); ];
return $partialObjectExpression; return $partialObjectExpression;
} }
@ -1875,11 +1875,11 @@ class Parser
$expression = new AST\NewObjectExpression($className, $args); $expression = new AST\NewObjectExpression($className, $args);
// Defer NewObjectExpression validation // Defer NewObjectExpression validation
$this->deferredNewObjectExpressions[] = array( $this->deferredNewObjectExpressions[] = [
'token' => $token, 'token' => $token,
'expression' => $expression, 'expression' => $expression,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
); ];
return $expression; return $expression;
} }
@ -2058,7 +2058,7 @@ class Parser
$this->match(Lexer::T_OPEN_PARENTHESIS); $this->match(Lexer::T_OPEN_PARENTHESIS);
// Process ScalarExpressions (1..N) // Process ScalarExpressions (1..N)
$scalarExpressions = array(); $scalarExpressions = [];
$scalarExpressions[] = $this->ScalarExpression(); $scalarExpressions[] = $this->ScalarExpression();
while ($this->lexer->isNextToken(Lexer::T_COMMA)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
@ -2101,7 +2101,7 @@ class Parser
$this->match(Lexer::T_CASE); $this->match(Lexer::T_CASE);
// Process WhenClause (1..N) // Process WhenClause (1..N)
$whenClauses = array(); $whenClauses = [];
do { do {
$whenClauses[] = $this->WhenClause(); $whenClauses[] = $this->WhenClause();
@ -2126,7 +2126,7 @@ class Parser
$caseOperand = $this->StateFieldPathExpression(); $caseOperand = $this->StateFieldPathExpression();
// Process SimpleWhenClause (1..N) // Process SimpleWhenClause (1..N)
$simpleWhenClauses = array(); $simpleWhenClauses = [];
do { do {
$simpleWhenClauses[] = $this->SimpleWhenClause(); $simpleWhenClauses[] = $this->SimpleWhenClause();
@ -2283,11 +2283,11 @@ class Parser
$aliasResultVariable = $this->AliasResultVariable(); $aliasResultVariable = $this->AliasResultVariable();
// Include AliasResultVariable in query components. // Include AliasResultVariable in query components.
$this->queryComponents[$aliasResultVariable] = array( $this->queryComponents[$aliasResultVariable] = [
'resultVariable' => $expression, 'resultVariable' => $expression,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $token, 'token' => $token,
); ];
} }
// AST // AST
@ -2377,11 +2377,11 @@ class Parser
$expr->fieldIdentificationVariable = $resultVariable; $expr->fieldIdentificationVariable = $resultVariable;
// Include AliasResultVariable in query components. // Include AliasResultVariable in query components.
$this->queryComponents[$resultVariable] = array( $this->queryComponents[$resultVariable] = [
'resultvariable' => $expr, 'resultvariable' => $expr,
'nestingLevel' => $this->nestingLevel, 'nestingLevel' => $this->nestingLevel,
'token' => $token, 'token' => $token,
); ];
} }
return $expr; return $expr;
@ -2394,7 +2394,7 @@ class Parser
*/ */
public function ConditionalExpression() public function ConditionalExpression()
{ {
$conditionalTerms = array(); $conditionalTerms = [];
$conditionalTerms[] = $this->ConditionalTerm(); $conditionalTerms[] = $this->ConditionalTerm();
while ($this->lexer->isNextToken(Lexer::T_OR)) { while ($this->lexer->isNextToken(Lexer::T_OR)) {
@ -2419,7 +2419,7 @@ class Parser
*/ */
public function ConditionalTerm() public function ConditionalTerm()
{ {
$conditionalFactors = array(); $conditionalFactors = [];
$conditionalFactors[] = $this->ConditionalFactor(); $conditionalFactors[] = $this->ConditionalFactor();
while ($this->lexer->isNextToken(Lexer::T_AND)) { while ($this->lexer->isNextToken(Lexer::T_AND)) {
@ -2484,8 +2484,8 @@ class Parser
// Peek beyond the matching closing parenthesis ')' // Peek beyond the matching closing parenthesis ')'
$peek = $this->peekBeyondClosingParenthesis(); $peek = $this->peekBeyondClosingParenthesis();
if (in_array($peek['value'], array("=", "<", "<=", "<>", ">", ">=", "!=")) || if (in_array($peek['value'], ["=", "<", "<=", "<>", ">", ">=", "!="]) ||
in_array($peek['type'], array(Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_IN, Lexer::T_IS, Lexer::T_EXISTS)) || 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)) { $this->isMathOperator($peek)) {
$condPrimary->simpleConditionalExpression = $this->SimpleConditionalExpression(); $condPrimary->simpleConditionalExpression = $this->SimpleConditionalExpression();
@ -2741,7 +2741,7 @@ class Parser
*/ */
public function SimpleArithmeticExpression() public function SimpleArithmeticExpression()
{ {
$terms = array(); $terms = [];
$terms[] = $this->ArithmeticTerm(); $terms[] = $this->ArithmeticTerm();
while (($isPlus = $this->lexer->isNextToken(Lexer::T_PLUS)) || $this->lexer->isNextToken(Lexer::T_MINUS)) { while (($isPlus = $this->lexer->isNextToken(Lexer::T_PLUS)) || $this->lexer->isNextToken(Lexer::T_MINUS)) {
@ -2767,7 +2767,7 @@ class Parser
*/ */
public function ArithmeticTerm() public function ArithmeticTerm()
{ {
$factors = array(); $factors = [];
$factors[] = $this->ArithmeticFactor(); $factors[] = $this->ArithmeticFactor();
while (($isMult = $this->lexer->isNextToken(Lexer::T_MULTIPLY)) || $this->lexer->isNextToken(Lexer::T_DIVIDE)) { 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']; $lookaheadType = $this->lexer->lookahead['type'];
$isDistinct = false; $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'); $this->syntaxError('One of: MAX, MIN, AVG, SUM, COUNT');
} }
@ -3018,7 +3018,7 @@ class Parser
$lookaheadType = $this->lexer->lookahead['type']; $lookaheadType = $this->lexer->lookahead['type'];
$value = $this->lexer->lookahead['value']; $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'); $this->syntaxError('ALL, ANY or SOME');
} }
@ -3097,7 +3097,7 @@ class Parser
if ($this->lexer->isNextToken(Lexer::T_SELECT)) { if ($this->lexer->isNextToken(Lexer::T_SELECT)) {
$inExpression->subselect = $this->Subselect(); $inExpression->subselect = $this->Subselect();
} else { } else {
$literals = array(); $literals = [];
$literals[] = $this->InParameter(); $literals[] = $this->InParameter();
while ($this->lexer->isNextToken(Lexer::T_COMMA)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
@ -3130,7 +3130,7 @@ class Parser
$this->match(Lexer::T_INSTANCE); $this->match(Lexer::T_INSTANCE);
$this->match(Lexer::T_OF); $this->match(Lexer::T_OF);
$exprValues = array(); $exprValues = [];
if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
$this->match(Lexer::T_OPEN_PARENTHESIS); $this->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -51,7 +51,7 @@ class ParserResult
* *
* @var array * @var array
*/ */
private $_parameterMappings = array(); private $_parameterMappings = [];
/** /**
* Initializes a new instance of the <tt>ParserResult</tt> class. * Initializes a new instance of the <tt>ParserResult</tt> class.

View File

@ -37,12 +37,12 @@ class QueryExpressionVisitor extends ExpressionVisitor
/** /**
* @var array * @var array
*/ */
private static $operatorMap = array( private static $operatorMap = [
Comparison::GT => Expr\Comparison::GT, Comparison::GT => Expr\Comparison::GT,
Comparison::GTE => Expr\Comparison::GTE, Comparison::GTE => Expr\Comparison::GTE,
Comparison::LT => Expr\Comparison::LT, Comparison::LT => Expr\Comparison::LT,
Comparison::LTE => Expr\Comparison::LTE Comparison::LTE => Expr\Comparison::LTE
); ];
/** /**
* @var array * @var array
@ -57,7 +57,7 @@ class QueryExpressionVisitor extends ExpressionVisitor
/** /**
* @var array * @var array
*/ */
private $parameters = array(); private $parameters = [];
/** /**
* Constructor * Constructor
@ -88,7 +88,7 @@ class QueryExpressionVisitor extends ExpressionVisitor
*/ */
public function clearParameters() public function clearParameters()
{ {
$this->parameters = array(); $this->parameters = [];
} }
/** /**
@ -108,7 +108,7 @@ class QueryExpressionVisitor extends ExpressionVisitor
*/ */
public function walkCompositeExpression(CompositeExpression $expr) public function walkCompositeExpression(CompositeExpression $expr)
{ {
$expressionList = array(); $expressionList = [];
foreach ($expr->getExpressionList() as $child) { foreach ($expr->getExpressionList() as $child) {
$expressionList[] = $this->dispatch($child); $expressionList[] = $this->dispatch($child);

View File

@ -57,7 +57,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $aliasMap = array(); public $aliasMap = [];
/** /**
* Maps alias names to related association field names. * Maps alias names to related association field names.
@ -65,7 +65,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $relationMap = array(); public $relationMap = [];
/** /**
* Maps alias names to parent alias names. * Maps alias names to parent alias names.
@ -73,7 +73,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $parentAliasMap = array(); public $parentAliasMap = [];
/** /**
* Maps column names in the result set to field names for each class. * Maps column names in the result set to field names for each class.
@ -81,7 +81,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @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. * 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 * @ignore
* @var array * @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. * 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 * @ignore
* @var array * @var array
*/ */
public $typeMappings = array(); public $typeMappings = [];
/** /**
* Maps entities in the result set to the alias name to use in the mapped result. * Maps entities in the result set to the alias name to use in the mapped result.
@ -105,7 +105,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $entityMappings = array(); public $entityMappings = [];
/** /**
* Maps column names of meta columns (foreign keys, discriminator columns, ...) to field names. * Maps column names of meta columns (foreign keys, discriminator columns, ...) to field names.
@ -113,7 +113,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $metaMappings = array(); public $metaMappings = [];
/** /**
* Maps column names in the result set to the alias they belong to. * Maps column names in the result set to the alias they belong to.
@ -121,7 +121,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $columnOwnerMap = array(); public $columnOwnerMap = [];
/** /**
* List of columns in the result set that are used as discriminator columns. * List of columns in the result set that are used as discriminator columns.
@ -129,7 +129,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $discriminatorColumns = array(); public $discriminatorColumns = [];
/** /**
* Maps alias names to field names that should be used for indexing. * Maps alias names to field names that should be used for indexing.
@ -137,7 +137,7 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $indexByMap = array(); public $indexByMap = [];
/** /**
* Map from column names to class names that declare the field the column is mapped to. * Map from column names to class names that declare the field the column is mapped to.
@ -145,28 +145,28 @@ class ResultSetMapping
* @ignore * @ignore
* @var array * @var array
*/ */
public $declaringClasses = array(); public $declaringClasses = [];
/** /**
* This is necessary to hydrate derivate foreign keys correctly. * This is necessary to hydrate derivate foreign keys correctly.
* *
* @var array * @var array
*/ */
public $isIdentifierColumn = array(); public $isIdentifierColumn = [];
/** /**
* Maps column names in the result set to field names for each new object expression. * Maps column names in the result set to field names for each new object expression.
* *
* @var array * @var array
*/ */
public $newObjectMappings = array(); public $newObjectMappings = [];
/** /**
* Maps metadata parameter names to the metadata attribute. * Maps metadata parameter names to the metadata attribute.
* *
* @var array * @var array
*/ */
public $metadataParameterMapping = array(); public $metadataParameterMapping = [];
/** /**
* Adds an entity result to this ResultSetMapping. * Adds an entity result to this ResultSetMapping.

View File

@ -97,7 +97,7 @@ class ResultSetMappingBuilder extends ResultSetMapping
* *
* @return void * @return void
*/ */
public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = array(), $renameMode = null) public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = [], $renameMode = null)
{ {
$renameMode = $renameMode ?: $this->defaultRenameMode; $renameMode = $renameMode ?: $this->defaultRenameMode;
$columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns);
@ -119,7 +119,7 @@ class ResultSetMappingBuilder extends ResultSetMapping
* *
* @return void * @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; $renameMode = $renameMode ?: $this->defaultRenameMode;
$columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns);
@ -139,7 +139,7 @@ class ResultSetMappingBuilder extends ResultSetMapping
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
protected function addAllClassFields($class, $alias, $columnAliasMap = array()) protected function addAllClassFields($class, $alias, $columnAliasMap = [])
{ {
$classMetadata = $this->em->getClassMetadata($class); $classMetadata = $this->em->getClassMetadata($class);
$platform = $this->em->getConnection()->getDatabasePlatform(); $platform = $this->em->getConnection()->getDatabasePlatform();
@ -232,7 +232,7 @@ class ResultSetMappingBuilder extends ResultSetMapping
$mode = self::COLUMN_RENAMING_CUSTOM; $mode = self::COLUMN_RENAMING_CUSTOM;
} }
$columnAlias = array(); $columnAlias = [];
$class = $this->em->getClassMetadata($className); $class = $this->em->getClassMetadata($className);
foreach ($class->getColumnNames() as $columnName) { foreach ($class->getColumnNames() as $columnName) {
@ -436,7 +436,7 @@ class ResultSetMappingBuilder extends ResultSetMapping
* *
* @return string * @return string
*/ */
public function generateSelectClause($tableAliases = array()) public function generateSelectClause($tableAliases = [])
{ {
$sql = ""; $sql = "";
@ -470,6 +470,6 @@ class ResultSetMappingBuilder extends ResultSetMapping
*/ */
public function __toString() public function __toString()
{ {
return $this->generateSelectClause(array()); return $this->generateSelectClause([]);
} }
} }

View File

@ -109,28 +109,28 @@ class SqlWalker implements TreeWalker
/** /**
* @var array * @var array
*/ */
private $tableAliasMap = array(); private $tableAliasMap = [];
/** /**
* Map from result variable names to their SQL column alias names. * Map from result variable names to their SQL column alias names.
* *
* @var array * @var array
*/ */
private $scalarResultAliasMap = array(); private $scalarResultAliasMap = [];
/** /**
* Map from Table-Alias + Column-Name to OrderBy-Direction. * Map from Table-Alias + Column-Name to OrderBy-Direction.
* *
* @var array * @var array
*/ */
private $orderedColumnsMap = array(); private $orderedColumnsMap = [];
/** /**
* Map from DQL-Alias + Field-Name to SQL Column Alias. * Map from DQL-Alias + Field-Name to SQL Column Alias.
* *
* @var array * @var array
*/ */
private $scalarFields = array(); private $scalarFields = [];
/** /**
* Map of all components/classes that appear in the DQL query. * Map of all components/classes that appear in the DQL query.
@ -144,14 +144,14 @@ class SqlWalker implements TreeWalker
* *
* @var array * @var array
*/ */
private $selectedClasses = array(); private $selectedClasses = [];
/** /**
* The DQL alias of the root class of the currently traversed query. * The DQL alias of the root class of the currently traversed query.
* *
* @var array * @var array
*/ */
private $rootAliases = array(); private $rootAliases = [];
/** /**
* Flag that indicates whether to generate SQL table aliases in the SQL. * 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) 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))) { if (array_diff($requiredKeys, array_keys($queryComponent))) {
throw QueryException::invalidQueryComponent($dqlAlias); throw QueryException::invalidQueryComponent($dqlAlias);
@ -354,7 +354,7 @@ class SqlWalker implements TreeWalker
$sql .= isset($this->queryComponents[$dqlAlias]['relation']) ? ' LEFT ' : ' INNER '; $sql .= isset($this->queryComponents[$dqlAlias]['relation']) ? ' LEFT ' : ' INNER ';
$sql .= 'JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; $sql .= 'JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON ';
$sqlParts = array(); $sqlParts = [];
foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) { foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) {
$sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $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 '; $sql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON ';
$sqlParts = array(); $sqlParts = [];
foreach ($this->quoteStrategy->getIdentifierColumnNames($subClass, $this->platform) as $columnName) { foreach ($this->quoteStrategy->getIdentifierColumnNames($subClass, $this->platform) as $columnName) {
$sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName; $sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName;
@ -397,7 +397,7 @@ class SqlWalker implements TreeWalker
*/ */
private function _generateOrderedCollectionOrderByItems() private function _generateOrderedCollectionOrderByItems()
{ {
$orderedColumns = array(); $orderedColumns = [];
foreach ($this->selectedClasses as $selectedClass) { foreach ($this->selectedClasses as $selectedClass) {
$dqlAlias = $selectedClass['dqlAlias']; $dqlAlias = $selectedClass['dqlAlias'];
@ -439,7 +439,7 @@ class SqlWalker implements TreeWalker
*/ */
private function _generateDiscriminatorColumnConditionSQL(array $dqlAliases) private function _generateDiscriminatorColumnConditionSQL(array $dqlAliases)
{ {
$sqlParts = array(); $sqlParts = [];
foreach ($dqlAliases as $dqlAlias) { foreach ($dqlAliases as $dqlAlias) {
$class = $this->queryComponents[$dqlAlias]['metadata']; $class = $this->queryComponents[$dqlAlias]['metadata'];
@ -447,7 +447,7 @@ class SqlWalker implements TreeWalker
if ( ! $class->isInheritanceTypeSingleTable()) continue; if ( ! $class->isInheritanceTypeSingleTable()) continue;
$conn = $this->em->getConnection(); $conn = $this->em->getConnection();
$values = array(); $values = [];
if ($class->discriminatorValue !== null) { // discriminators can be 0 if ($class->discriminatorValue !== null) { // discriminators can be 0
$values[] = $conn->quote($class->discriminatorValue); $values[] = $conn->quote($class->discriminatorValue);
@ -503,7 +503,7 @@ class SqlWalker implements TreeWalker
return ''; return '';
} }
$filterClauses = array(); $filterClauses = [];
foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { foreach ($this->em->getFilters()->getEnabledFilters() as $filter) {
if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
$filterClauses[] = '(' . $filterExpr . ')'; $filterClauses[] = '(' . $filterExpr . ')';
@ -606,7 +606,7 @@ class SqlWalker implements TreeWalker
{ {
$class = $this->queryComponents[$identVariable]['metadata']; $class = $this->queryComponents[$identVariable]['metadata'];
$tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable); $tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable);
$sqlParts = array(); $sqlParts = [];
foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) { foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) {
$sqlParts[] = $tableAlias . '.' . $columnName; $sqlParts[] = $tableAlias . '.' . $columnName;
@ -699,7 +699,7 @@ class SqlWalker implements TreeWalker
public function walkSelectClause($selectClause) public function walkSelectClause($selectClause)
{ {
$sql = 'SELECT ' . (($selectClause->isDistinct) ? 'DISTINCT ' : ''); $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) { if ($this->query->getHint(Query::HINT_INTERNAL_ITERATION) == true && $selectClause->isDistinct) {
$this->query->setHint(self::HINT_DISTINCT, true); $this->query->setHint(self::HINT_DISTINCT, true);
@ -812,7 +812,7 @@ class SqlWalker implements TreeWalker
public function walkFromClause($fromClause) public function walkFromClause($fromClause)
{ {
$identificationVarDecls = $fromClause->identificationVariableDeclarations; $identificationVarDecls = $fromClause->identificationVariableDeclarations;
$sqlParts = array(); $sqlParts = [];
foreach ($identificationVarDecls as $identificationVariableDecl) { foreach ($identificationVarDecls as $identificationVariableDecl) {
$sqlParts[] = $this->walkIdentificationVariableDeclaration($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. // The owning side is necessary at this point because only it contains the JoinColumn information.
switch (true) { switch (true) {
case ($assoc['type'] & ClassMetadata::TO_ONE): case ($assoc['type'] & ClassMetadata::TO_ONE):
$conditions = array(); $conditions = [];
foreach ($assoc['joinColumns'] as $joinColumn) { foreach ($assoc['joinColumns'] as $joinColumn) {
$quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform);
@ -953,7 +953,7 @@ class SqlWalker implements TreeWalker
} }
// Apply remaining inheritance restrictions // Apply remaining inheritance restrictions
$discrSql = $this->_generateDiscriminatorColumnConditionSQL(array($joinedDqlAlias)); $discrSql = $this->_generateDiscriminatorColumnConditionSQL([$joinedDqlAlias]);
if ($discrSql) { if ($discrSql) {
$conditions[] = $discrSql; $conditions[] = $discrSql;
@ -966,10 +966,10 @@ class SqlWalker implements TreeWalker
$conditions[] = $filterExpr; $conditions[] = $filterExpr;
} }
$targetTableJoin = array( $targetTableJoin = [
'table' => $targetTableName . ' ' . $targetTableAlias, 'table' => $targetTableName . ' ' . $targetTableAlias,
'condition' => implode(' AND ', $conditions), 'condition' => implode(' AND ', $conditions),
); ];
break; break;
case ($assoc['type'] == ClassMetadata::MANY_TO_MANY): case ($assoc['type'] == ClassMetadata::MANY_TO_MANY):
@ -978,7 +978,7 @@ class SqlWalker implements TreeWalker
$joinTableAlias = $this->getSQLTableAlias($joinTable['name'], $joinedDqlAlias); $joinTableAlias = $this->getSQLTableAlias($joinTable['name'], $joinedDqlAlias);
$joinTableName = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->platform); $joinTableName = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->platform);
$conditions = array(); $conditions = [];
$relationColumns = ($relation['isOwningSide']) $relationColumns = ($relation['isOwningSide'])
? $assoc['joinTable']['joinColumns'] ? $assoc['joinTable']['joinColumns']
: $assoc['joinTable']['inverseJoinColumns']; : $assoc['joinTable']['inverseJoinColumns'];
@ -995,7 +995,7 @@ class SqlWalker implements TreeWalker
// Join target table // Join target table
$sql .= ($joinType == AST\Join::JOIN_TYPE_LEFT || $joinType == AST\Join::JOIN_TYPE_LEFTOUTER) ? ' LEFT JOIN ' : ' INNER JOIN '; $sql .= ($joinType == AST\Join::JOIN_TYPE_LEFT || $joinType == AST\Join::JOIN_TYPE_LEFTOUTER) ? ' LEFT JOIN ' : ' INNER JOIN ';
$conditions = array(); $conditions = [];
$relationColumns = ($relation['isOwningSide']) $relationColumns = ($relation['isOwningSide'])
? $assoc['joinTable']['inverseJoinColumns'] ? $assoc['joinTable']['inverseJoinColumns']
: $assoc['joinTable']['joinColumns']; : $assoc['joinTable']['joinColumns'];
@ -1008,7 +1008,7 @@ class SqlWalker implements TreeWalker
} }
// Apply remaining inheritance restrictions // Apply remaining inheritance restrictions
$discrSql = $this->_generateDiscriminatorColumnConditionSQL(array($joinedDqlAlias)); $discrSql = $this->_generateDiscriminatorColumnConditionSQL([$joinedDqlAlias]);
if ($discrSql) { if ($discrSql) {
$conditions[] = $discrSql; $conditions[] = $discrSql;
@ -1021,10 +1021,10 @@ class SqlWalker implements TreeWalker
$conditions[] = $filterExpr; $conditions[] = $filterExpr;
} }
$targetTableJoin = array( $targetTableJoin = [
'table' => $targetTableName . ' ' . $targetTableAlias, 'table' => $targetTableName . ' ' . $targetTableAlias,
'condition' => implode(' AND ', $conditions), 'condition' => implode(' AND ', $conditions),
); ];
break; break;
default: default:
@ -1074,7 +1074,7 @@ class SqlWalker implements TreeWalker
*/ */
public function walkOrderByClause($orderByClause) public function walkOrderByClause($orderByClause)
{ {
$orderByItems = array_map(array($this, 'walkOrderByItem'), $orderByClause->orderByItems); $orderByItems = array_map([$this, 'walkOrderByItem'], $orderByClause->orderByItems);
if (($collectionOrderByItems = $this->_generateOrderedCollectionOrderByItems()) !== '') { if (($collectionOrderByItems = $this->_generateOrderedCollectionOrderByItems()) !== '') {
$orderByItems = array_merge($orderByItems, (array) $collectionOrderByItems); $orderByItems = array_merge($orderByItems, (array) $collectionOrderByItems);
@ -1141,7 +1141,7 @@ class SqlWalker implements TreeWalker
$sql .= $this->walkRangeVariableDeclaration($joinDeclaration); $sql .= $this->walkRangeVariableDeclaration($joinDeclaration);
// Apply remaining inheritance restrictions // Apply remaining inheritance restrictions
$discrSql = $this->_generateDiscriminatorColumnConditionSQL(array($dqlAlias)); $discrSql = $this->_generateDiscriminatorColumnConditionSQL([$dqlAlias]);
if ($discrSql) { if ($discrSql) {
$conditions[] = $discrSql; $conditions[] = $discrSql;
@ -1206,7 +1206,7 @@ class SqlWalker implements TreeWalker
{ {
$sql = 'COALESCE('; $sql = 'COALESCE(';
$scalarExpressions = array(); $scalarExpressions = [];
foreach ($coalesceExpression->scalarExpressions as $scalarExpression) { foreach ($coalesceExpression->scalarExpressions as $scalarExpression) {
$scalarExpressions[] = $this->walkSimpleArithmeticExpression($scalarExpression); $scalarExpressions[] = $this->walkSimpleArithmeticExpression($scalarExpression);
@ -1375,7 +1375,7 @@ class SqlWalker implements TreeWalker
$partialFieldSet = $expr->partialFieldSet; $partialFieldSet = $expr->partialFieldSet;
} else { } else {
$dqlAlias = $expr; $dqlAlias = $expr;
$partialFieldSet = array(); $partialFieldSet = [];
} }
$queryComp = $this->queryComponents[$dqlAlias]; $queryComp = $this->queryComponents[$dqlAlias];
@ -1383,14 +1383,14 @@ class SqlWalker implements TreeWalker
$resultAlias = $selectExpression->fieldIdentificationVariable ?: null; $resultAlias = $selectExpression->fieldIdentificationVariable ?: null;
if ( ! isset($this->selectedClasses[$dqlAlias])) { if ( ! isset($this->selectedClasses[$dqlAlias])) {
$this->selectedClasses[$dqlAlias] = array( $this->selectedClasses[$dqlAlias] = [
'class' => $class, 'class' => $class,
'dqlAlias' => $dqlAlias, 'dqlAlias' => $dqlAlias,
'resultAlias' => $resultAlias 'resultAlias' => $resultAlias
); ];
} }
$sqlParts = array(); $sqlParts = [];
// Select all fields from the queried class // Select all fields from the queried class
foreach ($class->fieldMappings as $fieldName => $mapping) { foreach ($class->fieldMappings as $fieldName => $mapping) {
@ -1475,7 +1475,7 @@ class SqlWalker implements TreeWalker
$useAliasesBefore = $this->useSqlTableAliases; $useAliasesBefore = $this->useSqlTableAliases;
$rootAliasesBefore = $this->rootAliases; $rootAliasesBefore = $this->rootAliases;
$this->rootAliases = array(); // reset the rootAliases for the subselect $this->rootAliases = []; // reset the rootAliases for the subselect
$this->useSqlTableAliases = true; $this->useSqlTableAliases = true;
$sql = $this->walkSimpleSelectClause($subselect->simpleSelectClause); $sql = $this->walkSimpleSelectClause($subselect->simpleSelectClause);
@ -1498,7 +1498,7 @@ class SqlWalker implements TreeWalker
public function walkSubselectFromClause($subselectFromClause) public function walkSubselectFromClause($subselectFromClause)
{ {
$identificationVarDecls = $subselectFromClause->identificationVariableDeclarations; $identificationVarDecls = $subselectFromClause->identificationVariableDeclarations;
$sqlParts = array (); $sqlParts = [];
foreach ($identificationVarDecls as $subselectIdVarDecl) { foreach ($identificationVarDecls as $subselectIdVarDecl) {
$sqlParts[] = $this->walkIdentificationVariableDeclaration($subselectIdVarDecl); $sqlParts[] = $this->walkIdentificationVariableDeclaration($subselectIdVarDecl);
@ -1533,7 +1533,7 @@ class SqlWalker implements TreeWalker
*/ */
public function walkNewObject($newObjectExpression, $newObjectResultAlias=null) public function walkNewObject($newObjectExpression, $newObjectResultAlias=null)
{ {
$sqlSelectExpressions = array(); $sqlSelectExpressions = [];
$objIndex = $newObjectResultAlias?:$this->newObjectCounter++; $objIndex = $newObjectResultAlias?:$this->newObjectCounter++;
foreach ($newObjectExpression->args as $argIndex => $e) { foreach ($newObjectExpression->args as $argIndex => $e) {
@ -1581,11 +1581,11 @@ class SqlWalker implements TreeWalker
$this->scalarResultAliasMap[$resultAlias] = $columnAlias; $this->scalarResultAliasMap[$resultAlias] = $columnAlias;
$this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldType); $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldType);
$this->rsm->newObjectMappings[$columnAlias] = array( $this->rsm->newObjectMappings[$columnAlias] = [
'className' => $newObjectExpression->className, 'className' => $newObjectExpression->className,
'objIndex' => $objIndex, 'objIndex' => $objIndex,
'argIndex' => $argIndex 'argIndex' => $argIndex
); ];
} }
return implode(', ', $sqlSelectExpressions); return implode(', ', $sqlSelectExpressions);
@ -1662,7 +1662,7 @@ class SqlWalker implements TreeWalker
*/ */
public function walkGroupByClause($groupByClause) public function walkGroupByClause($groupByClause)
{ {
$sqlParts = array(); $sqlParts = [];
foreach ($groupByClause->groupByItems as $groupByItem) { foreach ($groupByClause->groupByItems as $groupByItem) {
$sqlParts[] = $this->walkGroupByItem($groupByItem); $sqlParts[] = $this->walkGroupByItem($groupByItem);
@ -1697,7 +1697,7 @@ class SqlWalker implements TreeWalker
} }
// IdentificationVariable // IdentificationVariable
$sqlParts = array(); $sqlParts = [];
foreach ($this->queryComponents[$groupByItem]['metadata']->fieldNames as $field) { foreach ($this->queryComponents[$groupByItem]['metadata']->fieldNames as $field) {
$item = new AST\PathExpression(AST\PathExpression::TYPE_STATE_FIELD, $groupByItem, $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->setSQLTableAlias($tableName, $tableName, $updateClause->aliasIdentificationVariable);
$this->rootAliases[] = $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; return $sql;
} }
@ -1789,7 +1789,7 @@ class SqlWalker implements TreeWalker
$discrSql = $this->_generateDiscriminatorColumnConditionSql($this->rootAliases); $discrSql = $this->_generateDiscriminatorColumnConditionSql($this->rootAliases);
if ($this->em->hasFilters()) { if ($this->em->hasFilters()) {
$filterClauses = array(); $filterClauses = [];
foreach ($this->rootAliases as $dqlAlias) { foreach ($this->rootAliases as $dqlAlias) {
$class = $this->queryComponents[$dqlAlias]['metadata']; $class = $this->queryComponents[$dqlAlias]['metadata'];
$tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias); $tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias);
@ -1830,7 +1830,7 @@ class SqlWalker implements TreeWalker
return $this->walkConditionalTerm($condExpr); 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 $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 '; $sql .= $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' WHERE ';
$owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']]; $owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']];
$sqlParts = array(); $sqlParts = [];
foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) { foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $this->platform); $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $this->platform);
@ -1963,7 +1963,7 @@ class SqlWalker implements TreeWalker
// join conditions // join conditions
$joinColumns = $assoc['isOwningSide'] ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns']; $joinColumns = $assoc['isOwningSide'] ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns'];
$joinSqlParts = array(); $joinSqlParts = [];
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($targetClass->fieldNames[$joinColumn['referencedColumnName']], $targetClass, $this->platform); $targetColumn = $this->quoteStrategy->getColumnName($targetClass->fieldNames[$joinColumn['referencedColumnName']], $targetClass, $this->platform);
@ -1975,7 +1975,7 @@ class SqlWalker implements TreeWalker
$sql .= ' WHERE '; $sql .= ' WHERE ';
$joinColumns = $assoc['isOwningSide'] ? $joinTable['joinColumns'] : $joinTable['inverseJoinColumns']; $joinColumns = $assoc['isOwningSide'] ? $joinTable['joinColumns'] : $joinTable['inverseJoinColumns'];
$sqlParts = array(); $sqlParts = [];
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$joinColumn['referencedColumnName']], $class, $this->platform); $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$joinColumn['referencedColumnName']], $class, $this->platform);
@ -2038,7 +2038,7 @@ class SqlWalker implements TreeWalker
$sql .= ($inExpr->subselect) $sql .= ($inExpr->subselect)
? $this->walkSubselect($inExpr->subselect) ? $this->walkSubselect($inExpr->subselect)
: implode(', ', array_map(array($this, 'walkInParameter'), $inExpr->literals)); : implode(', ', array_map([$this, 'walkInParameter'], $inExpr->literals));
$sql .= ')'; $sql .= ')';
@ -2065,7 +2065,7 @@ class SqlWalker implements TreeWalker
$sql .= $class->discriminatorColumn['name'] . ($instanceOfExpr->not ? ' NOT IN ' : ' IN '); $sql .= $class->discriminatorColumn['name'] . ($instanceOfExpr->not ? ' NOT IN ' : ' IN ');
$sqlParameterList = array(); $sqlParameterList = [];
foreach ($instanceOfExpr->value as $parameter) { foreach ($instanceOfExpr->value as $parameter) {
if ($parameter instanceof AST\InputParameter) { if ($parameter instanceof AST\InputParameter) {
@ -2239,7 +2239,7 @@ class SqlWalker implements TreeWalker
return $this->walkArithmeticTerm($simpleArithmeticExpr); 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 $this->walkArithmeticFactor($term);
} }
return implode(' ', array_map(array($this, 'walkArithmeticFactor'), $term->arithmeticFactors)); return implode(' ', array_map([$this, 'walkArithmeticFactor'], $term->arithmeticFactors));
} }
/** /**

View File

@ -72,7 +72,7 @@ abstract class TreeWalkerAdapter implements TreeWalker
*/ */
public function setQueryComponent($dqlAlias, array $queryComponent) 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))) { if (array_diff($requiredKeys, array_keys($queryComponent))) {
throw QueryException::invalidQueryComponent($dqlAlias); throw QueryException::invalidQueryComponent($dqlAlias);

View File

@ -72,7 +72,7 @@ class TreeWalkerChain implements TreeWalker
*/ */
public function setQueryComponent($dqlAlias, array $queryComponent) 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))) { if (array_diff($requiredKeys, array_keys($queryComponent))) {
throw QueryException::invalidQueryComponent($dqlAlias); throw QueryException::invalidQueryComponent($dqlAlias);

Some files were not shown because too many files have changed in this diff Show More