forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddb2651
commit e5e45a3
Showing
4 changed files
with
20 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
* @author Jonathan Wage <[email protected]> | ||
* @author Roman Borschel <[email protected]> | ||
* @author Janne Vanhala <[email protected]> | ||
* @author Fabio B. Silva <[email protected]> | ||
*/ | ||
class Parser | ||
{ | ||
|
@@ -1641,12 +1642,12 @@ public function NewObjectExpression() | |
$className = $this->_lexer->token['value']; | ||
|
||
if ( ! class_exists($className, true)) { | ||
$this->semanticalError("Class '$className' is not defined.", $this->_lexer->token); | ||
$this->semanticalError("Class \"$className\" is not defined.", $this->_lexer->token); | ||
} | ||
|
||
$class = new \ReflectionClass($className); | ||
if($class->getConstructor() === null) { | ||
$this->semanticalError("Class '$className' has not a valid contructor.", $this->_lexer->token); | ||
$this->semanticalError("Class \"$className\" has not a valid contructor.", $this->_lexer->token); | ||
} | ||
|
||
$this->match(Lexer::T_OPEN_PARENTHESIS); | ||
|
@@ -1661,7 +1662,7 @@ public function NewObjectExpression() | |
$this->match(Lexer::T_CLOSE_PARENTHESIS); | ||
|
||
if($class->getConstructor()->getNumberOfRequiredParameters() > sizeof($args)) { | ||
$this->semanticalError("Number of arguments does not match definition.", $this->_lexer->token); | ||
$this->semanticalError("Number of arguments does not match.", $this->_lexer->token); | ||
} | ||
|
||
return new AST\NewObjectExpression($className, $args);; | ||
|
@@ -1680,9 +1681,6 @@ public function NewObjectArg() | |
|
||
return new AST\SimpleSelectExpression($expression); | ||
|
||
case ($this->_lexer->lookahead['type'] === Lexer::T_NEW): | ||
return $this->NewObjectExpression(); | ||
|
||
default: | ||
if ( ! ($this->_isFunction() || $this->_isAggregateFunction($this->_lexer->lookahead))) { | ||
$this->syntaxError(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
* @author Roman Borschel <[email protected]> | ||
* @author Benjamin Eberlei <[email protected]> | ||
* @author Alexander <[email protected]> | ||
* @author Fabio B. Silva <[email protected]> | ||
* @since 2.0 | ||
* @todo Rename: SQLWalker | ||
*/ | ||
|
@@ -1410,21 +1411,21 @@ public function walkNewObject($newObjectExpression) | |
foreach ($newObjectExpression->args as $argIndex => $e) { | ||
|
||
$resultAlias = $this->scalarResultCounter++; | ||
$columnAlias = $this->getSQLColumnAlias('sclr') . $resultAlias; | ||
$columnAlias = $this->getSQLColumnAlias('sclr'); | ||
|
||
switch (true) { | ||
case $e instanceof AST\NewObjectExpression: | ||
$sqlSelectExpressions[] = $e->dispatch($this); | ||
break; | ||
|
||
default: | ||
$sqlSelectExpressions[] = $e->dispatch($this) . ' AS ' . $columnAlias; | ||
$sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias; | ||
break; | ||
} | ||
|
||
|
||
$this->scalarResultAliasMap[$resultAlias] = $columnAlias; | ||
$this->rsm->addScalarResult($columnAlias, $resultAlias, 'string'); | ||
$this->rsm->addScalarResult($columnAlias, $resultAlias); | ||
|
||
$this->rsm->newObjectMappings[$columnAlias] = array( | ||
'className' => $newObjectExpression->className, | ||
|
@@ -1433,7 +1434,7 @@ public function walkNewObject($newObjectExpression) | |
); | ||
} | ||
|
||
return implode(',', $sqlSelectExpressions); | ||
return implode(', ', $sqlSelectExpressions); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters