diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 3f9e477c7..b353828ae 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -804,7 +804,7 @@ class EntityManager implements ObjectManager */ public function getFilters() { - if(null === $this->filterCollection) { + if (null === $this->filterCollection) { $this->filterCollection = new FilterCollection($this); } @@ -814,7 +814,7 @@ class EntityManager implements ObjectManager /** * Checks whether the state of the filter collection is clean. * - * @return boolean True, iff the filter collection is clean. + * @return boolean True, if the filter collection is clean. */ public function isFiltersStateClean() { @@ -825,7 +825,7 @@ class EntityManager implements ObjectManager /** * Checks whether the Entity Manager has filters. * - * @return True, iff the EM has a filter collection. + * @return True, if the EM has a filter collection. */ public function hasFilters() { diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php index c58c4c3bf..9ce8acc69 100644 --- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -903,8 +903,11 @@ class BasicEntityPersister $alias = $this->_getSQLTableAlias($this->_class->name); - if('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) { - if($conditionSql) $conditionSql .= ' AND '; + if ('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) { + if ($conditionSql) { + $conditionSql .= ' AND '; + } + $conditionSql .= $filterSql; } @@ -1033,7 +1036,7 @@ class BasicEntityPersister } // Add filter SQL - if('' !== $filterSql = $this->generateFilterConditionSQL($eagerEntity, $tableAlias)) { + if ('' !== $filterSql = $this->generateFilterConditionSQL($eagerEntity, $tableAlias)) { $this->_selectJoinSql .= ' AND ' . $filterSql; } } else { @@ -1541,7 +1544,7 @@ class BasicEntityPersister . $this->getLockTablesSql($alias) . ' WHERE ' . $this->_getSelectConditionSQL($criteria); - if('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) { + if ('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) { $sql .= ' AND ' . $filterSql; } @@ -1559,8 +1562,8 @@ class BasicEntityPersister protected function getJoinSQLForJoinColumns($joinColumns) { // if one of the join columns is nullable, return left join - foreach($joinColumns as $joinColumn) { - if(isset($joinColumn['nullable']) && $joinColumn['nullable']){ + foreach ($joinColumns as $joinColumn) { + if (isset($joinColumn['nullable']) && $joinColumn['nullable']) { return 'LEFT JOIN'; } } @@ -1595,8 +1598,8 @@ class BasicEntityPersister { $filterClauses = array(); - foreach($this->_em->getFilters()->getEnabledFilters() as $filter) { - if('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { + foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) { + if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { $filterClauses[] = '(' . $filterExpr . ')'; } } diff --git a/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php index ad34f5c31..02d6ab75c 100644 --- a/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php @@ -329,9 +329,9 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister $joinSql .= $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn; - if($parentClass->name === $this->_class->rootEntityName) { + if ($parentClass->name === $this->_class->rootEntityName) { // Add filters on the root class - if('' !== $filterSql = $this->generateFilterConditionSQL($parentClass, $tableAlias)) { + if ('' !== $filterSql = $this->generateFilterConditionSQL($parentClass, $tableAlias)) { $joinSql .= ' AND ' . $filterSql; } } @@ -383,9 +383,12 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister $conditionSql = $this->_getSelectConditionSQL($criteria, $assoc); // If the current class in the root entity, add the filters - if($this->_class->name === $this->_class->rootEntityName) { - if('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $baseTableAlias)) { - if($conditionSql) $conditionSql .= ' AND '; + if ($this->_class->name === $this->_class->rootEntityName) { + if ('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $baseTableAlias)) { + if ($conditionSql) { + $conditionSql .= ' AND '; + } + $conditionSql .= $filterSql; } } diff --git a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php index e9f4b9820..bfb6ef08e 100644 --- a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php @@ -219,7 +219,7 @@ class ManyToManyPersister extends AbstractCollectionPersister } list($joinTargetEntitySQL, $filterSql) = $this->getFilterSql($mapping); - if('' !== $filterSql) { + if ('' !== $filterSql) { $whereClauses[] = $filterSql; } @@ -331,9 +331,9 @@ class ManyToManyPersister extends AbstractCollectionPersister : $sourceId[$sourceClass->fieldNames[$mapping['relationToSourceKeyColumns'][$joinTableColumn]]]; } - if($addFilters) { + if ($addFilters) { list($joinTargetEntitySQL, $filterSql) = $this->getFilterSql($mapping); - if('' !== $filterSql) { + if ('' !== $filterSql) { $quotedJoinTable .= ' t ' . $joinTargetEntitySQL; $whereClauses[] = $filterSql; } @@ -355,13 +355,13 @@ class ManyToManyPersister extends AbstractCollectionPersister // A join is needed if there is filtering on the target entity $joinTargetEntitySQL = ''; - if('' !== $filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) { + if ('' !== $filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) { $joinTargetEntitySQL = ' JOIN ' . $targetClass->getQuotedTableName($this->_conn->getDatabasePlatform()) . ' te' . ' ON'; $joinTargetEntitySQLClauses = array(); - foreach($mapping['relationToTargetKeyColumns'] as $joinTableColumn => $targetTableColumn) { + foreach ($mapping['relationToTargetKeyColumns'] as $joinTableColumn => $targetTableColumn) { $joinTargetEntitySQLClauses[] = ' t.' . $joinTableColumn . ' = ' . 'te.' . $targetTableColumn; } @@ -383,8 +383,8 @@ class ManyToManyPersister extends AbstractCollectionPersister { $filterClauses = array(); - foreach($this->_em->getFilters()->getEnabledFilters() as $filter) { - if('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { + foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) { + if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { $filterClauses[] = '(' . $filterExpr . ')'; } } diff --git a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php index 17575aaac..2fe1d5acb 100644 --- a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php @@ -121,8 +121,8 @@ class OneToManyPersister extends AbstractCollectionPersister : $id[$sourceClass->fieldNames[$joinColumn['referencedColumnName']]]; } - foreach($this->_em->getFilters()->getEnabledFilters() as $filter) { - if("" !== $filterExpr = $filter->addFilterConstraint($targetClass, 't')) { + foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) { + if ('' !== $filterExpr = $filter->addFilterConstraint($targetClass, 't')) { $whereClauses[] = '(' . $filterExpr . ')'; } } diff --git a/lib/Doctrine/ORM/Persisters/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/SingleTablePersister.php index cb005575f..39a6b4954 100644 --- a/lib/Doctrine/ORM/Persisters/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/SingleTablePersister.php @@ -138,7 +138,7 @@ class SingleTablePersister extends AbstractEntityInheritancePersister { // Ensure that the filters are applied to the root entity of the inheritance tree $realTargetEntity = $targetEntity; - if($targetEntity->name !== $targetEntity->rootEntityName) { + if ($targetEntity->name !== $targetEntity->rootEntityName) { $realTargetEntity = $this->_em->getClassMetadata($targetEntity->rootEntityName); } diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index 9be8628a2..772ef683b 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -49,7 +49,6 @@ abstract class SQLFilter * Constructs the SQLFilter object. * * @param EntityManager $em The EM - * @final */ final public function __construct(EntityManager $em) { @@ -63,7 +62,6 @@ abstract class SQLFilter * @param string $value Value of the parameter. * @param string $type Type of the parameter. * - * @final * @return SQLFilter The current SQL filter. */ final public function setParameter($name, $value, $type) @@ -88,12 +86,11 @@ abstract class SQLFilter * * @param string $name Name of the parameter. * - * @final * @return string The SQL escaped parameter to use in a query. */ final public function getParameter($name) { - if(!isset($this->parameters[$name])) { + if (!isset($this->parameters[$name])) { throw new \InvalidArgumentException("Parameter '" . $name . "' does not exist."); } @@ -103,8 +100,7 @@ abstract class SQLFilter /** * Returns as string representation of the SQLFilter parameters (the state). * - * @final - * @return string String representation of the the SQLFilter. + * @return string String representation of the SQLFilter. */ final public function __toString() { diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index 8e055ecdb..35c8d043c 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -103,11 +103,11 @@ class FilterCollection */ public function enable($name) { - if(null === $filterClass = $this->config->getFilterClassName($name)) { + if (null === $filterClass = $this->config->getFilterClassName($name)) { throw new \InvalidArgumentException("Filter '" . $name . "' does not exist."); } - if(!isset($this->enabledFilters[$name])) { + if (!isset($this->enabledFilters[$name])) { $this->enabledFilters[$name] = new $filterClass($this->em); // Keep the enabled filters sorted for the hash @@ -153,7 +153,7 @@ class FilterCollection */ public function getFilter($name) { - if(!isset($this->enabledFilters[$name])) { + if (!isset($this->enabledFilters[$name])) { throw new \InvalidArgumentException("Filter '" . $name . "' is not enabled."); } @@ -176,12 +176,12 @@ class FilterCollection public function getHash() { // If there are only clean filters, the previous hash can be returned - if(self::FILTERS_STATE_CLEAN === $this->filtersState) { + if (self::FILTERS_STATE_CLEAN === $this->filtersState) { return $this->filterHash; } $filterHash = ''; - foreach($this->enabledFilters as $name => $filter) { + foreach ($this->enabledFilters as $name => $filter) { $filterHash .= $name . $filter; } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index e6a08bf5a..ea834fc6a 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -365,9 +365,9 @@ class SqlWalker implements TreeWalker { $filterClauses = array(); - if($this->_em->hasFilters()) { - foreach($this->_em->getFilters()->getEnabledFilters() as $filter) { - if("" !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { + if ($this->_em->hasFilters()) { + foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) { + if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { $filterClauses[] = '(' . $filterExpr . ')'; } } @@ -827,9 +827,8 @@ class SqlWalker implements TreeWalker } // Apply the filters - if("" !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) { - if ( ! $first) $sql .= ' AND '; else $first = false; - $sql .= $filterExpr; + if ('' !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) { + $sql .= ' AND ' . $filterExpr; } } else if ($assoc['type'] == ClassMetadata::MANY_TO_MANY) { // Join relation table @@ -896,9 +895,8 @@ class SqlWalker implements TreeWalker } // Apply the filters - if("" !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) { - if ( ! $first) $sql .= ' AND '; else $first = false; - $sql .= $filterExpr; + if ('' !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) { + $sql .= ' AND ' . $filterExpr; } } @@ -1508,13 +1506,15 @@ class SqlWalker implements TreeWalker $class = $this->_queryComponents[$dqlAlias]['metadata']; $tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias); - if("" !== $filterExpr = $this->generateFilterConditionSQL($class, $tableAlias)) { + if ('' !== $filterExpr = $this->generateFilterConditionSQL($class, $tableAlias)) { $filterClauses[] = $filterExpr; } } if (count($filterClauses)) { - if($condSql) $condSql .= ' AND '; + if ($condSql) { + $condSql .= ' AND '; + } $condSql .= implode(' AND ', $filterClauses); }