Commit f83f5c3c authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Code reorganization, preparing for battle.

Fixes Strict error on EntityPersisterMock.
parent 60fb69dd
<?php
/*
* $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.phpdoctrine.org>.
*/
/**
* SelectClause = "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class Doctrine_ORM_Query_AST_SelectExpression extends Doctrine_ORM_Query_AST
{
protected $_expression;
protected $_fieldIdentificationVariable;
/* Setters */
public function setExpression($expression)
{
$this->_expression = $expression;
}
public function setFieldIdentificationVariable($fieldIdentificationVariable)
{
$this->_fieldIdentificationVariable = $fieldIdentificationVariable;
}
/* Getters */
public function getExpression()
{
return $this->_expression;
}
public function getFieldIdentificationVariable()
{
return $this->_fieldIdentificationVariable;
}
}
\ No newline at end of file
...@@ -131,10 +131,12 @@ class Doctrine_ORM_Query_Parser ...@@ -131,10 +131,12 @@ class Doctrine_ORM_Query_Parser
$this->_sqlBuilder = new Doctrine_ORM_Query_SqlBuilder($this->_em); $this->_sqlBuilder = new Doctrine_ORM_Query_SqlBuilder($this->_em);
$this->_keywordTable = new Doctrine_ORM_Query_Token(); $this->_keywordTable = new Doctrine_ORM_Query_Token();
$defaultQueryComponent = Doctrine_ORM_Query_ParserRule::DEFAULT_QUERYCOMPONENT;
$this->_parserResult = new Doctrine_ORM_Query_ParserResult( $this->_parserResult = new Doctrine_ORM_Query_ParserResult(
'', '',
array( // queryComponent array( // queryComponent
'dctrn' => array( $defaultQueryComponent => array(
'metadata' => null, 'metadata' => null,
'parent' => null, 'parent' => null,
'relation' => null, 'relation' => null,
...@@ -143,7 +145,7 @@ class Doctrine_ORM_Query_Parser ...@@ -143,7 +145,7 @@ class Doctrine_ORM_Query_Parser
), ),
), ),
array( // tableAliasMap array( // tableAliasMap
'dctrn' => 'dctrn', $defaultQueryComponent => $defaultQueryComponent,
) )
); );
...@@ -234,7 +236,7 @@ class Doctrine_ORM_Query_Parser ...@@ -234,7 +236,7 @@ class Doctrine_ORM_Query_Parser
// Building the Abstract Syntax Tree // Building the Abstract Syntax Tree
// We have to double the call of QueryLanguage to allow it to work correctly... =\ // We have to double the call of QueryLanguage to allow it to work correctly... =\
$DQL = new Doctrine_ORM_Query_Parser_QueryLanguage($this); $DQL = new Doctrine_ORM_Query_Parser_QueryLanguage($this);
$AST = $DQL->parse('QueryLanguage', Doctrine_ORM_Query_ParserParamHolder::create()); $AST = $DQL->parse('QueryLanguage');
// Check for end of string // Check for end of string
if ($this->lookahead !== null) { if ($this->lookahead !== null) {
......
...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_AbstractSchemaName extends Doctrine_ORM_Query_Pa ...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_AbstractSchemaName extends Doctrine_ORM_Query_Pa
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// AbstractSchemaName ::= identifier // AbstractSchemaName ::= identifier
$this->_AST = $this->AST('AbstractSchemaName'); $this->_AST = $this->AST('AbstractSchemaName');
...@@ -44,7 +44,7 @@ class Doctrine_ORM_Query_Parser_AbstractSchemaName extends Doctrine_ORM_Query_Pa ...@@ -44,7 +44,7 @@ class Doctrine_ORM_Query_Parser_AbstractSchemaName extends Doctrine_ORM_Query_Pa
} }
public function semantical($paramHolder) public function semantical()
{ {
$componentName = $this->_AST->getComponentName(); $componentName = $this->_AST->getComponentName();
...@@ -62,6 +62,6 @@ class Doctrine_ORM_Query_Parser_AbstractSchemaName extends Doctrine_ORM_Query_Pa ...@@ -62,6 +62,6 @@ class Doctrine_ORM_Query_Parser_AbstractSchemaName extends Doctrine_ORM_Query_Pa
protected function _isDoctrineEntity($componentName) protected function _isDoctrineEntity($componentName)
{ {
return class_exists($componentName)/* && is_subclass_of($componentName, 'Doctrine_ORM_Entity')*/; return class_exists($componentName)/* && class_implements($componentName, 'Doctrine_ORM_Entity')*/;
} }
} }
...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_AliasIdentificationVariable extends Doctrine_ORM ...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_AliasIdentificationVariable extends Doctrine_ORM
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// AliasIdentificationVariable = identifier // AliasIdentificationVariable = identifier
$this->_AST = $this->AST('AliasIdentificationVariable'); $this->_AST = $this->AST('AliasIdentificationVariable');
...@@ -44,7 +44,7 @@ class Doctrine_ORM_Query_Parser_AliasIdentificationVariable extends Doctrine_ORM ...@@ -44,7 +44,7 @@ class Doctrine_ORM_Query_Parser_AliasIdentificationVariable extends Doctrine_ORM
} }
public function semantical($paramHolder) public function semantical()
{ {
$parserResult = $this->_parser->getParserResult(); $parserResult = $this->_parser->getParserResult();
......
...@@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_DeleteStatement extends Doctrine_ORM_Query_Parse ...@@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_DeleteStatement extends Doctrine_ORM_Query_Parse
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// DeleteStatement ::= DeleteClause [WhereClause] // DeleteStatement ::= DeleteClause [WhereClause]
$this->_AST = $this->AST('DeleteStatement'); $this->_AST = $this->AST('DeleteStatement');
$this->_AST->setDeleteClause($this->parse('DeleteClause', $paramHolder)); $this->_AST->setDeleteClause($this->parse('DeleteClause'));
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_WHERE)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_WHERE)) {
$this->_AST->setWhereClause($this->parse('WhereClause', $paramHolder)); $this->_AST->setWhereClause($this->parse('WhereClause'));
} }
// Return AST node // Return AST node
......
...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_FieldIdentificationVariable extends Doctrine_ORM ...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_FieldIdentificationVariable extends Doctrine_ORM
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// FieldIdentificationVariable ::= identifier // FieldIdentificationVariable ::= identifier
$this->_AST = $this->AST('FieldIdentificationVariable'); $this->_AST = $this->AST('FieldIdentificationVariable');
...@@ -47,7 +47,7 @@ class Doctrine_ORM_Query_Parser_FieldIdentificationVariable extends Doctrine_ORM ...@@ -47,7 +47,7 @@ class Doctrine_ORM_Query_Parser_FieldIdentificationVariable extends Doctrine_ORM
} }
public function semantical($paramHolder) public function semantical()
{ {
$parserResult = $this->_parser->getParserResult(); $parserResult = $this->_parser->getParserResult();
......
...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_FromClause extends Doctrine_ORM_Query_ParserRule ...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_FromClause extends Doctrine_ORM_Query_ParserRule
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration} // FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}
$this->_AST = $this->AST('FromClause'); $this->_AST = $this->AST('FromClause');
...@@ -42,14 +42,14 @@ class Doctrine_ORM_Query_Parser_FromClause extends Doctrine_ORM_Query_ParserRule ...@@ -42,14 +42,14 @@ class Doctrine_ORM_Query_Parser_FromClause extends Doctrine_ORM_Query_ParserRule
$this->_parser->match(Doctrine_ORM_Query_Token::T_FROM); $this->_parser->match(Doctrine_ORM_Query_Token::T_FROM);
$this->_AST->addIdentificationVariableDeclaration( $this->_AST->addIdentificationVariableDeclaration(
$this->parse('IdentificationVariableDeclaration', $paramHolder) $this->parse('IdentificationVariableDeclaration')
); );
while ($this->_isNextToken(',')) { while ($this->_isNextToken(',')) {
$this->_parser->match(','); $this->_parser->match(',');
$this->_AST->addIdentificationVariableDeclaration( $this->_AST->addIdentificationVariableDeclaration(
$this->parse('IdentificationVariableDeclaration', $paramHolder) $this->parse('IdentificationVariableDeclaration')
); );
} }
......
...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_IdentificationVariable extends Doctrine_ORM_Quer ...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_IdentificationVariable extends Doctrine_ORM_Quer
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// IdentificationVariable ::= identifier // IdentificationVariable ::= identifier
$this->_AST = $this->AST('IdentificationVariable'); $this->_AST = $this->AST('IdentificationVariable');
...@@ -44,7 +44,7 @@ class Doctrine_ORM_Query_Parser_IdentificationVariable extends Doctrine_ORM_Quer ...@@ -44,7 +44,7 @@ class Doctrine_ORM_Query_Parser_IdentificationVariable extends Doctrine_ORM_Quer
} }
public function semantical($paramHolder) public function semantical()
{ {
$parserResult = $this->_parser->getParserResult(); $parserResult = $this->_parser->getParserResult();
......
...@@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_IdentificationVariableDeclaration extends Doctri ...@@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_IdentificationVariableDeclaration extends Doctri
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}* // IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
$this->_AST = $this->AST('IdentificationVariableDeclaration'); $this->_AST = $this->AST('IdentificationVariableDeclaration');
$this->_AST->setRangeVariableDeclaration($this->parse('RangeVariableDeclaration', $paramHolder)); $this->_AST->setRangeVariableDeclaration($this->parse('RangeVariableDeclaration'));
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_INDEX)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_INDEX)) {
$this->_AST->setIndexBy($this->parse('IndexBy', $paramHolder)); $this->_AST->setIndexBy($this->parse('IndexBy'));
} }
while ( while (
...@@ -50,12 +50,12 @@ class Doctrine_ORM_Query_Parser_IdentificationVariableDeclaration extends Doctri ...@@ -50,12 +50,12 @@ class Doctrine_ORM_Query_Parser_IdentificationVariableDeclaration extends Doctri
$this->_isNextToken(Doctrine_ORM_Query_Token::T_INNER) || $this->_isNextToken(Doctrine_ORM_Query_Token::T_INNER) ||
$this->_isNextToken(Doctrine_ORM_Query_Token::T_JOIN) $this->_isNextToken(Doctrine_ORM_Query_Token::T_JOIN)
) { ) {
$this->_AST->addJoinVariableDeclaration($this->parse('JoinVariableDeclaration', $paramHolder)); $this->_AST->addJoinVariableDeclaration($this->parse('JoinVariableDeclaration'));
} }
} }
public function semantical($paramHolder) public function semantical()
{ {
// If we have an INDEX BY RangeVariableDeclaration // If we have an INDEX BY RangeVariableDeclaration
if ($this->_AST->getIndexby() !== null) { if ($this->_AST->getIndexby() !== null) {
......
...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_IndexBy extends Doctrine_ORM_Query_ParserRule ...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_IndexBy extends Doctrine_ORM_Query_ParserRule
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression // IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression
$this->_AST = $this->AST('IndexBy'); $this->_AST = $this->AST('IndexBy');
...@@ -42,11 +42,11 @@ class Doctrine_ORM_Query_Parser_IndexBy extends Doctrine_ORM_Query_ParserRule ...@@ -42,11 +42,11 @@ class Doctrine_ORM_Query_Parser_IndexBy extends Doctrine_ORM_Query_ParserRule
$this->_parser->match(Doctrine_ORM_Query_Token::T_INDEX); $this->_parser->match(Doctrine_ORM_Query_Token::T_INDEX);
$this->_parser->match(Doctrine_ORM_Query_Token::T_BY); $this->_parser->match(Doctrine_ORM_Query_Token::T_BY);
$this->_AST->setSimpleStateFieldPathExpression($this->parse('SimpleStateFieldPathExpression', $paramHolder)); $this->_AST->setSimpleStateFieldPathExpression($this->parse('SimpleStateFieldPathExpression'));
} }
public function semantical($paramHolder) public function semantical()
{ {
// Retrieving required information // Retrieving required information
$parserResult = $this->_parser->getParserResult(); $parserResult = $this->_parser->getParserResult();
......
...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_Join extends Doctrine_ORM_Query_ParserRule ...@@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_Join extends Doctrine_ORM_Query_ParserRule
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression // Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression
// ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression] // ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]
...@@ -59,13 +59,13 @@ class Doctrine_ORM_Query_Parser_Join extends Doctrine_ORM_Query_ParserRule ...@@ -59,13 +59,13 @@ class Doctrine_ORM_Query_Parser_Join extends Doctrine_ORM_Query_ParserRule
$this->_parser->match(Doctrine_ORM_Query_Token::T_JOIN); $this->_parser->match(Doctrine_ORM_Query_Token::T_JOIN);
$this->_AST->setJoinAssociationPathExpression($this->parse('JoinAssociationPathExpression', $paramHolder)); $this->_AST->setJoinAssociationPathExpression($this->parse('JoinAssociationPathExpression'));
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_AS)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_AS)) {
$this->_parser->match(Doctrine_ORM_Query_Token::T_AS); $this->_parser->match(Doctrine_ORM_Query_Token::T_AS);
} }
$this->_AST->setAliasIdentificationVariable($this->parse('AliasIdentificationVariable', $paramHolder)); $this->_AST->setAliasIdentificationVariable($this->parse('AliasIdentificationVariable'));
// Check Join where type // Check Join where type
if ( if (
...@@ -82,7 +82,7 @@ class Doctrine_ORM_Query_Parser_Join extends Doctrine_ORM_Query_ParserRule ...@@ -82,7 +82,7 @@ class Doctrine_ORM_Query_Parser_Join extends Doctrine_ORM_Query_ParserRule
$this->_parser->match(Doctrine_ORM_Query_Token::T_WITH); $this->_parser->match(Doctrine_ORM_Query_Token::T_WITH);
} }
$this->_AST->setConditionalExpression($this->parse('ConditionalExpression', $paramHolder)); $this->_AST->setConditionalExpression($this->parse('ConditionalExpression'));
} }
// Return AST node // Return AST node
......
...@@ -34,20 +34,20 @@ class Doctrine_ORM_Query_Parser_JoinVariableDeclaration extends Doctrine_ORM_Que ...@@ -34,20 +34,20 @@ class Doctrine_ORM_Query_Parser_JoinVariableDeclaration extends Doctrine_ORM_Que
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// JoinVariableDeclaration ::= Join [IndexBy] // JoinVariableDeclaration ::= Join [IndexBy]
$this->_AST = $this->AST('JoinVariableDeclaration'); $this->_AST = $this->AST('JoinVariableDeclaration');
$this->_AST->setJoin($this->parse('Join', $paramHolder)); $this->_AST->setJoin($this->parse('Join'));
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_INDEX)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_INDEX)) {
$this->_AST->setIndexBy($this->parse('IndexBy', $paramHolder)); $this->_AST->setIndexBy($this->parse('IndexBy'));
} }
} }
public function semantical($paramHolder) public function semantical()
{ {
// If we have an INDEX BY JoinVariableDeclaration // If we have an INDEX BY JoinVariableDeclaration
if ($this->_AST->getIndexby() !== null) { if ($this->_AST->getIndexby() !== null) {
......
...@@ -33,20 +33,20 @@ ...@@ -33,20 +33,20 @@
*/ */
class Doctrine_ORM_Query_Parser_QueryLanguage extends Doctrine_ORM_Query_ParserRule class Doctrine_ORM_Query_Parser_QueryLanguage extends Doctrine_ORM_Query_ParserRule
{ {
public function syntax($paramHolder) public function syntax()
{ {
// QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement // QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement
switch ($this->_parser->lookahead['type']) { switch ($this->_parser->lookahead['type']) {
case Doctrine_ORM_Query_Token::T_SELECT: case Doctrine_ORM_Query_Token::T_SELECT:
return $this->parse('SelectStatement', $paramHolder); return $this->parse('SelectStatement');
break; break;
case Doctrine_ORM_Query_Token::T_UPDATE: case Doctrine_ORM_Query_Token::T_UPDATE:
return $this->parse('UpdateStatement', $paramHolder); return $this->parse('UpdateStatement');
break; break;
case Doctrine_ORM_Query_Token::T_DELETE: case Doctrine_ORM_Query_Token::T_DELETE:
return $this->parse('DeleteStatement', $paramHolder); return $this->parse('DeleteStatement');
break; break;
default: default:
......
...@@ -34,22 +34,22 @@ class Doctrine_ORM_Query_Parser_RangeVariableDeclaration extends Doctrine_ORM_Qu ...@@ -34,22 +34,22 @@ class Doctrine_ORM_Query_Parser_RangeVariableDeclaration extends Doctrine_ORM_Qu
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable // RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable
$this->_AST = $this->AST('RangeVariableDeclaration'); $this->_AST = $this->AST('RangeVariableDeclaration');
$this->_AST->setAbstractSchemaName($this->parse('AbstractSchemaName', $paramHolder)); $this->_AST->setAbstractSchemaName($this->parse('AbstractSchemaName'));
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_AS)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_AS)) {
$this->_parser->match(Doctrine_ORM_Query_Token::T_AS); $this->_parser->match(Doctrine_ORM_Query_Token::T_AS);
} }
$this->_AST->setAliasIdentificationVariable($this->parse('AliasIdentificationVariable', $paramHolder)); $this->_AST->setAliasIdentificationVariable($this->parse('AliasIdentificationVariable'));
} }
public function semantical($paramHolder) public function semantical()
{ {
$parserResult = $this->_parser->getParserResult(); $parserResult = $this->_parser->getParserResult();
$componentName = $this->_AST->getAbstractSchemaName()->getComponentName(); $componentName = $this->_AST->getAbstractSchemaName()->getComponentName();
......
...@@ -36,7 +36,7 @@ class Doctrine_ORM_Query_Parser_SelectClause extends Doctrine_ORM_Query_ParserRu ...@@ -36,7 +36,7 @@ class Doctrine_ORM_Query_Parser_SelectClause extends Doctrine_ORM_Query_ParserRu
protected $_selectExpressions = array(); protected $_selectExpressions = array();
public function syntax($paramHolder) public function syntax()
{ {
// SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression} // SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}
$this->_AST = $this->AST('SelectClause'); $this->_AST = $this->AST('SelectClause');
...@@ -51,21 +51,21 @@ class Doctrine_ORM_Query_Parser_SelectClause extends Doctrine_ORM_Query_ParserRu ...@@ -51,21 +51,21 @@ class Doctrine_ORM_Query_Parser_SelectClause extends Doctrine_ORM_Query_ParserRu
} }
// Process SelectExpressions (1..N) // Process SelectExpressions (1..N)
$this->_selectExpressions[] = $this->parse('SelectExpression', $paramHolder); $this->_selectExpressions[] = $this->parse('SelectExpression');
while ($this->_isNextToken(',')) { while ($this->_isNextToken(',')) {
$this->_parser->match(','); $this->_parser->match(',');
$this->_selectExpressions[] = $this->parse('SelectExpression', $paramHolder); $this->_selectExpressions[] = $this->parse('SelectExpression');
} }
} }
public function semantical($paramHolder) public function semantical()
{ {
// We need to validate each SelectExpression // We need to validate each SelectExpression
for ($i = 0, $l = count($this->_selectExpressions); $i < $l; $i++) { for ($i = 0, $l = count($this->_selectExpressions); $i < $l; $i++) {
$this->_AST->addSelectExpression($this->_selectExpressions[$i]->semantical($paramHolder)); $this->_AST->addSelectExpression($this->_selectExpressions[$i]->semantical());
} }
// Return AST node // Return AST node
......
...@@ -35,31 +35,60 @@ class Doctrine_ORM_Query_Parser_SelectExpression extends Doctrine_ORM_Query_Pars ...@@ -35,31 +35,60 @@ class Doctrine_ORM_Query_Parser_SelectExpression extends Doctrine_ORM_Query_Pars
{ {
protected $_AST = null; protected $_AST = null;
protected $_expression = null;
public function syntax($paramHolder) protected $_fieldIdentificationVariable = null;
public function syntax()
{ {
// SelectExpression ::= IdentificationVariable ["." "*"] | // SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression |
// (StateFieldPathExpression | AggregateExpression | "(" Subselect ")" ) // ( ( AggregateExpression | "(" Subselect ")" ) ["AS"] FieldIdentificationVariable )
// [["AS"] FieldIdentificationVariable]
// First we recognize for an IdentificationVariable (Component alias) // First we recognize for an IdentificationVariable (Component alias)
if ($this->_isIdentificationVariable()) { if ($this->_isIdentificationVariable()) {
$identificationVariable = $this->parse('IdentificationVariable', $paramHolder); $this->_expression = $this->parse('IdentificationVariable');
// Inspecting if we are in a ["." "*"] // Inspecting if we are in a ["." "*"]
if ($this->_isNextToken('.')) { if ($this->_isNextToken('.')) {
$this->_parser->match('.'); $this->_parser->match('.');
$this->_parser->match('*'); $this->_parser->match('*');
} }
} else if ($this->_isFunction() || $this->_isSubselect()) {
$this->_expression = $this->parse(
$this->_isFunction() ? 'AggregateExpression' : 'Subselect'
);
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_AS)) {
$this->_parser->match(Doctrine_ORM_Query_Token::T_AS);
}
$this->_fieldIdentificationVariable = $this->parse('FieldIdentificationVariable');
} else {
$this->_expression = $this->parse('StateFieldPathExpression');
}
}
public function semantical()
{
$expression = $this->_expression->semantical();
if ($this->_fieldIdentificationVariable !== null) {
$expr = $expression;
return $identificationVariable; $expression = $this->AST('SelectExpression');
$expression->setExpression($expr);
$expression->setFieldIdentificationVariable($this->_fieldIdentificationVariable->semantical());
} }
return $expression;
} }
protected function _isIdentificationVariable() protected function _isIdentificationVariable()
{ {
// Retrying to recoginize this grammar: IdentificationVariable ["." "*"] // Trying to recoginize this grammar: IdentificationVariable ["." "*"]
$token = $this->_parser->lookahead; $token = $this->_parser->lookahead;
$this->_parser->getScanner()->resetPeek(); $this->_parser->getScanner()->resetPeek();
......
...@@ -36,7 +36,7 @@ class Doctrine_ORM_Query_Parser_SelectStatement extends Doctrine_ORM_Query_Parse ...@@ -36,7 +36,7 @@ class Doctrine_ORM_Query_Parser_SelectStatement extends Doctrine_ORM_Query_Parse
protected $_selectClause = null; protected $_selectClause = null;
public function syntax($paramHolder) public function syntax()
{ {
// SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] // SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
$this->_AST = $this->AST('SelectStatement'); $this->_AST = $this->AST('SelectStatement');
...@@ -44,36 +44,36 @@ class Doctrine_ORM_Query_Parser_SelectStatement extends Doctrine_ORM_Query_Parse ...@@ -44,36 +44,36 @@ class Doctrine_ORM_Query_Parser_SelectStatement extends Doctrine_ORM_Query_Parse
// Disable the semantical check for SelectClause now. This is needed // Disable the semantical check for SelectClause now. This is needed
// since we dont know the query components yet (will be known only // since we dont know the query components yet (will be known only
// when the FROM and WHERE clause are processed). // when the FROM and WHERE clause are processed).
$paramHolder->set('semanticalCheck', false); $this->_dataHolder->set('semanticalCheck', false);
$this->_selectClause = $this->parse('SelectClause', $paramHolder); $this->_selectClause = $this->parse('SelectClause');
$paramHolder->remove('semanticalCheck'); $this->_dataHolder->remove('semanticalCheck');
$this->_AST->setFromClause($this->parse('FromClause', $paramHolder)); $this->_AST->setFromClause($this->parse('FromClause'));
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_WHERE)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_WHERE)) {
$this->_AST->setWhereClause($this->parse('WhereClause', $paramHolder)); $this->_AST->setWhereClause($this->parse('WhereClause'));
} }
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_GROUP)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_GROUP)) {
$this->_AST->setGroupByClause($this->parse('GroupByClause', $paramHolder)); $this->_AST->setGroupByClause($this->parse('GroupByClause'));
} }
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_HAVING)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_HAVING)) {
$this->_AST->setHavingClause($this->parse('HavingClause', $paramHolder)); $this->_AST->setHavingClause($this->parse('HavingClause'));
} }
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_ORDER)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_ORDER)) {
$this->_AST->setOrderByClause($this->parse('OrderByClause', $paramHolder)); $this->_AST->setOrderByClause($this->parse('OrderByClause'));
} }
} }
public function semantical($paramHolder) public function semantical()
{ {
// We need to invoke the semantical check of SelectClause here, since // We need to invoke the semantical check of SelectClause here, since
// it was not yet checked. // it was not yet checked.
// The semantical checks will be forwarded to all SelectClause dependant grammar rules // The semantical checks will be forwarded to all SelectClause dependant grammar rules
$this->_AST->setSelectClause($this->_selectClause->semantical($paramHolder)); $this->_AST->setSelectClause($this->_selectClause->semantical());
// Return AST node // Return AST node
return $this->_AST; return $this->_AST;
......
...@@ -34,9 +34,9 @@ class Doctrine_ORM_Query_Parser_SimpleStateField extends Doctrine_ORM_Query_Pars ...@@ -34,9 +34,9 @@ class Doctrine_ORM_Query_Parser_SimpleStateField extends Doctrine_ORM_Query_Pars
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// SimpleStateField ::= FieldIdentificationVariable // SimpleStateField ::= FieldIdentificationVariable
return $this->parse('FieldIdentificationVariable', $paramHolder); return $this->parse('FieldIdentificationVariable');
} }
} }
\ No newline at end of file
...@@ -34,20 +34,20 @@ class Doctrine_ORM_Query_Parser_SimpleStateFieldPathExpression extends Doctrine_ ...@@ -34,20 +34,20 @@ class Doctrine_ORM_Query_Parser_SimpleStateFieldPathExpression extends Doctrine_
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// SimpleStateFieldPathExpression ::= IdentificationVariable "." SimpleStateField // SimpleStateFieldPathExpression ::= IdentificationVariable "." SimpleStateField
$this->_AST = $this->AST('SimpleStateFieldPathExpression'); $this->_AST = $this->AST('SimpleStateFieldPathExpression');
$this->_AST->setIdentificationVariable($this->parse('IdentificationVariable', $paramHolder)); $this->_AST->setIdentificationVariable($this->parse('IdentificationVariable'));
$this->_parser->match('.'); $this->_parser->match('.');
$this->_AST->setSimpleStateField($this->parse('SimpleStateField', $paramHolder)); $this->_AST->setSimpleStateField($this->parse('SimpleStateField'));
} }
public function semantical($paramHolder) public function semantical()
{ {
$parserResult = $this->_parser->getParserResult(); $parserResult = $this->_parser->getParserResult();
$componentAlias = $this->_AST->getIdentificationVariable()->getComponentAlias(); $componentAlias = $this->_AST->getIdentificationVariable()->getComponentAlias();
......
...@@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_UpdateStatement extends Doctrine_ORM_Query_Parse ...@@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_UpdateStatement extends Doctrine_ORM_Query_Parse
protected $_AST = null; protected $_AST = null;
public function syntax($paramHolder) public function syntax()
{ {
// UpdateStatement ::= UpdateClause [WhereClause] // UpdateStatement ::= UpdateClause [WhereClause]
$this->_AST = $this->AST('UpdateStatement'); $this->_AST = $this->AST('UpdateStatement');
$this->_AST->setUpdateClause($this->parse('UpdateClause', $paramHolder)); $this->_AST->setUpdateClause($this->parse('UpdateClause'));
if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_WHERE)) { if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_WHERE)) {
$this->_AST->setWhereClause($this->parse('WhereClause', $paramHolder)); $this->_AST->setWhereClause($this->parse('WhereClause'));
} }
// Return AST node // Return AST node
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* @since 2.0 * @since 2.0
* @version $Revision$ * @version $Revision$
*/ */
class Doctrine_ORM_Query_ParserParamHolder class Doctrine_ORM_Query_ParserDataHolder
{ {
protected static $_instance; protected static $_instance;
......
...@@ -58,6 +58,13 @@ abstract class Doctrine_ORM_Query_ParserRule ...@@ -58,6 +58,13 @@ abstract class Doctrine_ORM_Query_ParserRule
*/ */
protected $_em; protected $_em;
/**
* The Parser Data Holder.
*
* @var ParserDataHolder
*/
protected $_dataHolder;
/** /**
* Creates a new production object. * Creates a new production object.
...@@ -68,6 +75,7 @@ abstract class Doctrine_ORM_Query_ParserRule ...@@ -68,6 +75,7 @@ abstract class Doctrine_ORM_Query_ParserRule
{ {
$this->_parser = $parser; $this->_parser = $parser;
$this->_em = $this->_parser->getEntityManager(); $this->_em = $this->_parser->getEntityManager();
$this->_dataHolder = Doctrine_ORM_Query_ParserDataHolder::create();
} }
...@@ -101,7 +109,7 @@ abstract class Doctrine_ORM_Query_ParserRule ...@@ -101,7 +109,7 @@ abstract class Doctrine_ORM_Query_ParserRule
* @param array $paramHolder Production parameter holder * @param array $paramHolder Production parameter holder
* @return Doctrine_ORM_Query_ParserRule * @return Doctrine_ORM_Query_ParserRule
*/ */
public function parse($RuleName, $paramHolder) public function parse($RuleName)
{ {
$BNFGrammarRule = $this->_getGrammarRule($RuleName); $BNFGrammarRule = $this->_getGrammarRule($RuleName);
...@@ -109,10 +117,10 @@ abstract class Doctrine_ORM_Query_ParserRule ...@@ -109,10 +117,10 @@ abstract class Doctrine_ORM_Query_ParserRule
//echo "Params: " . var_export($paramHolder, true) . "\n"; //echo "Params: " . var_export($paramHolder, true) . "\n";
// Syntax check // Syntax check
if ( ! $paramHolder->has('syntaxCheck') || $paramHolder->get('syntaxCheck') === true) { if ( ! $this->_dataHolder->has('syntaxCheck') || $this->_dataHolder->get('syntaxCheck') === true) {
//echo "Processing syntax checks of " . $RuleName . "...\n"; //echo "Processing syntax checks of " . $RuleName . "...\n";
$return = $BNFGrammarRule->syntax($paramHolder); $return = $BNFGrammarRule->syntax();
if ($return !== null) { if ($return !== null) {
//echo "Returning Gramma Rule class: " . (is_object($return) ? get_class($return) : $return) . "...\n"; //echo "Returning Gramma Rule class: " . (is_object($return) ? get_class($return) : $return) . "...\n";
...@@ -122,10 +130,10 @@ abstract class Doctrine_ORM_Query_ParserRule ...@@ -122,10 +130,10 @@ abstract class Doctrine_ORM_Query_ParserRule
} }
// Semantical check // Semantical check
if ( ! $paramHolder->has('semanticalCheck') || $paramHolder->get('semanticalCheck') === true) { if ( ! $this->_dataHolder->has('semanticalCheck') || $this->_dataHolder->get('semanticalCheck') === true) {
//echo "Processing semantical checks of " . $RuleName . "...\n"; //echo "Processing semantical checks of " . $RuleName . "...\n";
$return = $BNFGrammarRule->semantical($paramHolder); $return = $BNFGrammarRule->semantical();
if ($return !== null) { if ($return !== null) {
//echo "Returning Gramma Rule class: " . (is_object($return) ? get_class($return) : $return) . "...\n"; //echo "Returning Gramma Rule class: " . (is_object($return) ? get_class($return) : $return) . "...\n";
...@@ -185,13 +193,13 @@ abstract class Doctrine_ORM_Query_ParserRule ...@@ -185,13 +193,13 @@ abstract class Doctrine_ORM_Query_ParserRule
/** /**
* @nodoc * @nodoc
*/ */
abstract public function syntax($paramHolder); abstract public function syntax();
/** /**
* @nodoc * @nodoc
*/ */
public function semantical($paramHolder) public function semantical()
{ {
} }
...@@ -199,4 +207,9 @@ abstract class Doctrine_ORM_Query_ParserRule ...@@ -199,4 +207,9 @@ abstract class Doctrine_ORM_Query_ParserRule
{ {
return $this->_parser; return $this->_parser;
} }
public function getDataHolder()
{
return $this->_dataHolder;
}
} }
...@@ -32,12 +32,12 @@ class Doctrine_EntityPersisterMock extends Doctrine_ORM_Persisters_StandardEntit ...@@ -32,12 +32,12 @@ class Doctrine_EntityPersisterMock extends Doctrine_ORM_Persisters_StandardEntit
$this->_mockIdGeneratorType = $genType; $this->_mockIdGeneratorType = $genType;
} }
public function update(Doctrine_ORM_Entity $entity) public function update($entity)
{ {
$this->_updates[] = $entity; $this->_updates[] = $entity;
} }
public function delete(Doctrine_ORM_Entity $entity) public function delete($entity)
{ {
$this->_deletes[] = $entity; $this->_deletes[] = $entity;
} }
......
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