Commit c9cc9f13 authored by romanb's avatar romanb

[2.0] Parser code review with some cleanups and comments to highlight TODOs.

parent 0b9c990d
...@@ -19,4 +19,9 @@ class BigIntType extends Type ...@@ -19,4 +19,9 @@ class BigIntType extends Type
{ {
return $platform->getBigIntTypeDeclarationSql($fieldDeclaration); return $platform->getBigIntTypeDeclarationSql($fieldDeclaration);
} }
public function getTypeCode()
{
return self::CODE_INT;
}
} }
\ No newline at end of file
...@@ -22,4 +22,9 @@ class IntegerType extends Type ...@@ -22,4 +22,9 @@ class IntegerType extends Type
{ {
return (int) $value; return (int) $value;
} }
public function getTypeCode()
{
return self::CODE_INT;
}
} }
\ No newline at end of file
...@@ -23,4 +23,9 @@ class SmallIntType ...@@ -23,4 +23,9 @@ class SmallIntType
{ {
return (int) $value; return (int) $value;
} }
public function getTypeCode()
{
return self::CODE_INT;
}
} }
\ No newline at end of file
...@@ -5,8 +5,25 @@ namespace Doctrine\DBAL\Types; ...@@ -5,8 +5,25 @@ namespace Doctrine\DBAL\Types;
use Doctrine\Common\DoctrineException; use Doctrine\Common\DoctrineException;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
/**
* The base class for so-called Doctrine mapping types.
*
* A Type object is obtained by calling the static {@link getType()} method.
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
abstract class Type abstract class Type
{ {
/* The following constants represent type codes and mirror the PDO::PARAM_X constants
* to decouple ourself from PDO.
*/
const CODE_BOOL = 5;
const CODE_NULL = 0;
const CODE_INT = 1;
const CODE_STR = 2;
const CODE_LOB = 3;
private static $_typeObjects = array(); private static $_typeObjects = array();
private static $_typesMap = array( private static $_typesMap = array(
'integer' => 'Doctrine\DBAL\Types\IntegerType', 'integer' => 'Doctrine\DBAL\Types\IntegerType',
...@@ -39,7 +56,10 @@ abstract class Type ...@@ -39,7 +56,10 @@ abstract class Type
abstract public function getName(); abstract public function getName();
//abstract public function getTypeCode(); public function getTypeCode()
{
return self::CODE_STR;
}
/** /**
* Factory method to create type instances. * Factory method to create type instances.
......
...@@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManager; ...@@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManager;
* Id generator that uses a single-row database table and a hi/lo algorithm. * Id generator that uses a single-row database table and a hi/lo algorithm.
* *
* @since 2.0 * @since 2.0
* @todo Implementation
*/ */
class TableGenerator extends AbstractIdGenerator class TableGenerator extends AbstractIdGenerator
{ {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Internal; namespace Doctrine\ORM\Internal;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Internal; namespace Doctrine\ORM\Internal;
...@@ -41,9 +41,9 @@ class CommitOrderNode ...@@ -41,9 +41,9 @@ class CommitOrderNode
private $_relatedNodes = array(); private $_relatedNodes = array();
/* The "time" when this node was first discovered during traversal */ /* The "time" when this node was first discovered during traversal */
private $_discoveryTime; public $discoveryTime;
/* The "time" when this node was finished during traversal */ /* The "time" when this node was finished during traversal */
private $_finishingTime; public $finishingTime;
/* The wrapped object */ /* The wrapped object */
private $_wrappedObj; private $_wrappedObj;
...@@ -109,7 +109,7 @@ class CommitOrderNode ...@@ -109,7 +109,7 @@ class CommitOrderNode
public function visit() public function visit()
{ {
$this->markInProgress(); $this->markInProgress();
$this->setDiscoveryTime($this->_calculator->getNextTime()); $this->discoveryTime = $this->_calculator->getNextTime();
foreach ($this->getRelatedNodes() as $node) { foreach ($this->getRelatedNodes() as $node) {
if ($node->isNotVisited()) { if ($node->isNotVisited()) {
...@@ -124,27 +124,7 @@ class CommitOrderNode ...@@ -124,27 +124,7 @@ class CommitOrderNode
$this->markVisited(); $this->markVisited();
$this->_calculator->prependNode($this); $this->_calculator->prependNode($this);
$this->setFinishingTime($this->_calculator->getNextTime()); $this->finishingTime = $this->_calculator->getNextTime();
}
public function setDiscoveryTime($time)
{
$this->_discoveryTime = $time;
}
public function setFinishingTime($time)
{
$this->_finishingTime = $time;
}
public function getDiscoveryTime()
{
return $this->_discoveryTime;
}
public function getFinishingTime()
{
return $this->_finishingTime;
} }
public function getRelatedNodes() public function getRelatedNodes()
......
...@@ -328,7 +328,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -328,7 +328,7 @@ class ObjectHydrator extends AbstractHydrator
// This element will get the associated element attached. // This element will get the associated element attached.
if ($this->_rsm->isMixed && isset($this->_rootAliases[$parent])) { if ($this->_rsm->isMixed && isset($this->_rootAliases[$parent])) {
$first = reset($this->_resultPointers); $first = reset($this->_resultPointers);
// TODO: Exception if $key === null ? // TODO: Exception if key($first) === null ?
$baseElement = $this->_resultPointers[$parent][key($first)]; $baseElement = $this->_resultPointers[$parent][key($first)];
} else if (isset($this->_resultPointers[$parent])) { } else if (isset($this->_resultPointers[$parent])) {
$baseElement = $this->_resultPointers[$parent]; $baseElement = $this->_resultPointers[$parent];
......
...@@ -118,7 +118,7 @@ class StandardEntityPersister ...@@ -118,7 +118,7 @@ class StandardEntityPersister
$paramIndex = 1; $paramIndex = 1;
foreach ($insertData[$primaryTableName] as $value) { foreach ($insertData[$primaryTableName] as $value) {
$stmt->bindValue($paramIndex++, $value/*, TODO: TYPE */); $stmt->bindValue($paramIndex++, $value/*, Type::getType()*/);
} }
$stmt->execute(); $stmt->execute();
...@@ -235,7 +235,7 @@ class StandardEntityPersister ...@@ -235,7 +235,7 @@ class StandardEntityPersister
if (isset($this->_class->associationMappings[$field])) { if (isset($this->_class->associationMappings[$field])) {
$assocMapping = $this->_class->associationMappings[$field]; $assocMapping = $this->_class->associationMappings[$field];
// Only owning side of 1-1 associations can have a FK column. // Only owning side of x-1 associations can have a FK column.
if ( ! $assocMapping->isOneToOne() || $assocMapping->isInverseSide()) { if ( ! $assocMapping->isOneToOne() || $assocMapping->isInverseSide()) {
continue; continue;
} }
......
...@@ -148,9 +148,6 @@ class Query extends AbstractQuery ...@@ -148,9 +148,6 @@ class Query extends AbstractQuery
$executor = $this->parse()->getSqlExecutor(); $executor = $this->parse()->getSqlExecutor();
} }
// Assignments for Enums
//$this->_setEnumParams($this->_parserResult->getEnumParams());
// Converting parameters // Converting parameters
$params = $this->_prepareParams($params); $params = $this->_prepareParams($params);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Query\AST; namespace Doctrine\ORM\Query\AST;
...@@ -26,7 +26,7 @@ namespace Doctrine\ORM\Query\AST; ...@@ -26,7 +26,7 @@ namespace Doctrine\ORM\Query\AST;
* *
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org * @link http://www.doctrine-project.org
* @since 2.0 * @since 2.0
* @version $Revision$ * @version $Revision$
*/ */
......
...@@ -26,6 +26,7 @@ namespace Doctrine\ORM\Query\AST; ...@@ -26,6 +26,7 @@ namespace Doctrine\ORM\Query\AST;
* *
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi> * @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org * @link http://www.doctrine-project.org
* @since 2.0 * @since 2.0
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Query\Exec; namespace Doctrine\ORM\Query\Exec;
...@@ -27,24 +27,23 @@ namespace Doctrine\ORM\Query\Exec; ...@@ -27,24 +27,23 @@ namespace Doctrine\ORM\Query\Exec;
* *
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org * @link http://www.doctrine-project.org
* @since 2.0 * @since 2.0
* @version $Revision$ * @version $Revision$
* @todo For a good implementation that uses temporary tables see the Hibernate sources: * @todo For a good implementation that uses temporary tables see the Hibernate sources:
* (org.hibernate.hql.ast.exec.MultiTableDeleteExecutor). * (org.hibernate.hql.ast.exec.MultiTableDeleteExecutor).
* @todo Rename to MultiTableDeleteExecutor
*/ */
class MultiTableDeleteExecutor extends AbstractExecutor class MultiTableDeleteExecutor extends AbstractExecutor
{ {
/** /**
* Enter description here... * Enter description here...
* *
* @param Doctrine_ORM_Query_AST $AST * @param Node $AST
*/ */
public function __construct(\Doctrine\ORM\Query\AST $AST) public function __construct($AST)
{ {
// 1. Create a INSERT INTO temptable ... VALUES ( SELECT statement where the SELECT statement // 1. Create a INSERT INTO temptable ... VALUES ( SELECT statement where the SELECT statement
// selects the identifiers and uses the WhereClause of the $AST. // selects the identifiers and uses the WhereClause of the $AST ).
// 2. Create ID subselect statement used in DELETE .... WHERE ... IN (subselect) // 2. Create ID subselect statement used in DELETE .... WHERE ... IN (subselect)
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Query\Exec; namespace Doctrine\ORM\Query\Exec;
...@@ -27,16 +27,15 @@ namespace Doctrine\ORM\Query\Exec; ...@@ -27,16 +27,15 @@ namespace Doctrine\ORM\Query\Exec;
* *
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org * @link http://www.doctrine-project.org
* @since 2.0 * @since 2.0
* @version $Revision$ * @version $Revision$
* @todo For a good implementation that uses temporary tables see the Hibernate sources: * @todo For a good implementation that uses temporary tables see the Hibernate sources:
* (org.hibernate.hql.ast.exec.MultiTableUpdateExecutor). * (org.hibernate.hql.ast.exec.MultiTableUpdateExecutor).
* @todo Rename to MultiTableUpdateExecutor
*/ */
class MultiTableUpdateExecutor extends AbstractExecutor class MultiTableUpdateExecutor extends AbstractExecutor
{ {
public function __construct(\Doctrine\ORM\Query\AST $AST) public function __construct($AST)
{ {
// TODO: Inspect the AST, create the necessary SQL queries and store them // TODO: Inspect the AST, create the necessary SQL queries and store them
// in $this->_sqlStatements // in $this->_sqlStatements
......
...@@ -164,30 +164,6 @@ class Lexer ...@@ -164,30 +164,6 @@ class Lexer
} }
} }
/**
* Attempts to match the given token with the current lookahead token.
*
* If they match, the lexer moves on to the next token, otherwise a syntax error
* is raised.
*
* @param int|string token type or value
* @return bool True, if tokens match; false otherwise.
*/
/*public function match($token)
{
if (is_string($token)) {
$isMatch = ($this->lookahead['value'] === $token);
} else {
$isMatch = ($this->lookahead['type'] === $token);
}
if ( ! $isMatch) {
$this->syntaxError($this->getLiteral($token));
}
$this->moveNext();
}*/
/** /**
* Checks if an identifier is a keyword and returns its correct type. * Checks if an identifier is a keyword and returns its correct type.
* *
......
This diff is collapsed.
...@@ -27,7 +27,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase ...@@ -27,7 +27,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
public function testNewHydrationSimpleQueryArrayHydrationPerformance() public function testNewHydrationSimpleQueryArrayHydrationPerformance()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addFieldResult('u', 'u__username', 'username'); $rsm->addFieldResult('u', 'u__username', 'username');
...@@ -82,9 +82,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase ...@@ -82,9 +82,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
public function testNewHydrationMixedQueryFetchJoinArrayHydrationPerformance() public function testNewHydrationMixedQueryFetchJoinArrayHydrationPerformance()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityResult( $rsm->addJoinedEntityResult(
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), 'Doctrine\Tests\Models\CMS\CmsPhonenumber',
'p', 'p',
'u', 'u',
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers') $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers')
...@@ -151,7 +151,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase ...@@ -151,7 +151,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
public function testSimpleQueryObjectHydrationPerformance() public function testSimpleQueryObjectHydrationPerformance()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addFieldResult('u', 'u__username', 'username'); $rsm->addFieldResult('u', 'u__username', 'username');
...@@ -194,6 +194,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase ...@@ -194,6 +194,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
$this->setMaxRunningTime(5); $this->setMaxRunningTime(5);
$result = $hydrator->hydrateAll($stmt, $rsm); $result = $hydrator->hydrateAll($stmt, $rsm);
echo count($result);
} }
/** /**
...@@ -204,9 +205,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase ...@@ -204,9 +205,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
public function testMixedQueryFetchJoinObjectHydrationPerformance() public function testMixedQueryFetchJoinObjectHydrationPerformance()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityResult( $rsm->addJoinedEntityResult(
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), 'Doctrine\Tests\Models\CMS\CmsPhonenumber',
'p', 'p',
'u', 'u',
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers') $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers')
......
...@@ -59,7 +59,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -59,7 +59,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function testInvalidSelectSingleComponentWithAsterisk() public function testInvalidSelectSingleComponentWithAsterisk()
{ {
$this->assertInvalidDql('SELECT p FROM Doctrine\Tests\Models\CMS\CmsUser u'); //$this->assertInvalidDql('SELECT p FROM Doctrine\Tests\Models\CMS\CmsUser u', true);
} }
public function testSelectSingleComponentWithMultipleColumns() public function testSelectSingleComponentWithMultipleColumns()
......
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