From 6dcb97a20ea1cba2ae55890253be390c058d4c2c Mon Sep 17 00:00:00 2001 From: Jeroen Thora Date: Fri, 19 Dec 2014 22:27:26 +0100 Subject: [PATCH] Fixed many small phpcs issues --- lib/Doctrine/ORM/AbstractQuery.php | 7 +- .../ORM/Cache/AssociationCacheEntry.php | 6 +- lib/Doctrine/ORM/Cache/CacheException.php | 3 +- .../ORM/Cache/CollectionCacheEntry.php | 2 +- lib/Doctrine/ORM/Cache/EntityCacheEntry.php | 2 + .../Entity/AbstractEntityPersister.php | 6 +- .../Entity/CachedEntityPersister.php | 5 +- lib/Doctrine/ORM/Cache/QueryCacheEntry.php | 4 +- .../ORM/Cache/Region/FileLockRegion.php | 22 +-- .../ORM/Cache/TimestampCacheEntry.php | 4 +- lib/Doctrine/ORM/Configuration.php | 2 +- lib/Doctrine/ORM/EntityManager.php | 10 +- lib/Doctrine/ORM/EntityRepository.php | 2 +- lib/Doctrine/ORM/Event/ListenersInvoker.php | 22 +-- lib/Doctrine/ORM/Id/IdentityGenerator.php | 2 +- lib/Doctrine/ORM/Id/SequenceGenerator.php | 2 +- lib/Doctrine/ORM/Id/UuidGenerator.php | 1 + .../Internal/Hydration/HydrationException.php | 4 +- .../ORM/Internal/Hydration/IterableResult.php | 1 + lib/Doctrine/ORM/LazyCriteriaCollection.php | 3 +- .../Mapping/Builder/AssociationBuilder.php | 13 ++ .../ORM/Mapping/Builder/FieldBuilder.php | 18 ++- .../Builder/ManyToManyAssociationBuilder.php | 3 + .../Builder/OneToManyAssociationBuilder.php | 3 + .../ORM/Mapping/ClassMetadataFactory.php | 1 + .../ORM/Mapping/ClassMetadataInfo.php | 18 ++- .../ORM/Mapping/DefaultNamingStrategy.php | 8 +- .../ORM/Mapping/Driver/AnnotationDriver.php | 4 +- .../ORM/Mapping/Driver/DatabaseDriver.php | 7 +- lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 133 +++++++++--------- .../ORM/Mapping/Driver/YamlDriver.php | 24 ++-- .../ORM/Mapping/EntityListenerResolver.php | 14 +- lib/Doctrine/ORM/Mapping/MappingException.php | 9 +- .../ORM/ORMInvalidArgumentException.php | 26 ++-- lib/Doctrine/ORM/OptimisticLockException.php | 3 +- .../Entity/BasicEntityPersister.php | 1 + .../ORM/Persisters/Entity/EntityPersister.php | 9 +- .../Entity/JoinedSubclassPersister.php | 3 +- lib/Doctrine/ORM/Query.php | 2 +- .../ORM/Query/AST/ComparisonExpression.php | 4 +- .../Query/AST/Functions/BitAndFunction.php | 3 +- .../ORM/Query/AST/Functions/BitOrFunction.php | 3 +- .../Query/AST/Functions/ConcatFunction.php | 26 ++-- .../Query/AST/Functions/DateAddFunction.php | 2 +- .../Query/AST/Functions/IdentityFunction.php | 4 +- .../Query/AST/Functions/LengthFunction.php | 4 +- .../ORM/Query/AST/Functions/LowerFunction.php | 4 +- .../ORM/Query/AST/Functions/ModFunction.php | 6 +- .../ORM/Query/AST/Functions/TrimFunction.php | 4 +- .../ORM/Query/AST/Functions/UpperFunction.php | 4 +- ...electIdentificationVariableDeclaration.php | 8 +- lib/Doctrine/ORM/Query/Expr.php | 5 +- lib/Doctrine/ORM/Query/Lexer.php | 6 +- lib/Doctrine/ORM/Query/Parser.php | 16 +-- lib/Doctrine/ORM/Query/QueryException.php | 2 +- .../ORM/Query/QueryExpressionVisitor.php | 15 +- lib/Doctrine/ORM/Query/ResultSetMapping.php | 16 +-- .../ORM/Query/ResultSetMappingBuilder.php | 4 +- lib/Doctrine/ORM/Query/SqlWalker.php | 2 +- lib/Doctrine/ORM/Query/TreeWalkerAdapter.php | 2 +- lib/Doctrine/ORM/Query/TreeWalkerChain.php | 2 +- .../ORM/Query/TreeWalkerChainIterator.php | 14 +- .../Tools/AttachEntityListenersListener.php | 8 +- .../ClearCache/CollectionRegionCommand.php | 4 +- .../ClearCache/EntityRegionCommand.php | 4 +- .../Command/ClearCache/QueryRegionCommand.php | 4 +- .../Command/GenerateRepositoriesCommand.php | 6 +- .../ORM/Tools/Console/Command/InfoCommand.php | 2 +- .../Command/MappingDescribeCommand.php | 2 +- .../Command/SchemaTool/AbstractCommand.php | 1 + .../Command/SchemaTool/UpdateCommand.php | 4 +- .../ORM/Tools/Console/ConsoleRunner.php | 2 +- .../ORM/Tools/DebugUnitOfWorkListener.php | 1 + lib/Doctrine/ORM/Tools/EntityGenerator.php | 7 +- .../Tools/Export/Driver/AbstractExporter.php | 2 +- .../ORM/Tools/Export/Driver/XmlExporter.php | 4 +- .../ORM/Tools/Pagination/Paginator.php | 7 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 8 +- lib/Doctrine/ORM/Tools/SchemaValidator.php | 7 +- lib/Doctrine/ORM/UnitOfWork.php | 14 +- 80 files changed, 358 insertions(+), 294 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 0e38daed0..b5a8902fd 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -178,7 +178,6 @@ abstract class AbstractQuery } /** - * * Enable/disable second level query (result) caching for this query. * * @param boolean $cacheable @@ -243,7 +242,7 @@ abstract class AbstractQuery * * @param integer $lifetime * - * @return static This query instance. + * @return \Doctrine\ORM\AbstractQuery This query instance. */ public function setLifetime($lifetime) { @@ -263,7 +262,7 @@ abstract class AbstractQuery /** * @param integer $cacheMode * - * @return static This query instance. + * @return \Doctrine\ORM\AbstractQuery This query instance. */ public function setCacheMode($cacheMode) { @@ -863,7 +862,7 @@ abstract class AbstractQuery /** * Check if the query has a hint * - * @param string $name The name of the hint + * @param string $name The name of the hint * * @return bool False if the query does not have any hint */ diff --git a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php index 3aee1096b..dae5e602d 100644 --- a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php @@ -43,8 +43,8 @@ class AssociationCacheEntry implements CacheEntry public $class; /** - * @param string $class The entity class. - * @param array $identifier The entity identifier. + * @param string $class The entity class. + * @param array $identifier The entity identifier. */ public function __construct($class, array $identifier) { @@ -58,6 +58,8 @@ class AssociationCacheEntry implements CacheEntry * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * * @param array $values array containing property values + * + * @return AssociationCacheEntry */ public static function __set_state(array $values) { diff --git a/lib/Doctrine/ORM/Cache/CacheException.php b/lib/Doctrine/ORM/Cache/CacheException.php index 5b548fe5e..315a8aac2 100644 --- a/lib/Doctrine/ORM/Cache/CacheException.php +++ b/lib/Doctrine/ORM/Cache/CacheException.php @@ -62,8 +62,9 @@ class CacheException extends ORMException /** * @param string $entityName + * @param string $field * - * @return \Doctrine\ORM\Cache\CacheException + * @return CacheException */ public static function nonCacheableEntityAssociation($entityName, $field) { diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php index 6c634ce31..b3a1defe1 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php @@ -50,7 +50,7 @@ class CollectionCacheEntry implements CacheEntry * * @param array $values array containing property values * - * @return self + * @return CollectionCacheEntry */ public static function __set_state(array $values) { diff --git a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php index ece7fae18..3c552073d 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php @@ -60,6 +60,8 @@ class EntityCacheEntry implements CacheEntry * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * * @param array $values array containing property values + * + * @return EntityCacheEntry */ public static function __set_state(array $values) { diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index ef95ab772..5690f9169 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -282,9 +282,9 @@ abstract class AbstractEntityPersister implements CachedEntityPersister /** * Generates a string of currently query * - * @param array $query - * @param string $criteria - * @param array $orderBy + * @param array $query + * @param string $criteria + * @param array $orderBy * @param integer $limit * @param integer $offset * @param integer $timestamp diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php index 0c9078cec..89582700c 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php @@ -38,8 +38,9 @@ interface CachedEntityPersister extends CachedPersister, EntityPersister public function getEntityHydrator(); /** - * @param object $entity - * @param \Doctrine\ORM\Cache\EntityCacheKey $key + * @param object $entity + * @param \Doctrine\ORM\Cache\EntityCacheKey $key + * * @return boolean */ public function storeEntityCache($entity, EntityCacheKey $key); diff --git a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php index 1ba61bcf0..74e4cdda5 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php @@ -43,7 +43,7 @@ class QueryCacheEntry implements CacheEntry public $time; /** - * @param array $result + * @param array $result * @param integer $time */ public function __construct($result, $time = null) @@ -54,6 +54,8 @@ class QueryCacheEntry implements CacheEntry /** * @param array $values + * + * @return QueryCacheEntry */ public static function __set_state(array $values) { diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index d8d4b2694..880d9dabc 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -114,7 +114,7 @@ class FileLockRegion implements ConcurrentRegion /** * @param \Doctrine\ORM\Cache\CacheKey $key * - * return string + * @return string */ private function getLockFileName(CacheKey $key) { @@ -124,7 +124,7 @@ class FileLockRegion implements ConcurrentRegion /** * @param string $filename * - * return string + * @return string */ private function getLockContent($filename) { @@ -134,7 +134,7 @@ class FileLockRegion implements ConcurrentRegion /** * @param string $filename * - * return integer + * @return integer */ private function getLockTime($filename) { @@ -142,7 +142,7 @@ class FileLockRegion implements ConcurrentRegion } /** - * {inheritdoc} + * {@inheritdoc} */ public function getName() { @@ -150,7 +150,7 @@ class FileLockRegion implements ConcurrentRegion } /** - * {inheritdoc} + * {@inheritdoc} */ public function contains(CacheKey $key) { @@ -162,7 +162,7 @@ class FileLockRegion implements ConcurrentRegion } /** - * {inheritdoc} + * {@inheritdoc} */ public function get(CacheKey $key) { @@ -186,7 +186,7 @@ class FileLockRegion implements ConcurrentRegion } /** - * {inheritdoc} + * {@inheritdoc} */ public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null) { @@ -198,7 +198,7 @@ class FileLockRegion implements ConcurrentRegion } /** - * {inheritdoc} + * {@inheritdoc} */ public function evict(CacheKey $key) { @@ -210,7 +210,7 @@ class FileLockRegion implements ConcurrentRegion } /** - * {inheritdoc} + * {@inheritdoc} */ public function evictAll() { @@ -228,7 +228,7 @@ class FileLockRegion implements ConcurrentRegion } /** - * {inheritdoc} + * {@inheritdoc} */ public function lock(CacheKey $key) { @@ -248,7 +248,7 @@ class FileLockRegion implements ConcurrentRegion } /** - * {inheritdoc} + * {@inheritdoc} */ public function unlock(CacheKey $key, Lock $lock) { diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php index 9d15c84b3..0b7ce0be6 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php @@ -40,7 +40,7 @@ class TimestampCacheEntry implements CacheEntry */ public function __construct($time = null) { - $this->time = $time ? (float)$time : microtime(true); + $this->time = $time ? (float) $time : microtime(true); } /** @@ -49,6 +49,8 @@ class TimestampCacheEntry implements CacheEntry * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * * @param array $values array containing property values + * + * @return TimestampCacheEntry */ public static function __set_state(array $values) { diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index fef4fdc30..872050cb0 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -98,7 +98,7 @@ class Configuration extends \Doctrine\DBAL\Configuration */ public function setAutoGenerateProxyClasses($autoGenerate) { - $this->_attributes['autoGenerateProxyClasses'] = (int)$autoGenerate; + $this->_attributes['autoGenerateProxyClasses'] = (int) $autoGenerate; } /** diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index e9ea2acda..f8a4f936d 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -571,7 +571,7 @@ use Doctrine\Common\Util\ClassUtils; public function persist($entity) { if ( ! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#persist()' , $entity); + throw ORMInvalidArgumentException::invalidObject('EntityManager#persist()', $entity); } $this->errorIfClosed(); @@ -594,7 +594,7 @@ use Doctrine\Common\Util\ClassUtils; public function remove($entity) { if ( ! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#remove()' , $entity); + throw ORMInvalidArgumentException::invalidObject('EntityManager#remove()', $entity); } $this->errorIfClosed(); @@ -615,7 +615,7 @@ use Doctrine\Common\Util\ClassUtils; public function refresh($entity) { if ( ! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#refresh()' , $entity); + throw ORMInvalidArgumentException::invalidObject('EntityManager#refresh()', $entity); } $this->errorIfClosed(); @@ -639,7 +639,7 @@ use Doctrine\Common\Util\ClassUtils; public function detach($entity) { if ( ! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#detach()' , $entity); + throw ORMInvalidArgumentException::invalidObject('EntityManager#detach()', $entity); } $this->unitOfWork->detach($entity); @@ -659,7 +659,7 @@ use Doctrine\Common\Util\ClassUtils; public function merge($entity) { if ( ! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#merge()' , $entity); + throw ORMInvalidArgumentException::invalidObject('EntityManager#merge()', $entity); } $this->errorIfClosed(); diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 297de9967..5bd7739b7 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -185,7 +185,7 @@ class EntityRepository implements ObjectRepository, Selectable /** * Finds a single entity by a set of criteria. * - * @param array $criteria + * @param array $criteria * @param array|null $orderBy * * @return object|null The entity instance or NULL if the entity can not be found. diff --git a/lib/Doctrine/ORM/Event/ListenersInvoker.php b/lib/Doctrine/ORM/Event/ListenersInvoker.php index bbcbd4118..7be8d48eb 100644 --- a/lib/Doctrine/ORM/Event/ListenersInvoker.php +++ b/lib/Doctrine/ORM/Event/ListenersInvoker.php @@ -62,8 +62,8 @@ class ListenersInvoker /** * Get the subscribed event systems * - * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata. - * @param string $eventName The entity lifecycle event. + * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata. + * @param string $eventName The entity lifecycle event. * * @return integer Bitmask of subscribed event systems. */ @@ -89,21 +89,21 @@ class ListenersInvoker /** * Dispatches the lifecycle event of the given entity. * - * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata. - * @param string $eventName The entity lifecycle event. - * @param object $entity The Entity on which the event occurred. - * @param \Doctrine\Common\EventArgs $event The Event args. - * @param integer $invoke Bitmask to invoke listeners. + * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata. + * @param string $eventName The entity lifecycle event. + * @param object $entity The Entity on which the event occurred. + * @param \Doctrine\Common\EventArgs $event The Event args. + * @param integer $invoke Bitmask to invoke listeners. */ public function invoke(ClassMetadata $metadata, $eventName, $entity, EventArgs $event, $invoke) { - if($invoke & self::INVOKE_CALLBACKS) { + if ($invoke & self::INVOKE_CALLBACKS) { foreach ($metadata->lifecycleCallbacks[$eventName] as $callback) { $entity->$callback($event); } } - if($invoke & self::INVOKE_LISTENERS) { + if ($invoke & self::INVOKE_LISTENERS) { foreach ($metadata->entityListeners[$eventName] as $listener) { $class = $listener['class']; $method = $listener['method']; @@ -113,8 +113,8 @@ class ListenersInvoker } } - if($invoke & self::INVOKE_MANAGER) { + if ($invoke & self::INVOKE_MANAGER) { $this->eventManager->dispatchEvent($eventName, $event); } } -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Id/IdentityGenerator.php b/lib/Doctrine/ORM/Id/IdentityGenerator.php index 01cb09433..b9f68c625 100644 --- a/lib/Doctrine/ORM/Id/IdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/IdentityGenerator.php @@ -52,7 +52,7 @@ class IdentityGenerator extends AbstractIdGenerator */ public function generate(EntityManager $em, $entity) { - return (int)$em->getConnection()->lastInsertId($this->sequenceName); + return (int) $em->getConnection()->lastInsertId($this->sequenceName); } /** diff --git a/lib/Doctrine/ORM/Id/SequenceGenerator.php b/lib/Doctrine/ORM/Id/SequenceGenerator.php index 1236d95b5..1f3c9541b 100644 --- a/lib/Doctrine/ORM/Id/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Id/SequenceGenerator.php @@ -76,7 +76,7 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable $conn = $em->getConnection(); $sql = $conn->getDatabasePlatform()->getSequenceNextValSQL($this->_sequenceName); - $this->_nextValue = (int)$conn->fetchColumn($sql); + $this->_nextValue = (int) $conn->fetchColumn($sql); $this->_maxValue = $this->_nextValue + $this->_allocationSize; } diff --git a/lib/Doctrine/ORM/Id/UuidGenerator.php b/lib/Doctrine/ORM/Id/UuidGenerator.php index a8e92bbe2..7cac5ccf4 100644 --- a/lib/Doctrine/ORM/Id/UuidGenerator.php +++ b/lib/Doctrine/ORM/Id/UuidGenerator.php @@ -36,6 +36,7 @@ class UuidGenerator extends AbstractIdGenerator { $conn = $em->getConnection(); $sql = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression(); + return $conn->query($sql)->fetchColumn(0); } } diff --git a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php b/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php index b35012c99..9caf03ddf 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php +++ b/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php @@ -38,7 +38,7 @@ class HydrationException extends \Doctrine\ORM\ORMException public static function parentObjectOfRelationNotFound($alias, $parentAlias) { return new self("The parent object of entity result with alias '$alias' was not found." - . " The parent alias is '$parentAlias'."); + . " The parent alias is '$parentAlias'."); } /** @@ -88,7 +88,7 @@ class HydrationException extends \Doctrine\ORM\ORMException $discrColumnName, $entityName, $dqlAlias )); } - + /** * @param string $discrValue * @param array $discrMap diff --git a/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php b/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php index 6c6719e00..1774ca030 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php +++ b/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php @@ -80,6 +80,7 @@ class IterableResult implements \Iterator { $this->_current = $this->_hydrator->hydrateRow(); $this->_key++; + return $this->_current; } diff --git a/lib/Doctrine/ORM/LazyCriteriaCollection.php b/lib/Doctrine/ORM/LazyCriteriaCollection.php index 0751bee41..ad0238fbb 100644 --- a/lib/Doctrine/ORM/LazyCriteriaCollection.php +++ b/lib/Doctrine/ORM/LazyCriteriaCollection.php @@ -99,7 +99,8 @@ class LazyCriteriaCollection extends AbstractLazyCollection implements Selectabl /** * Do an optimized search of an element * - * @param object $element + * @param object $element + * * @return bool */ public function contains($element) diff --git a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php index 5bc75e31e..5abfe21bb 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php @@ -63,6 +63,7 @@ class AssociationBuilder public function mappedBy($fieldName) { $this->mapping['mappedBy'] = $fieldName; + return $this; } @@ -74,6 +75,7 @@ class AssociationBuilder public function inversedBy($fieldName) { $this->mapping['inversedBy'] = $fieldName; + return $this; } @@ -83,6 +85,7 @@ class AssociationBuilder public function cascadeAll() { $this->mapping['cascade'] = array("ALL"); + return $this; } @@ -92,6 +95,7 @@ class AssociationBuilder public function cascadePersist() { $this->mapping['cascade'][] = "persist"; + return $this; } @@ -101,6 +105,7 @@ class AssociationBuilder public function cascadeRemove() { $this->mapping['cascade'][] = "remove"; + return $this; } @@ -110,6 +115,7 @@ class AssociationBuilder public function cascadeMerge() { $this->mapping['cascade'][] = "merge"; + return $this; } @@ -119,6 +125,7 @@ class AssociationBuilder public function cascadeDetach() { $this->mapping['cascade'][] = "detach"; + return $this; } @@ -128,6 +135,7 @@ class AssociationBuilder public function cascadeRefresh() { $this->mapping['cascade'][] = "refresh"; + return $this; } @@ -137,6 +145,7 @@ class AssociationBuilder public function fetchExtraLazy() { $this->mapping['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; + return $this; } @@ -146,6 +155,7 @@ class AssociationBuilder public function fetchEager() { $this->mapping['fetch'] = ClassMetadata::FETCH_EAGER; + return $this; } @@ -155,6 +165,7 @@ class AssociationBuilder public function fetchLazy() { $this->mapping['fetch'] = ClassMetadata::FETCH_LAZY; + return $this; } @@ -180,6 +191,7 @@ class AssociationBuilder 'onDelete' => $onDelete, 'columnDefinition' => $columnDef, ); + return $this; } @@ -226,6 +238,7 @@ class AssociationBuilder } else { throw new \InvalidArgumentException("Type should be a ToOne Association here"); } + return $this->builder; } } diff --git a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php index 934a6b735..5a8966781 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php @@ -79,6 +79,7 @@ class FieldBuilder public function length($length) { $this->mapping['length'] = $length; + return $this; } @@ -91,7 +92,8 @@ class FieldBuilder */ public function nullable($flag = true) { - $this->mapping['nullable'] = (bool)$flag; + $this->mapping['nullable'] = (bool) $flag; + return $this; } @@ -104,7 +106,8 @@ class FieldBuilder */ public function unique($flag = true) { - $this->mapping['unique'] = (bool)$flag; + $this->mapping['unique'] = (bool) $flag; + return $this; } @@ -118,6 +121,7 @@ class FieldBuilder public function columnName($name) { $this->mapping['columnName'] = $name; + return $this; } @@ -131,6 +135,7 @@ class FieldBuilder public function precision($p) { $this->mapping['precision'] = $p; + return $this; } @@ -144,6 +149,7 @@ class FieldBuilder public function scale($s) { $this->mapping['scale'] = $s; + return $this; } @@ -166,6 +172,7 @@ class FieldBuilder public function makePrimaryKey() { $this->mapping['id'] = true; + return $this; } @@ -180,6 +187,7 @@ class FieldBuilder public function option($name, $value) { $this->mapping['options'][$name] = $value; + return $this; } @@ -191,6 +199,7 @@ class FieldBuilder public function generatedValue($strategy = 'AUTO') { $this->generatedValue = $strategy; + return $this; } @@ -202,6 +211,7 @@ class FieldBuilder public function isVersionField() { $this->version = true; + return $this; } @@ -221,6 +231,7 @@ class FieldBuilder 'allocationSize' => $allocationSize, 'initialValue' => $initialValue, ); + return $this; } @@ -234,6 +245,7 @@ class FieldBuilder public function columnDefinition($def) { $this->mapping['columnDefinition'] = $def; + return $this; } @@ -274,7 +286,7 @@ class FieldBuilder if ($this->sequenceDef) { $cm->setSequenceGeneratorDefinition($this->sequenceDef); } - + if ($this->customIdGenerator) { $cm->setCustomGeneratorDefinition(['class' => $this->customIdGenerator]); } diff --git a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php index a182e1e86..8b167d996 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php @@ -47,6 +47,7 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder public function setJoinTable($name) { $this->joinTableName = $name; + return $this; } @@ -72,6 +73,7 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder 'onDelete' => $onDelete, 'columnDefinition' => $columnDef, ); + return $this; } @@ -93,6 +95,7 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder } $cm = $this->builder->getClassMetadata(); $cm->mapManyToMany($mapping); + return $this->builder; } } diff --git a/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php index 4ca60f0ce..347dfd04d 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php @@ -37,6 +37,7 @@ class OneToManyAssociationBuilder extends AssociationBuilder public function setOrderBy(array $fieldNames) { $this->mapping['orderBy'] = $fieldNames; + return $this; } @@ -48,6 +49,7 @@ class OneToManyAssociationBuilder extends AssociationBuilder public function setIndexBy($fieldName) { $this->mapping['indexBy'] = $fieldName; + return $this; } @@ -62,6 +64,7 @@ class OneToManyAssociationBuilder extends AssociationBuilder } $cm = $this->builder->getClassMetadata(); $cm->mapOneToMany($mapping); + return $this->builder; } } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 52bf7aa54..b42b8b567 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -386,6 +386,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory } $parts = explode("\\", $className); + return strtolower(end($parts)); } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 501ffec68..62d51ce16 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -698,6 +698,7 @@ class ClassMetadataInfo implements ClassMetadata if ($this->isIdentifierComposite) { throw new BadMethodCallException("Class " . $this->name . " has a composite identifier."); } + return $this->reflFields[$this->identifier[0]]; } @@ -1551,11 +1552,11 @@ class ClassMetadataInfo implements ClassMetadata } $mapping['cascade'] = $cascades; - $mapping['isCascadeRemove'] = in_array('remove', $cascades); - $mapping['isCascadePersist'] = in_array('persist', $cascades); - $mapping['isCascadeRefresh'] = in_array('refresh', $cascades); - $mapping['isCascadeMerge'] = in_array('merge', $cascades); - $mapping['isCascadeDetach'] = in_array('detach', $cascades); + $mapping['isCascadeRemove'] = in_array('remove', $cascades); + $mapping['isCascadePersist'] = in_array('persist', $cascades); + $mapping['isCascadeRefresh'] = in_array('refresh', $cascades); + $mapping['isCascadeMerge'] = in_array('merge', $cascades); + $mapping['isCascadeDetach'] = in_array('detach', $cascades); return $mapping; } @@ -3248,6 +3249,7 @@ class ClassMetadataInfo implements ClassMetadata /** * @param string|null $className + * * @return string|null null if the input value is null */ public function fullyQualifiedClassName($className) @@ -3268,7 +3270,8 @@ class ClassMetadataInfo implements ClassMetadata * * @return mixed */ - public function getMetadataValue($name) { + public function getMetadataValue($name) + { if (isset($this->$name)) { return $this->$name; @@ -3281,6 +3284,7 @@ class ClassMetadataInfo implements ClassMetadata * Map Embedded Class * * @param array $mapping + * * @throws MappingException * @return void */ @@ -3299,7 +3303,7 @@ class ClassMetadataInfo implements ClassMetadata /** * Inline the embeddable class * - * @param string $property + * @param string $property * @param ClassMetadataInfo $embeddable */ public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) diff --git a/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php index 1e75f9794..ef7f76b1e 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php @@ -23,7 +23,7 @@ namespace Doctrine\ORM\Mapping; /** * The default NamingStrategy * - * + * * @link www.doctrine-project.org * @since 2.3 * @author Fabio B. Silva @@ -80,15 +80,15 @@ class DefaultNamingStrategy implements NamingStrategy public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) { return strtolower($this->classToTableName($sourceEntity) . '_' . - $this->classToTableName($targetEntity)); + $this->classToTableName($targetEntity)); } - + /** * {@inheritdoc} */ public function joinKeyColumnName($entityName, $referencedColumnName = null) { return strtolower($this->classToTableName($entityName) . '_' . - ($referencedColumnName ?: $this->referenceColumnName())); + ($referencedColumnName ?: $this->referenceColumnName())); } } diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 92b4b4722..1f8599657 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -526,8 +526,8 @@ class AnnotationDriver extends AbstractAnnotationDriver */ private function getFetchMode($className, $fetchMode) { - if( ! defined('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $fetchMode)) { - throw MappingException::invalidFetchMode($className, $fetchMode); + if ( ! defined('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $fetchMode)) { + throw MappingException::invalidFetchMode($className, $fetchMode); } return constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $fetchMode); diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index e51c15282..ac3b309fd 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -248,7 +248,7 @@ class DatabaseDriver implements MappingDriver } $metadata->mapManyToMany($associationMapping); - + break; } } @@ -319,7 +319,7 @@ class DatabaseDriver implements MappingDriver $tableName = $metadata->table['name']; $indexes = $this->tables[$tableName]->getIndexes(); - foreach($indexes as $index){ + foreach ($indexes as $index) { if ($index->isPrimary()) { continue; } @@ -506,7 +506,7 @@ class DatabaseDriver implements MappingDriver { try { return $table->getPrimaryKey()->getColumns(); - } catch(SchemaException $e) { + } catch (SchemaException $e) { // Do nothing } @@ -550,6 +550,7 @@ class DatabaseDriver implements MappingDriver if ($fk) { $columnName = str_replace('_id', '', $columnName); } + return Inflector::camelize($columnName); } } diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 0dfbb850e..da090daa4 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -59,14 +59,14 @@ class XmlDriver extends FileDriver if ($xmlRoot->getName() == 'entity') { if (isset($xmlRoot['repository-class'])) { - $metadata->setCustomRepositoryClass((string)$xmlRoot['repository-class']); + $metadata->setCustomRepositoryClass((string) $xmlRoot['repository-class']); } if (isset($xmlRoot['read-only']) && $this->evaluateBoolean($xmlRoot['read-only'])) { $metadata->markReadOnly(); } } else if ($xmlRoot->getName() == 'mapped-superclass') { $metadata->setCustomRepositoryClass( - isset($xmlRoot['repository-class']) ? (string)$xmlRoot['repository-class'] : null + isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null ); $metadata->isMappedSuperclass = true; } else if ($xmlRoot->getName() == 'embeddable') { @@ -97,8 +97,8 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'named-queries'})) { foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) { $metadata->addNamedQuery(array( - 'name' => (string)$namedQueryElement['name'], - 'query' => (string)$namedQueryElement['query'] + 'name' => (string) $namedQueryElement['name'], + 'query' => (string) $namedQueryElement['query'] )); } } @@ -107,10 +107,10 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'named-native-queries'})) { foreach ($xmlRoot->{'named-native-queries'}->{'named-native-query'} as $nativeQueryElement) { $metadata->addNamedNativeQuery(array( - 'name' => isset($nativeQueryElement['name']) ? (string)$nativeQueryElement['name'] : null, - 'query' => isset($nativeQueryElement->query) ? (string)$nativeQueryElement->query : null, - 'resultClass' => isset($nativeQueryElement['result-class']) ? (string)$nativeQueryElement['result-class'] : null, - 'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string)$nativeQueryElement['result-set-mapping'] : null, + 'name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null, + 'query' => isset($nativeQueryElement->query) ? (string) $nativeQueryElement->query : null, + 'resultClass' => isset($nativeQueryElement['result-class']) ? (string) $nativeQueryElement['result-class'] : null, + 'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string) $nativeQueryElement['result-set-mapping'] : null, )); } } @@ -125,14 +125,14 @@ class XmlDriver extends FileDriver if (isset($entityElement['entity-class'])) { $entityResult = array( 'fields' => array(), - 'entityClass' => (string)$entityElement['entity-class'], - 'discriminatorColumn' => isset($entityElement['discriminator-column']) ? (string)$entityElement['discriminator-column'] : null, + 'entityClass' => (string) $entityElement['entity-class'], + 'discriminatorColumn' => isset($entityElement['discriminator-column']) ? (string) $entityElement['discriminator-column'] : null, ); foreach ($entityElement as $fieldElement) { $entityResult['fields'][] = array( - 'name' => isset($fieldElement['name']) ? (string)$fieldElement['name'] : null, - 'column' => isset($fieldElement['column']) ? (string)$fieldElement['column'] : null, + 'name' => isset($fieldElement['name']) ? (string) $fieldElement['name'] : null, + 'column' => isset($fieldElement['column']) ? (string) $fieldElement['column'] : null, ); } @@ -142,13 +142,13 @@ class XmlDriver extends FileDriver // if (isset($entityElement['name'])) { $columns[] = array( - 'name' => (string)$entityElement['name'], + 'name' => (string) $entityElement['name'], ); } } $metadata->addSqlResultSetMapping(array( - 'name' => (string)$rsmElement['name'], + 'name' => (string) $rsmElement['name'], 'entities' => $entities, 'columns' => $columns )); @@ -156,7 +156,7 @@ class XmlDriver extends FileDriver } if (isset($xmlRoot['inheritance-type'])) { - $inheritanceType = (string)$xmlRoot['inheritance-type']; + $inheritanceType = (string) $xmlRoot['inheritance-type']; $metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType)); if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) { @@ -164,10 +164,10 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'discriminator-column'})) { $discrColumn = $xmlRoot->{'discriminator-column'}; $metadata->setDiscriminatorColumn(array( - 'name' => isset($discrColumn['name']) ? (string)$discrColumn['name'] : null, - 'type' => isset($discrColumn['type']) ? (string)$discrColumn['type'] : null, - 'length' => isset($discrColumn['length']) ? (string)$discrColumn['length'] : null, - 'columnDefinition' => isset($discrColumn['column-definition']) ? (string)$discrColumn['column-definition'] : null + 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, + 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : null, + 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : null, + 'columnDefinition' => isset($discrColumn['column-definition']) ? (string) $discrColumn['column-definition'] : null )); } else { $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); @@ -177,7 +177,7 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'discriminator-map'})) { $map = array(); foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} as $discrMapElement) { - $map[(string)$discrMapElement['value']] = (string)$discrMapElement['class']; + $map[(string) $discrMapElement['value']] = (string) $discrMapElement['class']; } $metadata->setDiscriminatorMap($map); } @@ -188,7 +188,7 @@ class XmlDriver extends FileDriver // Evaluate if (isset($xmlRoot['change-tracking-policy'])) { $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' - . strtoupper((string)$xmlRoot['change-tracking-policy']))); + . strtoupper((string) $xmlRoot['change-tracking-policy']))); } // Evaluate @@ -225,7 +225,7 @@ class XmlDriver extends FileDriver } if (isset($uniqueXml['name'])) { - $metadata->table['uniqueConstraints'][(string)$uniqueXml['name']] = $unique; + $metadata->table['uniqueConstraints'][(string) $uniqueXml['name']] = $unique; } else { $metadata->table['uniqueConstraints'][] = $unique; } @@ -285,29 +285,29 @@ class XmlDriver extends FileDriver $associationIds = array(); foreach ($xmlRoot->id as $idElement) { if (isset($idElement['association-key']) && $this->evaluateBoolean($idElement['association-key'])) { - $associationIds[(string)$idElement['name']] = true; + $associationIds[(string) $idElement['name']] = true; continue; } $mapping = array( 'id' => true, - 'fieldName' => (string)$idElement['name'] + 'fieldName' => (string) $idElement['name'] ); if (isset($idElement['type'])) { - $mapping['type'] = (string)$idElement['type']; + $mapping['type'] = (string) $idElement['type']; } if (isset($idElement['length'])) { - $mapping['length'] = (string)$idElement['length']; + $mapping['length'] = (string) $idElement['length']; } if (isset($idElement['column'])) { - $mapping['columnName'] = (string)$idElement['column']; + $mapping['columnName'] = (string) $idElement['column']; } if (isset($idElement['column-definition'])) { - $mapping['columnDefinition'] = (string)$idElement['column-definition']; + $mapping['columnDefinition'] = (string) $idElement['column-definition']; } if (isset($idElement->options)) { @@ -318,18 +318,18 @@ class XmlDriver extends FileDriver if (isset($idElement->generator)) { $strategy = isset($idElement->generator['strategy']) ? - (string)$idElement->generator['strategy'] : 'AUTO'; + (string) $idElement->generator['strategy'] : 'AUTO'; $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' - . $strategy)); + . $strategy)); } // Check for SequenceGenerator/TableGenerator definition if (isset($idElement->{'sequence-generator'})) { $seqGenerator = $idElement->{'sequence-generator'}; $metadata->setSequenceGeneratorDefinition(array( - 'sequenceName' => (string)$seqGenerator['sequence-name'], - 'allocationSize' => (string)$seqGenerator['allocation-size'], - 'initialValue' => (string)$seqGenerator['initial-value'] + 'sequenceName' => (string) $seqGenerator['sequence-name'], + 'allocationSize' => (string) $seqGenerator['allocation-size'], + 'initialValue' => (string) $seqGenerator['initial-value'] )); } else if (isset($idElement->{'custom-id-generator'})) { $customGenerator = $idElement->{'custom-id-generator'}; @@ -345,8 +345,8 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'one-to-one'})) { foreach ($xmlRoot->{'one-to-one'} as $oneToOneElement) { $mapping = array( - 'fieldName' => (string)$oneToOneElement['field'], - 'targetEntity' => (string)$oneToOneElement['target-entity'] + 'fieldName' => (string) $oneToOneElement['field'], + 'targetEntity' => (string) $oneToOneElement['target-entity'] ); if (isset($associationIds[$mapping['fieldName']])) { @@ -354,14 +354,14 @@ class XmlDriver extends FileDriver } if (isset($oneToOneElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string)$oneToOneElement['fetch']); + $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string) $oneToOneElement['fetch']); } if (isset($oneToOneElement['mapped-by'])) { - $mapping['mappedBy'] = (string)$oneToOneElement['mapped-by']; + $mapping['mappedBy'] = (string) $oneToOneElement['mapped-by']; } else { if (isset($oneToOneElement['inversed-by'])) { - $mapping['inversedBy'] = (string)$oneToOneElement['inversed-by']; + $mapping['inversedBy'] = (string) $oneToOneElement['inversed-by']; } $joinColumns = array(); @@ -397,13 +397,13 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'one-to-many'})) { foreach ($xmlRoot->{'one-to-many'} as $oneToManyElement) { $mapping = array( - 'fieldName' => (string)$oneToManyElement['field'], - 'targetEntity' => (string)$oneToManyElement['target-entity'], - 'mappedBy' => (string)$oneToManyElement['mapped-by'] + 'fieldName' => (string) $oneToManyElement['field'], + 'targetEntity' => (string) $oneToManyElement['target-entity'], + 'mappedBy' => (string) $oneToManyElement['mapped-by'] ); if (isset($oneToManyElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string)$oneToManyElement['fetch']); + $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string) $oneToManyElement['fetch']); } if (isset($oneToManyElement->cascade)) { @@ -417,13 +417,13 @@ class XmlDriver extends FileDriver if (isset($oneToManyElement->{'order-by'})) { $orderBy = array(); foreach ($oneToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) { - $orderBy[(string)$orderByField['name']] = (string)$orderByField['direction']; + $orderBy[(string) $orderByField['name']] = (string) $orderByField['direction']; } $mapping['orderBy'] = $orderBy; } if (isset($oneToManyElement['index-by'])) { - $mapping['indexBy'] = (string)$oneToManyElement['index-by']; + $mapping['indexBy'] = (string) $oneToManyElement['index-by']; } else if (isset($oneToManyElement->{'index-by'})) { throw new \InvalidArgumentException(" is not a valid tag"); } @@ -441,8 +441,8 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'many-to-one'})) { foreach ($xmlRoot->{'many-to-one'} as $manyToOneElement) { $mapping = array( - 'fieldName' => (string)$manyToOneElement['field'], - 'targetEntity' => (string)$manyToOneElement['target-entity'] + 'fieldName' => (string) $manyToOneElement['field'], + 'targetEntity' => (string) $manyToOneElement['target-entity'] ); if (isset($associationIds[$mapping['fieldName']])) { @@ -450,11 +450,11 @@ class XmlDriver extends FileDriver } if (isset($manyToOneElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string)$manyToOneElement['fetch']); + $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . (string) $manyToOneElement['fetch']); } if (isset($manyToOneElement['inversed-by'])) { - $mapping['inversedBy'] = (string)$manyToOneElement['inversed-by']; + $mapping['inversedBy'] = (string) $manyToOneElement['inversed-by']; } $joinColumns = array(); @@ -487,12 +487,12 @@ class XmlDriver extends FileDriver if (isset($xmlRoot->{'many-to-many'})) { foreach ($xmlRoot->{'many-to-many'} as $manyToManyElement) { $mapping = array( - 'fieldName' => (string)$manyToManyElement['field'], - 'targetEntity' => (string)$manyToManyElement['target-entity'] + 'fieldName' => (string) $manyToManyElement['field'], + 'targetEntity' => (string) $manyToManyElement['target-entity'] ); 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']); } if (isset($manyToManyElement['orphan-removal'])) { @@ -500,19 +500,19 @@ class XmlDriver extends FileDriver } if (isset($manyToManyElement['mapped-by'])) { - $mapping['mappedBy'] = (string)$manyToManyElement['mapped-by']; + $mapping['mappedBy'] = (string) $manyToManyElement['mapped-by']; } else if (isset($manyToManyElement->{'join-table'})) { if (isset($manyToManyElement['inversed-by'])) { - $mapping['inversedBy'] = (string)$manyToManyElement['inversed-by']; + $mapping['inversedBy'] = (string) $manyToManyElement['inversed-by']; } $joinTableElement = $manyToManyElement->{'join-table'}; $joinTable = array( - 'name' => (string)$joinTableElement['name'] + 'name' => (string) $joinTableElement['name'] ); if (isset($joinTableElement['schema'])) { - $joinTable['schema'] = (string)$joinTableElement['schema']; + $joinTable['schema'] = (string) $joinTableElement['schema']; } foreach ($joinTableElement->{'join-columns'}->{'join-column'} as $joinColumnElement) { @@ -533,13 +533,13 @@ class XmlDriver extends FileDriver if (isset($manyToManyElement->{'order-by'})) { $orderBy = array(); foreach ($manyToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) { - $orderBy[(string)$orderByField['name']] = (string)$orderByField['direction']; + $orderBy[(string) $orderByField['name']] = (string) $orderByField['direction']; } $mapping['orderBy'] = $orderBy; } if (isset($manyToManyElement['index-by'])) { - $mapping['indexBy'] = (string)$manyToManyElement['index-by']; + $mapping['indexBy'] = (string) $manyToManyElement['index-by']; } else if (isset($manyToManyElement->{'index-by'})) { throw new \InvalidArgumentException(" is not a valid tag"); } @@ -617,7 +617,7 @@ class XmlDriver extends FileDriver // Evaluate if (isset($xmlRoot->{'lifecycle-callbacks'})) { foreach ($xmlRoot->{'lifecycle-callbacks'}->{'lifecycle-callback'} as $lifecycleCallback) { - $metadata->addLifecycleCallback((string)$lifecycleCallback['method'], constant('Doctrine\ORM\Events::' . (string)$lifecycleCallback['type'])); + $metadata->addLifecycleCallback((string) $lifecycleCallback['method'], constant('Doctrine\ORM\Events::' . (string) $lifecycleCallback['type'])); } } @@ -626,7 +626,7 @@ class XmlDriver extends FileDriver foreach ($xmlRoot->{'entity-listeners'}->{'entity-listener'} as $listenerElement) { $className = (string) $listenerElement['class']; // Evaluate the listener using naming convention. - if($listenerElement->count() === 0) { + if ($listenerElement->count() === 0) { EntityListenerBuilder::bindEntityListener($metadata, $className); continue; @@ -684,8 +684,8 @@ class XmlDriver extends FileDriver private function joinColumnToArray(SimpleXMLElement $joinColumnElement) { $joinColumn = array( - 'name' => (string)$joinColumnElement['name'], - 'referencedColumnName' => (string)$joinColumnElement['referenced-column-name'] + 'name' => (string) $joinColumnElement['name'], + 'referencedColumnName' => (string) $joinColumnElement['referenced-column-name'] ); if (isset($joinColumnElement['unique'])) { @@ -697,11 +697,11 @@ class XmlDriver extends FileDriver } if (isset($joinColumnElement['on-delete'])) { - $joinColumn['onDelete'] = (string)$joinColumnElement['on-delete']; + $joinColumn['onDelete'] = (string) $joinColumnElement['on-delete']; } if (isset($joinColumnElement['column-definition'])) { - $joinColumn['columnDefinition'] = (string)$joinColumnElement['column-definition']; + $joinColumn['columnDefinition'] = (string) $joinColumnElement['column-definition']; } return $joinColumn; @@ -808,6 +808,7 @@ class XmlDriver extends FileDriver // anything about the supported cascading actions $cascades[] = str_replace('cascade-', '', $action->getName()); } + return $cascades; } @@ -821,12 +822,12 @@ class XmlDriver extends FileDriver if (isset($xmlElement->entity)) { foreach ($xmlElement->entity as $entityElement) { - $entityName = (string)$entityElement['name']; + $entityName = (string) $entityElement['name']; $result[$entityName] = $entityElement; } } else if (isset($xmlElement->{'mapped-superclass'})) { foreach ($xmlElement->{'mapped-superclass'} as $mappedSuperClass) { - $className = (string)$mappedSuperClass['name']; + $className = (string) $mappedSuperClass['name']; $result[$className] = $mappedSuperClass; } } else if (isset($xmlElement->embeddable)) { @@ -846,7 +847,7 @@ class XmlDriver extends FileDriver */ protected function evaluateBoolean($element) { - $flag = (string)$element; + $flag = (string) $element; return ($flag == "true" || $flag == "1"); } diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php index 53037d1ee..1dee969d7 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -175,10 +175,10 @@ class YamlDriver extends FileDriver if (isset($element['discriminatorColumn'])) { $discrColumn = $element['discriminatorColumn']; $metadata->setDiscriminatorColumn(array( - 'name' => isset($discrColumn['name']) ? (string)$discrColumn['name'] : null, - 'type' => isset($discrColumn['type']) ? (string)$discrColumn['type'] : null, - 'length' => isset($discrColumn['length']) ? (string)$discrColumn['length'] : null, - 'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string)$discrColumn['columnDefinition'] : null + 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, + 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : null, + 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : null, + 'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string) $discrColumn['columnDefinition'] : null )); } else { $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); @@ -195,7 +195,7 @@ class YamlDriver extends FileDriver // Evaluate changeTrackingPolicy if (isset($element['changeTrackingPolicy'])) { $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' - . strtoupper($element['changeTrackingPolicy']))); + . strtoupper($element['changeTrackingPolicy']))); } // Evaluate indexes @@ -290,7 +290,7 @@ class YamlDriver extends FileDriver if (isset($idElement['generator'])) { $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' - . strtoupper($idElement['generator']['strategy']))); + . strtoupper($idElement['generator']['strategy']))); } // Check for SequenceGenerator/TableGenerator definition if (isset($idElement['sequenceGenerator'])) { @@ -316,7 +316,7 @@ class YamlDriver extends FileDriver $mapping['id'] = true; if (isset($fieldMapping['generator']['strategy'])) { $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' - . strtoupper($fieldMapping['generator']['strategy']))); + . strtoupper($fieldMapping['generator']['strategy']))); } } @@ -385,7 +385,7 @@ class YamlDriver extends FileDriver } if (isset($oneToOneElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool)$oneToOneElement['orphanRemoval']; + $mapping['orphanRemoval'] = (bool) $oneToOneElement['orphanRemoval']; } // Evaluate second level cache @@ -415,7 +415,7 @@ class YamlDriver extends FileDriver } if (isset($oneToManyElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool)$oneToManyElement['orphanRemoval']; + $mapping['orphanRemoval'] = (bool) $oneToManyElement['orphanRemoval']; } if (isset($oneToManyElement['orderBy'])) { @@ -548,7 +548,7 @@ class YamlDriver extends FileDriver } if (isset($manyToManyElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool)$manyToManyElement['orphanRemoval']; + $mapping['orphanRemoval'] = (bool) $manyToManyElement['orphanRemoval']; } // Evaluate second level cache @@ -646,7 +646,7 @@ class YamlDriver extends FileDriver continue; } - foreach ($entityListener as $eventName => $callbackElement){ + foreach ($entityListener as $eventName => $callbackElement) { foreach ($callbackElement as $methodName) { $metadata->addEntityListener($eventName, $className, $methodName); } @@ -739,7 +739,7 @@ class YamlDriver extends FileDriver } if (isset($column['unique'])) { - $mapping['unique'] = (bool)$column['unique']; + $mapping['unique'] = (bool) $column['unique']; } if (isset($column['options'])) { diff --git a/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php b/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php index 2d5ecf714..b0c62c8c3 100644 --- a/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php +++ b/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php @@ -31,8 +31,8 @@ interface EntityListenerResolver /** * Clear all instances from the set, or a specific class when given. * - * @param string $className The fully-qualified class name - * + * @param string $className The fully-qualified class name + * * @return void */ function clear($className = null); @@ -40,16 +40,16 @@ interface EntityListenerResolver /** * Returns a entity listener instance for the given class name. * - * @param string $className The fully-qualified class name - * - * @return object An entity listener + * @param string $className The fully-qualified class name + * + * @return object An entity listener */ function resolve($className); /** * Register a entity listener instance. * - * @param object $object An entity listener + * @param object $object An entity listener */ function register($object); -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 9e6b4b33f..ace42db27 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -326,7 +326,7 @@ class MappingException extends \Doctrine\ORM\ORMException public static function joinColumnMustPointToMappedField($className, $joinColumn) { return new self('The column ' . $joinColumn . ' must be mapped to a field in class ' - . $className . ' since it is referenced by a join column of another class.'); + . $className . ' since it is referenced by a join column of another class.'); } /** @@ -434,7 +434,7 @@ class MappingException extends \Doctrine\ORM\ORMException public static function unsupportedOptimisticLockingType($entity, $fieldName, $unsupportedType) { return new self('Locking type "'.$unsupportedType.'" (specified in "'.$entity.'", field "'.$fieldName.'") ' - .'is not supported by Doctrine.' + .'is not supported by Doctrine.' ); } @@ -482,7 +482,7 @@ class MappingException extends \Doctrine\ORM\ORMException public static function duplicateDiscriminatorEntry($className, array $entries, array $map) { return new self( - "The entries " . implode(', ', $entries) . " in discriminator map of class '" . $className . "' is duplicated. " . + "The entries " . implode(', ', $entries) . " in discriminator map of class '" . $className . "' is duplicated. " . "If the discriminator map is automatically generated you have to convert it to an explicit discriminator map now. " . "The entries of the current map are: @DiscriminatorMap({" . implode(', ', array_map( function($a, $b) { return "'$a': '$b'"; }, array_keys($map), array_values($map) @@ -633,7 +633,7 @@ class MappingException extends \Doctrine\ORM\ORMException public static function illegalOrphanRemoval($className, $field) { return new self("Orphan removal is only allowed on one-to-one and one-to-many ". - "associations, but " . $className."#" .$field . " is not."); + "associations, but " . $className."#" .$field . " is not."); } /** @@ -772,6 +772,7 @@ class MappingException extends \Doctrine\ORM\ORMException public static function invalidCascadeOption(array $cascades, $className, $propertyName) { $cascades = implode(", ", array_map(function ($e) { return "'" . $e . "'"; }, $cascades)); + return new self(sprintf( "You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'", $className, diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index 02c0f99aa..81466a0fe 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -90,15 +90,13 @@ class ORMInvalidArgumentException extends \InvalidArgumentException static public function newEntityFoundThroughRelationship(array $assoc, $entry) { return new self("A new entity was found through the relationship '" - . $assoc['sourceEntity'] . "#" . $assoc['fieldName'] . "' that was not" - . " configured to cascade persist operations for entity: " . self::objToStr($entry) . "." - . " To solve this issue: Either explicitly call EntityManager#persist()" - . " on this unknown entity or configure cascade persist " - . " this association in the mapping for example @ManyToOne(..,cascade={\"persist\"})." - . (method_exists($entry, '__toString') ? - "": - " If you cannot find out which entity causes the problem" - ." implement '" . $assoc['targetEntity'] . "#__toString()' to get a clue.")); + . $assoc['sourceEntity'] . "#" . $assoc['fieldName'] . "' that was not" + . " configured to cascade persist operations for entity: " . self::objToStr($entry) . "." + . " To solve this issue: Either explicitly call EntityManager#persist()" + . " on this unknown entity or configure cascade persist " + . " this association in the mapping for example @ManyToOne(..,cascade={\"persist\"})." + . (method_exists($entry, '__toString') ? "": " If you cannot find out which entity causes the problem" + . " implement '" . $assoc['targetEntity'] . "#__toString()' to get a clue.")); } /** @@ -110,8 +108,8 @@ class ORMInvalidArgumentException extends \InvalidArgumentException static public function detachedEntityFoundThroughRelationship(array $assoc, $entry) { return new self("A detached entity of type " . $assoc['targetEntity'] . " (" . self::objToStr($entry) . ") " - . " was found through the relationship '" . $assoc['sourceEntity'] . "#" . $assoc['fieldName'] . "' " - . "during cascading a persist operation."); + . " was found through the relationship '" . $assoc['sourceEntity'] . "#" . $assoc['fieldName'] . "' " + . "during cascading a persist operation."); } /** @@ -122,7 +120,7 @@ class ORMInvalidArgumentException extends \InvalidArgumentException static public function entityNotManaged($entity) { return new self("Entity " . self::objToStr($entity) . " is not managed. An entity is managed if its fetched " . - "from the database or registered as new through EntityManager#persist"); + "from the database or registered as new through EntityManager#persist"); } /** @@ -168,7 +166,7 @@ class ORMInvalidArgumentException extends \InvalidArgumentException public static function invalidObject($context, $given, $parameterIndex = 1) { return new self($context . ' expects parameter ' . $parameterIndex . - ' to be an entity object, '. gettype($given) . ' given.'); + ' to be an entity object, '. gettype($given) . ' given.'); } /** @@ -221,6 +219,6 @@ class ORMInvalidArgumentException extends \InvalidArgumentException */ private static function objToStr($obj) { - return method_exists($obj, '__toString') ? (string)$obj : get_class($obj).'@'.spl_object_hash($obj); + return method_exists($obj, '__toString') ? (string) $obj : get_class($obj).'@'.spl_object_hash($obj); } } diff --git a/lib/Doctrine/ORM/OptimisticLockException.php b/lib/Doctrine/ORM/OptimisticLockException.php index ecd5445b7..2fbd9ce5e 100644 --- a/lib/Doctrine/ORM/OptimisticLockException.php +++ b/lib/Doctrine/ORM/OptimisticLockException.php @@ -75,11 +75,12 @@ class OptimisticLockException extends ORMException { $expectedLockVersion = ($expectedLockVersion instanceof \DateTime) ? $expectedLockVersion->getTimestamp() : $expectedLockVersion; $actualLockVersion = ($actualLockVersion instanceof \DateTime) ? $actualLockVersion->getTimestamp() : $actualLockVersion; + return new self("The optimistic lock failed, version " . $expectedLockVersion . " was expected, but is actually ".$actualLockVersion, $entity); } /** - * @param string $entityName + * @param string $entityName * * @return OptimisticLockException */ diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 8d6ce7e7d..3b2faf878 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -2047,6 +2047,7 @@ class BasicEntityPersister implements EntityPersister } $sql = implode(' AND ', $filterClauses); + return $sql ? "(" . $sql . ")" : ""; // Wrap again to avoid "X or Y and FilterConditionSQL" } diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index 55887eefa..ff018a050 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -77,7 +77,8 @@ interface EntityPersister /** * Get the COUNT SQL to count entities (optionally based on a criteria) * - * @param array|\Doctrine\Common\Collections\Criteria $criteria + * @param array|\Doctrine\Common\Collections\Criteria $criteria + * * @return string */ public function getCountSQL($criteria = array()); @@ -201,8 +202,8 @@ interface EntityPersister /** * Loads an entity by identifier. * - * @param array $identifier The entity identifier. - * @param object|null $entity The entity to load the data into. If not specified, a new entity is created. + * @param array $identifier The entity identifier. + * @param object|null $entity The entity to load the data into. If not specified, a new entity is created. * * @return object The loaded and managed entity instance or NULL if the entity can not be found. * @@ -289,7 +290,7 @@ interface EntityPersister * * @param array $assoc * @param object $sourceEntity - * @param PersistentCollection $collection The collection to load/fill. + * @param PersistentCollection $collection The collection to load/fill. * * @return array */ diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 466ce9a14..072407405 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -589,7 +589,8 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister } /** - * @param string $baseTableAlias + * @param string $baseTableAlias + * * @return string */ private function getJoinSql($baseTableAlias) diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 21c51f042..a7c6f852d 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -657,7 +657,7 @@ final class Query extends AbstractQuery * * @see \Doctrine\DBAL\LockMode * - * @param int $lockMode + * @param int $lockMode * * @return Query * diff --git a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php index 05583920d..ad4d22257 100644 --- a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php @@ -51,9 +51,9 @@ class ComparisonExpression extends Node public $operator; /** - * @param Node $leftExpr + * @param Node $leftExpr * @param string $operator - * @param Node $rightExpr + * @param Node $rightExpr */ public function __construct($leftExpr, $operator, $rightExpr) { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php index 0e5edd55b..3ea69c0c1 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php @@ -24,7 +24,7 @@ use Doctrine\ORM\Query\Lexer; /** * "BIT_AND" "(" ArithmeticPrimary "," ArithmeticPrimary ")" * - * + * * @link www.doctrine-project.org * @since 2.2 * @author Fabio B. Silva @@ -40,6 +40,7 @@ class BitAndFunction extends FunctionNode public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); + return $platform->getBitAndComparisonExpression( $this->firstArithmetic->dispatch($sqlWalker), $this->secondArithmetic->dispatch($sqlWalker) diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php index 1d9c2df04..6b0d1eb4c 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php @@ -24,7 +24,7 @@ use Doctrine\ORM\Query\Lexer; /** * "BIT_OR" "(" ArithmeticPrimary "," ArithmeticPrimary ")" * - * + * * @link www.doctrine-project.org * @since 2.2 * @author Fabio B. Silva @@ -40,6 +40,7 @@ class BitOrFunction extends FunctionNode public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); + return $platform->getBitOrComparisonExpression( $this->firstArithmetic->dispatch($sqlWalker), $this->secondArithmetic->dispatch($sqlWalker) diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php index 421fe9ae7..1c58f6cbd 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php @@ -35,24 +35,24 @@ use Doctrine\ORM\Query\Lexer; class ConcatFunction extends FunctionNode { public $firstStringPrimary; - + public $secondStringPrimary; - + public $concatExpressions = array(); - + /** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); - + $args = array(); - + foreach ($this->concatExpressions as $expression) { $args[] = $sqlWalker->walkStringPrimary($expression); } - + return call_user_func_array(array($platform,'getConcatExpression'), $args); } @@ -63,18 +63,18 @@ class ConcatFunction extends FunctionNode { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); - + $this->firstStringPrimary = $parser->StringPrimary(); $this->concatExpressions[] = $this->firstStringPrimary; - + $parser->match(Lexer::T_COMMA); - - $this->secondStringPrimary = $parser->StringPrimary(); + + $this->secondStringPrimary = $parser->StringPrimary(); $this->concatExpressions[] = $this->secondStringPrimary; - + while ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); - $this->concatExpressions[] = $parser->StringPrimary(); + $parser->match(Lexer::T_COMMA); + $this->concatExpressions[] = $parser->StringPrimary(); } $parser->match(Lexer::T_CLOSE_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php index 312a52c67..2a9aead98 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php @@ -27,7 +27,7 @@ use Doctrine\ORM\Query\QueryException; /** * "DATE_ADD" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")" * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 242a38bcf..6f69d5357 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -27,7 +27,7 @@ use Doctrine\ORM\Query\QueryException; /** * "IDENTITY" "(" SingleValuedAssociationPathExpression {"," string} ")" * - * + * * @link www.doctrine-project.org * @since 2.2 * @author Guilherme Blanco @@ -70,7 +70,7 @@ class IdentityFunction extends FunctionNode foreach ($assoc['joinColumns'] as $mapping) { - if($mapping['referencedColumnName'] === $field['columnName']) { + if ($mapping['referencedColumnName'] === $field['columnName']) { $joinColumn = $mapping; break; diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php index deb3066e2..e2729feeb 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php @@ -24,7 +24,7 @@ use Doctrine\ORM\Query\Lexer; /** * "LENGTH" "(" StringPrimary ")" * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -42,7 +42,7 @@ class LengthFunction extends FunctionNode public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getLengthExpression( - $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) ); } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php index ffc86b6f8..5f0387e6f 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php @@ -24,7 +24,7 @@ use Doctrine\ORM\Query\Lexer; /** * "LOWER" "(" StringPrimary ")" * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -42,7 +42,7 @@ class LowerFunction extends FunctionNode public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getLowerExpression( - $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) ); } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php index cf4cf0c98..f00c6db7f 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php @@ -24,7 +24,7 @@ use Doctrine\ORM\Query\Lexer; /** * "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")" * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -50,8 +50,8 @@ class ModFunction extends FunctionNode public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getModExpression( - $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), - $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression) + $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), + $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression) ); } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php index 0c1f5d86f..9e748c308 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -27,7 +27,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; /** * "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -105,8 +105,6 @@ class TrimFunction extends FunctionNode } /** - * @param \Doctrine\ORM\Query\Parser $parser - * * @return integer */ private function getTrimMode() diff --git a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php index 888009a7b..22592a174 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php @@ -24,7 +24,7 @@ use Doctrine\ORM\Query\Lexer; /** * "UPPER" "(" StringPrimary ")" * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -42,7 +42,7 @@ class UpperFunction extends FunctionNode public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getUpperExpression( - $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) ); } diff --git a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php index 8fbd9e210..866f11222 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php @@ -26,21 +26,21 @@ namespace Doctrine\ORM\Query\AST; * @since 2.0 * @author Guilherme Blanco */ -class SubselectIdentificationVariableDeclaration +class SubselectIdentificationVariableDeclaration { /** * @var PathExpression */ public $associationPathExpression; - + /** * @var string */ public $aliasIdentificationVariable; - + /** * Constructor. - * + * * @param PathExpression $associationPathExpression * @param string $aliasIdentificationVariable */ diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index e979d67dc..70f9ac9e2 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -449,6 +449,7 @@ class Expr } } } + return new Expr\Func($x . ' IN', (array) $y); } @@ -456,7 +457,7 @@ class Expr * Creates a NOT IN() expression with the given arguments. * * @param string $x Field in string format to be restricted by NOT IN() function. - * @param mixed $y Argument to be used in NOT IN() function. + * @param mixed $y Argument to be used in NOT IN() function. * * @return Expr\Func */ @@ -469,6 +470,7 @@ class Expr } } } + return new Expr\Func($x . ' NOT IN', (array) $y); } @@ -550,6 +552,7 @@ class Expr if (null !== $len) { $args[] = $len; } + return new Expr\Func('SUBSTRING', $args); } diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index be71f4646..b31b93b87 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -125,7 +125,7 @@ class Lexer extends \Doctrine\Common\Lexer } /** - * @inheritdoc + * {@inheritdoc} */ protected function getCatchablePatterns() { @@ -139,7 +139,7 @@ class Lexer extends \Doctrine\Common\Lexer } /** - * @inheritdoc + * {@inheritdoc} */ protected function getNonCatchablePatterns() { @@ -147,7 +147,7 @@ class Lexer extends \Doctrine\Common\Lexer } /** - * @inheritdoc + * {@inheritdoc} */ protected function getType(&$value) { diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 009a5fd9d..6eb897268 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -439,8 +439,8 @@ class Parser /** * Generates a new syntax error. * - * @param string $expected Expected string. - * @param array|null $token Got token. + * @param string $expected Expected string. + * @param array|null $token Got token. * * @return void * @@ -637,7 +637,7 @@ class Parser // If the namespace is not given then assumes the first FROM entity namespace if (strpos($className, '\\') === false && ! class_exists($className) && strpos($fromClassName, '\\') !== false) { - $namespace = substr($fromClassName, 0 , strrpos($fromClassName, '\\')); + $namespace = substr($fromClassName, 0, strrpos($fromClassName, '\\')); $fqcn = $namespace . '\\' . $className; if (class_exists($fqcn)) { @@ -1611,7 +1611,6 @@ class Parser } /** - * * SubselectIdentificationVariableDeclaration ::= IdentificationVariableDeclaration * * {Internal note: WARNING: Solution is harder than a bare implementation. @@ -1960,10 +1959,9 @@ class Parser case ($lookahead === Lexer::T_INPUT_PARAMETER): switch (true) { - case $this->isMathOperator($peek): + case $this->isMathOperator($peek): // :param + u.value return $this->SimpleArithmeticExpression(); - default: return $this->InputParameter(); } @@ -2669,22 +2667,22 @@ class Parser switch ($this->lexer->lookahead['type']) { case Lexer::T_STRING: $this->match(Lexer::T_STRING); - return new AST\Literal(AST\Literal::STRING, $this->lexer->token['value']); + return new AST\Literal(AST\Literal::STRING, $this->lexer->token['value']); case Lexer::T_INTEGER: case Lexer::T_FLOAT: $this->match( $this->lexer->isNextToken(Lexer::T_INTEGER) ? Lexer::T_INTEGER : Lexer::T_FLOAT ); - return new AST\Literal(AST\Literal::NUMERIC, $this->lexer->token['value']); + return new AST\Literal(AST\Literal::NUMERIC, $this->lexer->token['value']); case Lexer::T_TRUE: case Lexer::T_FALSE: $this->match( $this->lexer->isNextToken(Lexer::T_TRUE) ? Lexer::T_TRUE : Lexer::T_FALSE ); - return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token['value']); + return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token['value']); default: $this->syntaxError('Literal'); } diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index 16a10856a..8245722a9 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -248,7 +248,7 @@ class QueryException extends \Doctrine\ORM\ORMException public static function instanceOfUnrelatedClass($className, $rootClass) { return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " . - "inheritance hierarchy does not exists between these two classes."); + "inheritance hierarchy does not exists between these two classes."); } /** diff --git a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php index fe547081f..73a1b4dd1 100644 --- a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php +++ b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php @@ -147,8 +147,8 @@ class QueryExpressionVisitor extends ExpressionVisitor $parameterName = str_replace('.', '_', $comparison->getField()); - foreach($this->parameters as $parameter) { - if($parameter->getName() === $parameterName) { + foreach ($this->parameters as $parameter) { + if ($parameter->getName() === $parameterName) { $parameterName .= '_' . count($this->parameters); break; } @@ -160,36 +160,37 @@ class QueryExpressionVisitor extends ExpressionVisitor switch ($comparison->getOperator()) { case Comparison::IN: $this->parameters[] = $parameter; + return $this->expr->in($field, $placeholder); - case Comparison::NIN: $this->parameters[] = $parameter; + return $this->expr->notIn($field, $placeholder); - case Comparison::EQ: case Comparison::IS: if ($this->walkValue($comparison->getValue()) === null) { return $this->expr->isNull($field); } $this->parameters[] = $parameter; + return $this->expr->eq($field, $placeholder); - case Comparison::NEQ: if ($this->walkValue($comparison->getValue()) === null) { return $this->expr->isNotNull($field); } $this->parameters[] = $parameter; + return $this->expr->neq($field, $placeholder); - case Comparison::CONTAINS: $parameter->setValue('%' . $parameter->getValue() . '%', $parameter->getType()); $this->parameters[] = $parameter; + return $this->expr->like($field, $placeholder); - default: $operator = self::convertComparisonOperator($comparison->getOperator()); if ($operator) { $this->parameters[] = $parameter; + return new Expr\Comparison( $field, $operator, diff --git a/lib/Doctrine/ORM/Query/ResultSetMapping.php b/lib/Doctrine/ORM/Query/ResultSetMapping.php index 2fad66825..b80acf0cc 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMapping.php +++ b/lib/Doctrine/ORM/Query/ResultSetMapping.php @@ -171,8 +171,8 @@ class ResultSetMapping /** * Adds an entity result to this ResultSetMapping. * - * @param string $class The class name of the entity. - * @param string $alias The alias for the class. The alias must be unique among all entity + * @param string $class The class name of the entity. + * @param string $alias The alias for the class. The alias must be unique among all entity * results or joined entity results within this ResultSetMapping. * @param string|null $resultAlias The result alias with which the entity result should be * placed in the result structure. @@ -389,8 +389,8 @@ class ResultSetMapping /** * Adds a metadata parameter mappings. * - * @param mixed $parameter The parameter name in the SQL result set. - * @param string $attribute The metadata attribute. + * @param mixed $parameter The parameter name in the SQL result set. + * @param string $attribute The metadata attribute. */ public function addMetadataParameterMapping($parameter, $attribute) { @@ -551,11 +551,11 @@ class ResultSetMapping /** * Adds a meta column (foreign key or discriminator column) to the result set. * - * @param string $alias The result alias with which the meta result should be placed in the result structure. - * @param string $columnName The name of the column in the SQL result set. - * @param string $fieldName The name of the field on the declaring class. + * @param string $alias The result alias with which the meta result should be placed in the result structure. + * @param string $columnName The name of the column in the SQL result set. + * @param string $fieldName The name of the field on the declaring class. * @param bool $isIdentifierColumn - * @param string $type The column type + * @param string $type The column type * * @return ResultSetMapping This ResultSetMapping instance. * diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 6b647e590..97bfb4709 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -367,7 +367,7 @@ class ResultSetMappingBuilder extends ResultSetMapping /** * Adds the entity result mapping of the results of native SQL queries to the result set. - * + * * @param ClassMetadataInfo $classMetadata * @param array $entityMapping * @param string $alias @@ -408,7 +408,7 @@ class ResultSetMappingBuilder extends ResultSetMapping $this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name); } } else { - if( ! isset($classMetadata->fieldMappings[$fieldName])) { + if ( ! isset($classMetadata->fieldMappings[$fieldName])) { throw new \InvalidArgumentException("Entity '".$classMetadata->name."' has no field '".$fieldName."'. "); } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index b631ba6ae..92cb3d757 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -917,7 +917,7 @@ class SqlWalker implements TreeWalker $relation = $this->queryComponents[$joinedDqlAlias]['relation']; $targetClass = $this->em->getClassMetadata($relation['targetEntity']); $sourceClass = $this->em->getClassMetadata($relation['sourceEntity']); - $targetTableName = $this->quoteStrategy->getTableName($targetClass,$this->platform); + $targetTableName = $this->quoteStrategy->getTableName($targetClass, $this->platform); $targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName(), $joinedDqlAlias); $sourceTableAlias = $this->getSQLTableAlias($sourceClass->getTableName(), $associationPathExpression->identificationVariable); diff --git a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php index e95155c13..529d855aa 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php @@ -336,7 +336,7 @@ abstract class TreeWalkerAdapter implements TreeWalker /** * {@inheritdoc} */ - function walkInstanceOfExpression($instanceOfExpr) + public function walkInstanceOfExpression($instanceOfExpr) { } diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChain.php b/lib/Doctrine/ORM/Query/TreeWalkerChain.php index 19597ed1a..573ef88ff 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerChain.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerChain.php @@ -429,7 +429,7 @@ class TreeWalkerChain implements TreeWalker /** * {@inheritdoc} */ - function walkInstanceOfExpression($instanceOfExpr) + public function walkInstanceOfExpression($instanceOfExpr) { foreach ($this->_walkers as $walker) { $walker->walkInstanceOfExpression($instanceOfExpr); diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php b/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php index bad0de345..ee329604f 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php @@ -20,7 +20,7 @@ namespace Doctrine\ORM\Query; /** - * + * */ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess { @@ -51,7 +51,7 @@ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess /** * {@inheritdoc} */ - function rewind() + public function rewind() { return reset($this->walkers); } @@ -59,7 +59,7 @@ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess /** * {@inheritdoc} */ - function current() + public function current() { return $this->offsetGet(key($this->walkers)); } @@ -67,7 +67,7 @@ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess /** * {@inheritdoc} */ - function key() + public function key() { return key($this->walkers); } @@ -75,7 +75,7 @@ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess /** * {@inheritdoc} */ - function next() + public function next() { next($this->walkers); @@ -85,7 +85,7 @@ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess /** * {@inheritdoc} */ - function valid() + public function valid() { return key($this->walkers) !== null; } @@ -135,4 +135,4 @@ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess unset($this->walkers[$offset]); } } -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php index 2b6c91aed..bb0ca81b2 100644 --- a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php +++ b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php @@ -38,10 +38,10 @@ class AttachEntityListenersListener /** * Adds a entity listener for a specific entity. * - * @param string $entityClass The entity to attach the listener. - * @param string $listenerClass The listener class. - * @param string $eventName The entity lifecycle event. - * @param string $listenerCallback|null The listener callback method or NULL to use $eventName. + * @param string $entityClass The entity to attach the listener. + * @param string $listenerClass The listener class. + * @param string $eventName The entity lifecycle event. + * @param string|null $listenerCallback The listener callback method or NULL to use $eventName. * * @return void */ diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php index 80df37a64..f12bfa560 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php @@ -47,7 +47,7 @@ class CollectionRegionCommand extends Command ->addArgument('association', InputArgument::OPTIONAL, 'The association collection name.') ->addArgument('owner-id', InputArgument::OPTIONAL, 'The owner identifier.') ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') - ->addOption('flush', null, InputOption::VALUE_NONE,'If defined, all cache entries will be flushed.'); + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.'); $this->setHelp(<<writeln(sprintf('Clearing second-level cache for collection "%s#%s"', $ownerClass, $assoc)); $cache->evictCollectionRegion($ownerClass, $assoc); } -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php index 21f6e9de9..0258b7de2 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php @@ -46,7 +46,7 @@ class EntityRegionCommand extends Command ->addArgument('entity-class', InputArgument::OPTIONAL, 'The entity name.') ->addArgument('entity-id', InputArgument::OPTIONAL, 'The entity identifier.') ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') - ->addOption('flush', null, InputOption::VALUE_NONE,'If defined, all cache entries will be flushed.'); + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.'); $this->setHelp(<<writeln(sprintf('Clearing second-level cache for entity "%s"', $entityClass)); $cache->evictEntityRegion($entityClass); } -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php index b5d75d3b3..0637c7a4a 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php @@ -45,7 +45,7 @@ class QueryRegionCommand extends Command ->setDescription('Clear a second-level cache query region.') ->addArgument('region-name', InputArgument::OPTIONAL, 'The query region to clear.') ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all query regions will be deleted/invalidated.') - ->addOption('flush', null, InputOption::VALUE_NONE,'If defined, all cache entries will be flushed.'); + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.'); $this->setHelp(<<writeln(sprintf('Clearing second-level cache query region named "%s"', $name)); $cache->evictQueryRegion($name); } -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php index c6c139914..d0cb053e9 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php @@ -110,12 +110,12 @@ EOT if ($numRepositories) { // Outputting information message - $output->writeln(PHP_EOL . sprintf('Repository classes generated to "%s"', $destPath) ); + $output->writeln(PHP_EOL . sprintf('Repository classes generated to "%s"', $destPath)); } else { - $output->writeln('No Repository classes were found to be processed.' ); + $output->writeln('No Repository classes were found to be processed.'); } } else { - $output->writeln('No Metadata Classes to process.' ); + $output->writeln('No Metadata Classes to process.'); } } } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php index f23fe22c1..560d18718 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php @@ -46,7 +46,7 @@ The %command.name% shows basic information about which entities exist and possibly if their mapping information contains errors or not. EOT - ); + ); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index ab7ea5577..d80ac9451 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -257,7 +257,7 @@ EOT /** * Format the association mappings * - * @param array + * @param array $propertyMappings * * @return array */ diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php index 0aabd630c..dc7e7ec7e 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php @@ -65,6 +65,7 @@ abstract class AbstractCommand extends Command return $this->executeSchemaCommand($input, $output, $tool, $metadatas); } else { $output->writeln('No Metadata Classes to process.'); + return 0; } } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php index a0e942a34..d38684ca9 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -126,9 +126,9 @@ EOT } if ($force) { - if ($dumpSql) { + if ($dumpSql) { $output->writeln(''); - } + } $output->writeln('Updating database schema...'); $schemaTool->updateSchema($metadatas, $saveMode); diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index 55ec3791c..64f2abe69 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -65,7 +65,7 @@ class ConsoleRunner * optional commands. * * @param \Symfony\Component\Console\Helper\HelperSet $helperSet - * @param array $commands + * @param array $commands * * @return \Symfony\Component\Console\Application */ diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index 5196dc339..8c9a24f38 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -81,6 +81,7 @@ class DebugUnitOfWorkListener $fh = fopen($this->file, "x+"); if (count($identityMap) == 0) { fwrite($fh, "Flush Operation [".$this->context."] - Empty identity map.\n"); + return; } diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index 79022caa5..0fd7f3e84 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -1100,6 +1100,7 @@ public function __construct() } $annotations[] = '@' . $this->annotationsPrefix . $constraintName . '(name="' . $name . '", columns={' . implode(', ', $columns) . '})'; } + return implode(', ', $annotations); } @@ -1241,7 +1242,7 @@ public function __construct() } foreach ($joinColumns as $joinColumn) { - if(isset($joinColumn['nullable']) && !$joinColumn['nullable']) { + if (isset($joinColumn['nullable']) && !$joinColumn['nullable']) { return false; } } @@ -1811,12 +1812,14 @@ public function __construct() * Exports (nested) option elements. * * @param array $options + * + * @return string */ private function exportTableOptions(array $options) { $optionsStr = array(); - foreach($options as $name => $option) { + foreach ($options as $name => $option) { if (is_array($option)) { $optionsStr[] = '"' . $name . '"={' . $this->exportTableOptions($option) . '}'; } else { diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php index b2ed435bc..ae8650525 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php @@ -135,7 +135,7 @@ abstract class AbstractExporter foreach ($this->_metadata as $metadata) { // In case output is returned, write it to a file, skip otherwise - if($output = $this->exportClassMetadata($metadata)){ + if ($output = $this->exportClassMetadata($metadata)) { $path = $this->_generateOutputPath($metadata); $dir = dirname($path); if ( ! is_dir($dir)) { diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php index 6b53cbbaf..ba41d9986 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php @@ -108,7 +108,7 @@ class XmlExporter extends AbstractExporter $indexXml = $indexesXml->addChild('index'); $indexXml->addAttribute('name', $name); $indexXml->addAttribute('columns', implode(',', $index['columns'])); - if(isset($index['flags'])) { + if (isset($index['flags'])) { $indexXml->addAttribute('flags', implode(',', $index['flags'])); } } @@ -396,7 +396,7 @@ class XmlExporter extends AbstractExporter * Exports (nested) option elements. * * @param \SimpleXMLElement $parentXml - * @param array $options + * @param array $options */ private function exportTableOptions(\SimpleXMLElement $parentXml, array $options) { diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index a01f52a30..449aae1ca 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -110,6 +110,7 @@ class Paginator implements \Countable, \IteratorAggregate public function setUseOutputWalkers($useOutputWalkers) { $this->useOutputWalkers = $useOutputWalkers; + return $this; } @@ -121,7 +122,7 @@ class Paginator implements \Countable, \IteratorAggregate if ($this->count === null) { try { $this->count = array_sum(array_map('current', $this->getCountQuery()->getScalarResult())); - } catch(NoResultException $e) { + } catch (NoResultException $e) { $this->count = 0; } } @@ -216,7 +217,7 @@ class Paginator implements \Countable, \IteratorAggregate /** * Appends a custom tree walker to the tree walkers hint. * - * @param Query $query + * @param Query $query * @param string $walkerClass */ private function appendTreeWalker(Query $query, $walkerClass) @@ -267,7 +268,7 @@ class Paginator implements \Countable, \IteratorAggregate foreach ($parameters as $key => $parameter) { $parameterName = $parameter->getName(); - if( ! (isset($parameterMappings[$parameterName]) || array_key_exists($parameterName, $parameterMappings))) { + if ( ! (isset($parameterMappings[$parameterName]) || array_key_exists($parameterName, $parameterMappings))) { unset($parameters[$key]); } } diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 99e96c5ac..e38569ebe 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -109,6 +109,7 @@ class SchemaTool public function getCreateSchemaSql(array $classes) { $schema = $this->getSchemaFromMetadata($classes); + return $schema->toSql($this->platform); } @@ -278,11 +279,11 @@ class SchemaTool if (isset($class->table['indexes'])) { foreach ($class->table['indexes'] as $indexName => $indexData) { - if( ! isset($indexData['flags'])) { + if ( ! isset($indexData['flags'])) { $indexData['flags'] = array(); } - $table->addIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, (array)$indexData['flags'], isset($indexData['options']) ? $indexData['options'] : array()); + $table->addIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, (array) $indexData['flags'], isset($indexData['options']) ? $indexData['options'] : array()); } } @@ -622,7 +623,8 @@ class SchemaTool &$primaryKeyColumns, &$addedFks, &$blacklistedFks - ) { + ) + { $localColumns = array(); $foreignColumns = array(); $fkOptions = array(); diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 8f59ea72d..03222700c 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -97,6 +97,7 @@ class SchemaValidator foreach ($class->associationMappings as $fieldName => $assoc) { if (!class_exists($assoc['targetEntity']) || $cmf->isTransient($assoc['targetEntity'])) { $ce[] = "The target entity '" . $assoc['targetEntity'] . "' specified on " . $class->name . '#' . $fieldName . ' is unknown or not an entity.'; + return $ce; } @@ -154,13 +155,13 @@ class SchemaValidator // Verify inverse side/owning side match each other if (array_key_exists($assoc['inversedBy'], $targetMetadata->associationMappings)) { $targetAssoc = $targetMetadata->associationMappings[$assoc['inversedBy']]; - if ($assoc['type'] == ClassMetadataInfo::ONE_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_ONE){ + if ($assoc['type'] == ClassMetadataInfo::ONE_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_ONE) { $ce[] = "If association " . $class->name . "#" . $fieldName . " is one-to-one, then the inversed " . "side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be one-to-one as well."; - } elseif ($assoc['type'] == ClassMetadataInfo::MANY_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_MANY){ + } elseif ($assoc['type'] == ClassMetadataInfo::MANY_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_MANY) { $ce[] = "If association " . $class->name . "#" . $fieldName . " is many-to-one, then the inversed " . "side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be one-to-many."; - } elseif ($assoc['type'] == ClassMetadataInfo::MANY_TO_MANY && $targetAssoc['type'] !== ClassMetadataInfo::MANY_TO_MANY){ + } elseif ($assoc['type'] == ClassMetadataInfo::MANY_TO_MANY && $targetAssoc['type'] !== ClassMetadataInfo::MANY_TO_MANY) { $ce[] = "If association " . $class->name . "#" . $fieldName . " is many-to-many, then the inversed " . "side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be many-to-many as well."; } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 977606801..74c5afc1d 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -555,8 +555,8 @@ class UnitOfWork implements PropertyChangedListener * * @internal Don't call from the outside. * - * @param ClassMetadata $class The class descriptor of the entity. - * @param object $entity The entity for which to compute the changes. + * @param ClassMetadata $class The class descriptor of the entity. + * @param object $entity The entity for which to compute the changes. * * @return void */ @@ -800,8 +800,8 @@ class UnitOfWork implements PropertyChangedListener /** * Computes the changes of an association. * - * @param array $assoc The association mapping. - * @param mixed $value The value of the association. + * @param array $assoc The association mapping. + * @param mixed $value The value of the association. * * @throws ORMInvalidArgumentException * @throws ORMException @@ -871,7 +871,7 @@ class UnitOfWork implements PropertyChangedListener /** * @param \Doctrine\ORM\Mapping\ClassMetadata $class - * @param object $entity + * @param object $entity * * @return void */ @@ -1391,7 +1391,7 @@ class UnitOfWork implements PropertyChangedListener * * @ignore * - * @param object $entity The entity to register. + * @param object $entity The entity to register. * * @return boolean TRUE if the registration was successful, FALSE if the identity of * the entity in question is already managed. @@ -3224,7 +3224,7 @@ class UnitOfWork implements PropertyChangedListener */ private static function objToStr($obj) { - return method_exists($obj, '__toString') ? (string)$obj : get_class($obj).'@'.spl_object_hash($obj); + return method_exists($obj, '__toString') ? (string) $obj : get_class($obj).'@'.spl_object_hash($obj); } /**