1
0
mirror of synced 2025-01-29 19:41:45 +03:00

Coding style fixes.

This commit is contained in:
Guilherme Blanco 2012-03-15 01:26:06 -04:00
parent a16ca32981
commit 44d7d23e8d
3 changed files with 42 additions and 43 deletions

View File

@ -33,7 +33,6 @@ use Doctrine\DBAL\LockMode,
*/
final class Query extends AbstractQuery
{
/* Query STATES */
/**
* A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts.
*/
@ -108,6 +107,7 @@ final class Query extends AbstractQuery
*/
const HINT_LOCK_MODE = 'doctrine.lockMode';
/**
* @var integer $_state The current state of this query.
*/
@ -153,8 +153,6 @@ final class Query extends AbstractQuery
*/
private $_useQueryCache = true;
// End of Caching Stuff
/**
* Initializes a new Query instance.
*
@ -186,6 +184,7 @@ final class Query extends AbstractQuery
public function getAST()
{
$parser = new Parser($this);
return $parser->getAST();
}
@ -199,9 +198,7 @@ final class Query extends AbstractQuery
private function _parse()
{
// Return previous parser result if the query and the filter collection are both clean
if ($this->_state === self::STATE_CLEAN
&& $this->_em->isFiltersStateClean()
) {
if ($this->_state === self::STATE_CLEAN && $this->_em->isFiltersStateClean()) {
return $this->_parserResult;
}
@ -210,6 +207,7 @@ final class Query extends AbstractQuery
// Check query cache.
if ( ! ($this->_useQueryCache && ($queryCache = $this->getQueryCacheDriver()))) {
$parser = new Parser($this);
$this->_parserResult = $parser->parse();
return $this->_parserResult;
@ -227,7 +225,9 @@ final class Query extends AbstractQuery
// Cache miss.
$parser = new Parser($this);
$this->_parserResult = $parser->parse();
$queryCache->save($hash, $this->_parserResult, $this->_queryCacheTTL);
return $this->_parserResult;
@ -282,7 +282,9 @@ final class Query extends AbstractQuery
}
$sqlPositions = $paramMappings[$key];
// optimized multi value sql positions away for now, they are not allowed in DQL anyways.
// optimized multi value sql positions away for now,
// they are not allowed in DQL anyways.
$value = array($value);
$countValue = count($value);
@ -469,7 +471,7 @@ final class Query extends AbstractQuery
public function setFirstResult($firstResult)
{
$this->_firstResult = $firstResult;
$this->_state = self::STATE_DIRTY;
$this->_state = self::STATE_DIRTY;
return $this;
}
@ -494,7 +496,7 @@ final class Query extends AbstractQuery
public function setMaxResults($maxResults)
{
$this->_maxResults = $maxResults;
$this->_state = self::STATE_DIRTY;
$this->_state = self::STATE_DIRTY;
return $this;
}
@ -554,7 +556,7 @@ final class Query extends AbstractQuery
*/
public function setLockMode($lockMode)
{
if ($lockMode === LockMode::PESSIMISTIC_READ || $lockMode === LockMode::PESSIMISTIC_WRITE) {
if (in_array($lockMode, array(LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE))) {
if ( ! $this->_em->getConnection()->isTransactionActive()) {
throw TransactionRequiredException::transactionRequired();
}

View File

@ -193,7 +193,7 @@ class QueryBuilder
}
$this->_state = self::STATE_CLEAN;
$this->_dql = $dql;
$this->_dql = $dql;
return $dql;
}
@ -214,9 +214,9 @@ class QueryBuilder
public function getQuery()
{
return $this->_em->createQuery($this->getDQL())
->setParameters($this->_params, $this->_paramTypes)
->setFirstResult($this->_firstResult)
->setMaxResults($this->_maxResults);
->setParameters($this->_params, $this->_paramTypes)
->setFirstResult($this->_firstResult)
->setMaxResults($this->_maxResults);
}
/**
@ -225,8 +225,8 @@ class QueryBuilder
*
* <code>
* $qb = $em->createQueryBuilder()
* ->select('u')
* ->from('User', 'u');
* ->select('u')
* ->from('User', 'u');
*
* echo $qb->getRootAlias(); // u
* </code>
@ -326,12 +326,8 @@ class QueryBuilder
{
$key = trim($key, ':');
if ($type === null) {
$type = Query\ParameterTypeInferer::inferType($value);
}
$this->_paramTypes[$key] = $type;
$this->_params[$key] = $value;
$this->_paramTypes[$key] = $type ?: Query\ParameterTypeInferer::inferType($value);
$this->_params[$key] = $value;
return $this;
}
@ -450,13 +446,13 @@ class QueryBuilder
// TODO: Remove for 3.0
if ($dqlPartName == 'join') {
$newDqlPart = array();
foreach ($dqlPart AS $k => $v) {
if (is_numeric($k)) {
$newDqlPart[$this->getRootAlias()] = $v;
} else {
$newDqlPart[$k] = $v;
}
$k = is_numeric($k) ? $this->getRootAlias() : $k;
$newDqlPart[$k] = $v;
}
$dqlPart = $newDqlPart;
}
@ -520,6 +516,7 @@ class QueryBuilder
public function distinct($flag = true)
{
$this->_dqlParts['distinct'] = (bool) $flag;
return $this;
}
@ -791,7 +788,7 @@ class QueryBuilder
public function andWhere($where)
{
$where = $this->getDQLPart('where');
$args = func_get_args();
$args = func_get_args();
if ($where instanceof Expr\Andx) {
$where->addMultiple($args);
@ -822,7 +819,7 @@ class QueryBuilder
public function orWhere($where)
{
$where = $this->getDqlPart('where');
$args = func_get_args();
$args = func_get_args();
if ($where instanceof Expr\Orx) {
$where->addMultiple($args);
@ -899,7 +896,7 @@ class QueryBuilder
public function andHaving($having)
{
$having = $this->getDqlPart('having');
$args = func_get_args();
$args = func_get_args();
if ($having instanceof Expr\Andx) {
$having->addMultiple($args);
@ -921,7 +918,7 @@ class QueryBuilder
public function orHaving($having)
{
$having = $this->getDqlPart('having');
$args = func_get_args();
$args = func_get_args();
if ($having instanceof Expr\Orx) {
$having->addMultiple($args);
@ -943,8 +940,9 @@ class QueryBuilder
*/
public function orderBy($sort, $order = null)
{
return $this->add('orderBy', $sort instanceof Expr\OrderBy ? $sort
: new Expr\OrderBy($sort, $order));
$orderBy = ($sort instanceof Expr\OrderBy) ? $sort : new Expr\OrderBy($sort, $order);
return $this->add('orderBy', $orderBy);
}
/**
@ -1002,8 +1000,8 @@ class QueryBuilder
private function _getDQLForSelect()
{
$dql = 'SELECT'
. ($this->_dqlParts['distinct']===true ? ' DISTINCT' : '')
. $this->_getReducedDQLQueryPart('select', array('pre' => ' ', 'separator' => ', '));
. ($this->_dqlParts['distinct']===true ? ' DISTINCT' : '')
. $this->_getReducedDQLQueryPart('select', array('pre' => ' ', 'separator' => ', '));
$fromParts = $this->getDQLPart('from');
$joinParts = $this->getDQLPart('join');
@ -1059,9 +1057,11 @@ class QueryBuilder
if (is_null($parts)) {
$parts = array_keys($this->_dqlParts);
}
foreach ($parts as $part) {
$this->resetDQLPart($part);
}
return $this;
}
@ -1073,12 +1073,9 @@ class QueryBuilder
*/
public function resetDQLPart($part)
{
if (is_array($this->_dqlParts[$part])) {
$this->_dqlParts[$part] = array();
} else {
$this->_dqlParts[$part] = null;
}
$this->_state = self::STATE_DIRTY;
$this->_dqlParts[$part] = is_array($this->_dqlParts[$part]) ? array() : null;
$this->_state = self::STATE_DIRTY;
return $this;
}
@ -1107,7 +1104,7 @@ class QueryBuilder
$this->_dqlParts[$part][$idx] = clone $element;
}
}
} else if (\is_object($elements)) {
} else if (is_object($elements)) {
$this->_dqlParts[$part] = clone $elements;
}
}

View File

@ -48,7 +48,7 @@ class Version
public static function compare($version)
{
$currentVersion = str_replace(' ', '', strtolower(self::VERSION));
$version = str_replace(' ', '', $version);
$version = str_replace(' ', '', $version);
return version_compare($version, $currentVersion);
}