1
0
mirror of synced 2024-12-13 06:46:03 +03:00

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

This commit is contained in:
guilhermeblanco 2009-08-06 15:48:41 +00:00
parent 401235d7ca
commit f087a0058b
4 changed files with 41 additions and 49 deletions

View File

@ -24,7 +24,13 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{

View File

@ -1,7 +1,22 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
/*
* $Id$
*
* 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;
@ -9,47 +24,27 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
private $_simpleArithmeticExpression;
private $_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 $simpleArithmeticExpression;
public $subselect;
public function isSimpleArithmeticExpression()
{
return (bool) $this->_simpleArithmeticExpression;
return (bool) $this->simpleArithmeticExpression;
}
public function isSubselect()
{
return (bool) $this->_subselect;
return (bool) $this->subselect;
}
public function dispatch($sqlWalker)

View File

@ -1900,14 +1900,14 @@ class Parser
if ($peek['type'] === Lexer::T_SELECT) {
$this->match('(');
$expr->setSubselect($this->Subselect());
$expr->subselect = $this->Subselect();
$this->match(')');
return $expr;
}
}
$expr->setSimpleArithmeticExpression($this->SimpleArithmeticExpression());
$expr->simpleArithmeticExpression = $this->SimpleArithmeticExpression();
return $expr;
}

View File

@ -30,7 +30,6 @@ use Doctrine\ORM\Query,
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
* @todo Code review for identifier quoting.
* @todo Code review for schema usage with table names.
* (Prepend schema name to tables IF schema is defined AND platform supports them)
*/
@ -1272,17 +1271,9 @@ class SqlWalker implements TreeWalker
*/
public function walkArithmeticExpression($arithmeticExpr)
{
$sql = '';
if ($arithmeticExpr->isSimpleArithmeticExpression()) {
foreach ($arithmeticExpr->getSimpleArithmeticExpression()->getArithmeticTerms() as $term) {
$sql .= $this->walkArithmeticTerm($term);
}
} else {
$sql .= $this->walkSubselect($arithmeticExpr->getSubselect());
}
return $sql;
return ($arithmeticExpr->isSimpleArithmeticExpression())
? $this->walkSimpleArithmeticExpression($arithmeticExpr->simpleArithmeticExpression)
: $this->walkSubselect($arithmeticExpr->subselect);
}
/**