Commit f087a005 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Started refactoring of AST nodes to use public properties instead of getter/setter methods

parent 401235d7
...@@ -24,7 +24,13 @@ namespace Doctrine\ORM\Query\AST; ...@@ -24,7 +24,13 @@ namespace Doctrine\ORM\Query\AST;
/** /**
* Description of AggregateExpression * Description of AggregateExpression
* *
* @author robo * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/ */
class AggregateExpression extends Node class AggregateExpression extends Node
{ {
......
<?php <?php
/* /*
* To change this template, choose Tools | Templates * $Id$
* and open the template in the editor. *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Query\AST; namespace Doctrine\ORM\Query\AST;
...@@ -9,47 +24,27 @@ namespace Doctrine\ORM\Query\AST; ...@@ -9,47 +24,27 @@ namespace Doctrine\ORM\Query\AST;
/** /**
* ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")" * ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")"
* *
* @author robo * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/ */
class ArithmeticExpression extends Node class ArithmeticExpression extends Node
{ {
private $_simpleArithmeticExpression; public $simpleArithmeticExpression;
private $_subselect; public $subselect;
public function setSimpleArithmeticExpression($simpleArithmeticExpr)
{
if ($this->_subselect) {
throw \Doctrine\Common\DoctrineException::updateMe();
}
$this->_simpleArithmeticExpression = $simpleArithmeticExpr;
}
public function setSubselect($subselect)
{
if ($this->_simpleArithmeticExpression){
throw \Doctrine\Common\DoctrineException::updateMe();
}
$this->_subselect = $subselect;
}
public function getSimpleArithmeticExpression()
{
return $this->_simpleArithmeticExpression;
}
public function getSubselect()
{
return $this->_subselect;
}
public function isSimpleArithmeticExpression() public function isSimpleArithmeticExpression()
{ {
return (bool) $this->_simpleArithmeticExpression; return (bool) $this->simpleArithmeticExpression;
} }
public function isSubselect() public function isSubselect()
{ {
return (bool) $this->_subselect; return (bool) $this->subselect;
} }
public function dispatch($sqlWalker) public function dispatch($sqlWalker)
......
...@@ -1900,14 +1900,14 @@ class Parser ...@@ -1900,14 +1900,14 @@ class Parser
if ($peek['type'] === Lexer::T_SELECT) { if ($peek['type'] === Lexer::T_SELECT) {
$this->match('('); $this->match('(');
$expr->setSubselect($this->Subselect()); $expr->subselect = $this->Subselect();
$this->match(')'); $this->match(')');
return $expr; return $expr;
} }
} }
$expr->setSimpleArithmeticExpression($this->SimpleArithmeticExpression()); $expr->simpleArithmeticExpression = $this->SimpleArithmeticExpression();
return $expr; return $expr;
} }
......
...@@ -30,7 +30,6 @@ use Doctrine\ORM\Query, ...@@ -30,7 +30,6 @@ use Doctrine\ORM\Query,
* *
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
* @todo Code review for identifier quoting.
* @todo Code review for schema usage with table names. * @todo Code review for schema usage with table names.
* (Prepend schema name to tables IF schema is defined AND platform supports them) * (Prepend schema name to tables IF schema is defined AND platform supports them)
*/ */
...@@ -1272,17 +1271,9 @@ class SqlWalker implements TreeWalker ...@@ -1272,17 +1271,9 @@ class SqlWalker implements TreeWalker
*/ */
public function walkArithmeticExpression($arithmeticExpr) public function walkArithmeticExpression($arithmeticExpr)
{ {
$sql = ''; return ($arithmeticExpr->isSimpleArithmeticExpression())
? $this->walkSimpleArithmeticExpression($arithmeticExpr->simpleArithmeticExpression)
if ($arithmeticExpr->isSimpleArithmeticExpression()) { : $this->walkSubselect($arithmeticExpr->subselect);
foreach ($arithmeticExpr->getSimpleArithmeticExpression()->getArithmeticTerms() as $term) {
$sql .= $this->walkArithmeticTerm($term);
}
} else {
$sql .= $this->walkSubselect($arithmeticExpr->getSubselect());
}
return $sql;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment