[2.0] Code reorganization, preparing for battle.
Fixes Strict error on EntityPersisterMock.
This commit is contained in:
parent
60fb69dd03
commit
f83f5c3c89
23 changed files with 193 additions and 89 deletions
lib/Doctrine/ORM/Query
AST
Parser.phpParser
AbstractSchemaName.phpAliasIdentificationVariable.phpDeleteStatement.phpFieldIdentificationVariable.phpFromClause.phpIdentificationVariable.phpIdentificationVariableDeclaration.phpIndexBy.phpJoin.phpJoinVariableDeclaration.phpQueryLanguage.phpRangeVariableDeclaration.phpSelectClause.phpSelectExpression.phpSelectStatement.phpSimpleStateField.phpSimpleStateFieldPathExpression.phpUpdateStatement.php
ParserDataHolder.phpParserRule.phptests/lib/mocks
60
lib/Doctrine/ORM/Query/AST/SelectExpression.php
Normal file
60
lib/Doctrine/ORM/Query/AST/SelectExpression.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
|
@ -130,11 +130,13 @@ class Doctrine_ORM_Query_Parser
|
|||
$this->_scanner = new Doctrine_ORM_Query_Scanner($this->_input);
|
||||
$this->_sqlBuilder = new Doctrine_ORM_Query_SqlBuilder($this->_em);
|
||||
$this->_keywordTable = new Doctrine_ORM_Query_Token();
|
||||
|
||||
$defaultQueryComponent = Doctrine_ORM_Query_ParserRule::DEFAULT_QUERYCOMPONENT;
|
||||
|
||||
$this->_parserResult = new Doctrine_ORM_Query_ParserResult(
|
||||
'',
|
||||
array( // queryComponent
|
||||
'dctrn' => array(
|
||||
$defaultQueryComponent => array(
|
||||
'metadata' => null,
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
|
@ -143,7 +145,7 @@ class Doctrine_ORM_Query_Parser
|
|||
),
|
||||
),
|
||||
array( // tableAliasMap
|
||||
'dctrn' => 'dctrn',
|
||||
$defaultQueryComponent => $defaultQueryComponent,
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -234,7 +236,7 @@ class Doctrine_ORM_Query_Parser
|
|||
// Building the Abstract Syntax Tree
|
||||
// We have to double the call of QueryLanguage to allow it to work correctly... =\
|
||||
$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
|
||||
if ($this->lookahead !== null) {
|
||||
|
|
|
@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_AbstractSchemaName extends Doctrine_ORM_Query_Pa
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// AbstractSchemaName ::= identifier
|
||||
$this->_AST = $this->AST('AbstractSchemaName');
|
||||
|
@ -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();
|
||||
|
||||
|
@ -62,6 +62,6 @@ class Doctrine_ORM_Query_Parser_AbstractSchemaName extends Doctrine_ORM_Query_Pa
|
|||
|
||||
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
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// AliasIdentificationVariable = identifier
|
||||
$this->_AST = $this->AST('AliasIdentificationVariable');
|
||||
|
@ -44,7 +44,7 @@ class Doctrine_ORM_Query_Parser_AliasIdentificationVariable extends Doctrine_ORM
|
|||
}
|
||||
|
||||
|
||||
public function semantical($paramHolder)
|
||||
public function semantical()
|
||||
{
|
||||
$parserResult = $this->_parser->getParserResult();
|
||||
|
||||
|
|
|
@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_DeleteStatement extends Doctrine_ORM_Query_Parse
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// DeleteStatement ::= DeleteClause [WhereClause]
|
||||
$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)) {
|
||||
$this->_AST->setWhereClause($this->parse('WhereClause', $paramHolder));
|
||||
$this->_AST->setWhereClause($this->parse('WhereClause'));
|
||||
}
|
||||
|
||||
// Return AST node
|
||||
|
|
|
@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_FieldIdentificationVariable extends Doctrine_ORM
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// FieldIdentificationVariable ::= identifier
|
||||
$this->_AST = $this->AST('FieldIdentificationVariable');
|
||||
|
@ -47,7 +47,7 @@ class Doctrine_ORM_Query_Parser_FieldIdentificationVariable extends Doctrine_ORM
|
|||
}
|
||||
|
||||
|
||||
public function semantical($paramHolder)
|
||||
public function semantical()
|
||||
{
|
||||
$parserResult = $this->_parser->getParserResult();
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_FromClause extends Doctrine_ORM_Query_ParserRule
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}
|
||||
$this->_AST = $this->AST('FromClause');
|
||||
|
@ -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->_AST->addIdentificationVariableDeclaration(
|
||||
$this->parse('IdentificationVariableDeclaration', $paramHolder)
|
||||
$this->parse('IdentificationVariableDeclaration')
|
||||
);
|
||||
|
||||
while ($this->_isNextToken(',')) {
|
||||
$this->_parser->match(',');
|
||||
|
||||
$this->_AST->addIdentificationVariableDeclaration(
|
||||
$this->parse('IdentificationVariableDeclaration', $paramHolder)
|
||||
$this->parse('IdentificationVariableDeclaration')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_IdentificationVariable extends Doctrine_ORM_Quer
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// IdentificationVariable ::= identifier
|
||||
$this->_AST = $this->AST('IdentificationVariable');
|
||||
|
@ -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();
|
||||
|
||||
|
|
|
@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_IdentificationVariableDeclaration extends Doctri
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
|
||||
$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)) {
|
||||
$this->_AST->setIndexBy($this->parse('IndexBy', $paramHolder));
|
||||
$this->_AST->setIndexBy($this->parse('IndexBy'));
|
||||
}
|
||||
|
||||
while (
|
||||
|
@ -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_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 ($this->_AST->getIndexby() !== null) {
|
||||
|
|
|
@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_IndexBy extends Doctrine_ORM_Query_ParserRule
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression
|
||||
$this->_AST = $this->AST('IndexBy');
|
||||
|
@ -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_BY);
|
||||
|
||||
$this->_AST->setSimpleStateFieldPathExpression($this->parse('SimpleStateFieldPathExpression', $paramHolder));
|
||||
$this->_AST->setSimpleStateFieldPathExpression($this->parse('SimpleStateFieldPathExpression'));
|
||||
}
|
||||
|
||||
|
||||
public function semantical($paramHolder)
|
||||
public function semantical()
|
||||
{
|
||||
// Retrieving required information
|
||||
$parserResult = $this->_parser->getParserResult();
|
||||
|
|
|
@ -34,7 +34,7 @@ class Doctrine_ORM_Query_Parser_Join extends Doctrine_ORM_Query_ParserRule
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression
|
||||
// ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]
|
||||
|
@ -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->_AST->setJoinAssociationPathExpression($this->parse('JoinAssociationPathExpression', $paramHolder));
|
||||
$this->_AST->setJoinAssociationPathExpression($this->parse('JoinAssociationPathExpression'));
|
||||
|
||||
if ($this->_isNextToken(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
|
||||
if (
|
||||
|
@ -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->_AST->setConditionalExpression($this->parse('ConditionalExpression', $paramHolder));
|
||||
$this->_AST->setConditionalExpression($this->parse('ConditionalExpression'));
|
||||
}
|
||||
|
||||
// Return AST node
|
||||
|
|
|
@ -34,20 +34,20 @@ class Doctrine_ORM_Query_Parser_JoinVariableDeclaration extends Doctrine_ORM_Que
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// JoinVariableDeclaration ::= Join [IndexBy]
|
||||
$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)) {
|
||||
$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 ($this->_AST->getIndexby() !== null) {
|
||||
|
|
|
@ -33,20 +33,20 @@
|
|||
*/
|
||||
class Doctrine_ORM_Query_Parser_QueryLanguage extends Doctrine_ORM_Query_ParserRule
|
||||
{
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement
|
||||
switch ($this->_parser->lookahead['type']) {
|
||||
case Doctrine_ORM_Query_Token::T_SELECT:
|
||||
return $this->parse('SelectStatement', $paramHolder);
|
||||
return $this->parse('SelectStatement');
|
||||
break;
|
||||
|
||||
case Doctrine_ORM_Query_Token::T_UPDATE:
|
||||
return $this->parse('UpdateStatement', $paramHolder);
|
||||
return $this->parse('UpdateStatement');
|
||||
break;
|
||||
|
||||
case Doctrine_ORM_Query_Token::T_DELETE:
|
||||
return $this->parse('DeleteStatement', $paramHolder);
|
||||
return $this->parse('DeleteStatement');
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -34,22 +34,22 @@ class Doctrine_ORM_Query_Parser_RangeVariableDeclaration extends Doctrine_ORM_Qu
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable
|
||||
$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)) {
|
||||
$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();
|
||||
$componentName = $this->_AST->getAbstractSchemaName()->getComponentName();
|
||||
|
|
|
@ -36,7 +36,7 @@ class Doctrine_ORM_Query_Parser_SelectClause extends Doctrine_ORM_Query_ParserRu
|
|||
protected $_selectExpressions = array();
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}
|
||||
$this->_AST = $this->AST('SelectClause');
|
||||
|
@ -51,21 +51,21 @@ class Doctrine_ORM_Query_Parser_SelectClause extends Doctrine_ORM_Query_ParserRu
|
|||
}
|
||||
|
||||
// Process SelectExpressions (1..N)
|
||||
$this->_selectExpressions[] = $this->parse('SelectExpression', $paramHolder);
|
||||
$this->_selectExpressions[] = $this->parse('SelectExpression');
|
||||
|
||||
while ($this->_isNextToken(',')) {
|
||||
$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
|
||||
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
|
||||
|
|
|
@ -35,31 +35,60 @@ class Doctrine_ORM_Query_Parser_SelectExpression extends Doctrine_ORM_Query_Pars
|
|||
{
|
||||
protected $_AST = null;
|
||||
|
||||
protected $_expression = null;
|
||||
|
||||
protected $_fieldIdentificationVariable = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// SelectExpression ::= IdentificationVariable ["." "*"] |
|
||||
// (StateFieldPathExpression | AggregateExpression | "(" Subselect ")" )
|
||||
// [["AS"] FieldIdentificationVariable]
|
||||
|
||||
// SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression |
|
||||
// ( ( AggregateExpression | "(" Subselect ")" ) ["AS"] FieldIdentificationVariable )
|
||||
|
||||
// First we recognize for an IdentificationVariable (Component alias)
|
||||
if ($this->_isIdentificationVariable()) {
|
||||
$identificationVariable = $this->parse('IdentificationVariable', $paramHolder);
|
||||
|
||||
$this->_expression = $this->parse('IdentificationVariable');
|
||||
|
||||
// Inspecting if we are in a ["." "*"]
|
||||
if ($this->_isNextToken('.')) {
|
||||
$this->_parser->match('.');
|
||||
$this->_parser->match('*');
|
||||
}
|
||||
|
||||
return $identificationVariable;
|
||||
} 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;
|
||||
|
||||
$expression = $this->AST('SelectExpression');
|
||||
$expression->setExpression($expr);
|
||||
$expression->setFieldIdentificationVariable($this->_fieldIdentificationVariable->semantical());
|
||||
}
|
||||
|
||||
return $expression;
|
||||
}
|
||||
|
||||
|
||||
protected function _isIdentificationVariable()
|
||||
{
|
||||
// Retrying to recoginize this grammar: IdentificationVariable ["." "*"]
|
||||
// Trying to recoginize this grammar: IdentificationVariable ["." "*"]
|
||||
$token = $this->_parser->lookahead;
|
||||
$this->_parser->getScanner()->resetPeek();
|
||||
|
||||
|
@ -70,7 +99,7 @@ class Doctrine_ORM_Query_Parser_SelectExpression extends Doctrine_ORM_Query_Pars
|
|||
// If we have a dot ".", then next char must be the "*"
|
||||
if ($token['value'] === '.') {
|
||||
$token = $this->_parser->getScanner()->peek();
|
||||
|
||||
|
||||
return $token['value'] === '*';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class Doctrine_ORM_Query_Parser_SelectStatement extends Doctrine_ORM_Query_Parse
|
|||
protected $_selectClause = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
|
||||
$this->_AST = $this->AST('SelectStatement');
|
||||
|
@ -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
|
||||
// since we dont know the query components yet (will be known only
|
||||
// when the FROM and WHERE clause are processed).
|
||||
$paramHolder->set('semanticalCheck', false);
|
||||
$this->_selectClause = $this->parse('SelectClause', $paramHolder);
|
||||
$paramHolder->remove('semanticalCheck');
|
||||
$this->_dataHolder->set('semanticalCheck', false);
|
||||
$this->_selectClause = $this->parse('SelectClause');
|
||||
$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)) {
|
||||
$this->_AST->setWhereClause($this->parse('WhereClause', $paramHolder));
|
||||
$this->_AST->setWhereClause($this->parse('WhereClause'));
|
||||
}
|
||||
|
||||
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)) {
|
||||
$this->_AST->setHavingClause($this->parse('HavingClause', $paramHolder));
|
||||
$this->_AST->setHavingClause($this->parse('HavingClause'));
|
||||
}
|
||||
|
||||
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
|
||||
// it was not yet checked.
|
||||
// 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 $this->_AST;
|
||||
|
|
|
@ -34,9 +34,9 @@ class Doctrine_ORM_Query_Parser_SimpleStateField extends Doctrine_ORM_Query_Pars
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// SimpleStateField ::= FieldIdentificationVariable
|
||||
return $this->parse('FieldIdentificationVariable', $paramHolder);
|
||||
return $this->parse('FieldIdentificationVariable');
|
||||
}
|
||||
}
|
|
@ -34,20 +34,20 @@ class Doctrine_ORM_Query_Parser_SimpleStateFieldPathExpression extends Doctrine_
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// SimpleStateFieldPathExpression ::= IdentificationVariable "." SimpleStateField
|
||||
$this->_AST = $this->AST('SimpleStateFieldPathExpression');
|
||||
|
||||
$this->_AST->setIdentificationVariable($this->parse('IdentificationVariable', $paramHolder));
|
||||
$this->_AST->setIdentificationVariable($this->parse('IdentificationVariable'));
|
||||
|
||||
$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();
|
||||
$componentAlias = $this->_AST->getIdentificationVariable()->getComponentAlias();
|
||||
|
|
|
@ -34,15 +34,15 @@ class Doctrine_ORM_Query_Parser_UpdateStatement extends Doctrine_ORM_Query_Parse
|
|||
protected $_AST = null;
|
||||
|
||||
|
||||
public function syntax($paramHolder)
|
||||
public function syntax()
|
||||
{
|
||||
// UpdateStatement ::= UpdateClause [WhereClause]
|
||||
$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)) {
|
||||
$this->_AST->setWhereClause($this->parse('WhereClause', $paramHolder));
|
||||
$this->_AST->setWhereClause($this->parse('WhereClause'));
|
||||
}
|
||||
|
||||
// Return AST node
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* @since 2.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_ORM_Query_ParserParamHolder
|
||||
class Doctrine_ORM_Query_ParserDataHolder
|
||||
{
|
||||
protected static $_instance;
|
||||
|
|
@ -57,6 +57,13 @@ abstract class Doctrine_ORM_Query_ParserRule
|
|||
* @var EntityManager
|
||||
*/
|
||||
protected $_em;
|
||||
|
||||
/**
|
||||
* The Parser Data Holder.
|
||||
*
|
||||
* @var ParserDataHolder
|
||||
*/
|
||||
protected $_dataHolder;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -68,6 +75,7 @@ abstract class Doctrine_ORM_Query_ParserRule
|
|||
{
|
||||
$this->_parser = $parser;
|
||||
$this->_em = $this->_parser->getEntityManager();
|
||||
$this->_dataHolder = Doctrine_ORM_Query_ParserDataHolder::create();
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,7 +109,7 @@ abstract class Doctrine_ORM_Query_ParserRule
|
|||
* @param array $paramHolder Production parameter holder
|
||||
* @return Doctrine_ORM_Query_ParserRule
|
||||
*/
|
||||
public function parse($RuleName, $paramHolder)
|
||||
public function parse($RuleName)
|
||||
{
|
||||
$BNFGrammarRule = $this->_getGrammarRule($RuleName);
|
||||
|
||||
|
@ -109,10 +117,10 @@ abstract class Doctrine_ORM_Query_ParserRule
|
|||
//echo "Params: " . var_export($paramHolder, true) . "\n";
|
||||
|
||||
// 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";
|
||||
|
||||
$return = $BNFGrammarRule->syntax($paramHolder);
|
||||
$return = $BNFGrammarRule->syntax();
|
||||
|
||||
if ($return !== null) {
|
||||
//echo "Returning Gramma Rule class: " . (is_object($return) ? get_class($return) : $return) . "...\n";
|
||||
|
@ -122,10 +130,10 @@ abstract class Doctrine_ORM_Query_ParserRule
|
|||
}
|
||||
|
||||
// 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";
|
||||
|
||||
$return = $BNFGrammarRule->semantical($paramHolder);
|
||||
$return = $BNFGrammarRule->semantical();
|
||||
|
||||
if ($return !== null) {
|
||||
//echo "Returning Gramma Rule class: " . (is_object($return) ? get_class($return) : $return) . "...\n";
|
||||
|
@ -185,18 +193,23 @@ abstract class Doctrine_ORM_Query_ParserRule
|
|||
/**
|
||||
* @nodoc
|
||||
*/
|
||||
abstract public function syntax($paramHolder);
|
||||
abstract public function syntax();
|
||||
|
||||
|
||||
/**
|
||||
* @nodoc
|
||||
*/
|
||||
public function semantical($paramHolder)
|
||||
public function semantical()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function getParser()
|
||||
{
|
||||
return $this->_parser;
|
||||
}
|
||||
|
||||
public function getDataHolder()
|
||||
{
|
||||
return $this->_dataHolder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@ class Doctrine_EntityPersisterMock extends Doctrine_ORM_Persisters_StandardEntit
|
|||
$this->_mockIdGeneratorType = $genType;
|
||||
}
|
||||
|
||||
public function update(Doctrine_ORM_Entity $entity)
|
||||
public function update($entity)
|
||||
{
|
||||
$this->_updates[] = $entity;
|
||||
}
|
||||
|
||||
public function delete(Doctrine_ORM_Entity $entity)
|
||||
public function delete($entity)
|
||||
{
|
||||
$this->_deletes[] = $entity;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue