Permalink
Browse files

[2.0] Code cleanups. Preparations for DDC-193. Fixed DDC-399, type co…

…nfiguration remains global for now but the irritating instance methods on the Configuration have been removed. Use Type::addType et al. Added TODOs for naming standards.
  • Loading branch information...
1 parent ed94a34 commit a53c2fbd6c2df5453c79edf693b5299c0133abf5 romanb committed Mar 15, 2010
Showing with 498 additions and 903 deletions.
  1. +8 −85 UPGRADE_TO_2_0
  2. +35 −0 UPGRADE_TO_ALPHA3
  3. +36 −0 UPGRADE_TO_ALPHA4
  4. +1 −0 lib/Doctrine/Common/Cache/ApcCache.php
  5. +3 −30 lib/Doctrine/DBAL/Configuration.php
  6. +1 −1 lib/Doctrine/DBAL/Connection.php
  7. +1 −0 lib/Doctrine/DBAL/Logging/EchoSqlLogger.php
  8. +1 −0 lib/Doctrine/DBAL/Logging/SqlLogger.php
  9. +1 −1 lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
  10. +1 −0 lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
  11. +1 −0 lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
  12. +5 −4 lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
  13. +1 −0 lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
  14. +3 −3 lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
  15. +19 −0 lib/Doctrine/DBAL/Types/StringType.php
  16. +22 −7 lib/Doctrine/DBAL/Types/Type.php
  17. +3 −0 lib/Doctrine/ORM/AbstractQuery.php
  18. +98 −11 lib/Doctrine/ORM/Configuration.php
  19. +4 −1 lib/Doctrine/ORM/EntityManager.php
  20. +1 −1 lib/Doctrine/ORM/EntityRepository.php
  21. +1 −1 lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
  22. +5 −5 lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
  23. +68 −141 lib/Doctrine/ORM/Mapping/AssociationMapping.php
  24. +13 −16 lib/Doctrine/ORM/Mapping/ClassMetadata.php
  25. +8 −9 lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
  26. +38 −290 lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
  27. +4 −2 lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
  28. +3 −2 lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
  29. +8 −34 lib/Doctrine/ORM/Mapping/ManyToManyMapping.php
  30. +10 −14 lib/Doctrine/ORM/Mapping/OneToManyMapping.php
  31. +14 −107 lib/Doctrine/ORM/Mapping/OneToOneMapping.php
  32. +3 −4 lib/Doctrine/ORM/PersistentCollection.php
  33. +4 −4 lib/Doctrine/ORM/Persisters/ManyToManyPersister.php
  34. +3 −4 lib/Doctrine/ORM/Persisters/OneToManyPersister.php
  35. +6 −6 lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
  36. +1 −1 lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php
  37. +2 −4 lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php
  38. +20 −75 lib/Doctrine/ORM/Query/Parser.php
  39. +4 −4 lib/Doctrine/ORM/Query/SqlWalker.php
  40. +2 −2 lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php
  41. +3 −3 lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php
  42. +3 −3 lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
  43. +5 −5 lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
  44. +4 −4 lib/Doctrine/ORM/Tools/SchemaTool.php
  45. +4 −2 lib/Doctrine/ORM/UnitOfWork.php
  46. +2 −2 tests/Doctrine/Tests/DBAL/Schema/TableTest.php
  47. +9 −9 tests/Doctrine/Tests/ORM/Associations/OneToOneMappingTest.php
  48. +2 −2 tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
  49. +3 −3 tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
  50. +1 −1 tests/Doctrine/Tests/OrmFunctionalTestCase.php
View
@@ -1,102 +1,25 @@
-> **NOTE**
-> This document does not describe how to upgrade from Doctrine 1.x to Doctrine 2 as this is a more
-> complicated process.
-# Upgrade from 2.0-ALPHA4 to 2.0 ...
+# Upgrade from 2.0-ALPHA4 to 2.0-BETA1
-## Default Property for Field Mappings removed
+## Default Property for Field Mappings
-The "default" option for database column defaults has been removed. If desired database column defaults can
-be implemented by using the @columnDefinition annotation (or the approriate XML and YAML equivalents).
-
-Additionally keep in mind that Doctrine's focus in on objects and you can specifiy default values for an Entitiy's
-mapped fields inside PHP easily. Upon persist() invocation these values are saved as if they were default values.
+The "default" option for database column defaults has been removed. If desired, database column defaults can
+be implemented by using the columnDefinition attribute of the @Column annotation (or the approriate XML and YAML equivalents).
+Prefer PHP default values, if possible.
## Partial Objects
+xxx
+
## XML Mapping Driver
The 'inheritance-type' attribute changed to take last bit of ClassMetadata constant names, i.e.
NONE, SINGLE_TABLE, INHERITANCE_TYPE_JOINED
-## Change of PreUpdate Event Listener
+## PreUpdate Event Listeners
Event Listeners listening to the 'preUpdate' event can only affect the primitive values of entity changesets
by using the API on the `PreUpdateEventArgs` instance passed to the preUpdate listener method. Any changes
to the state of the entitys properties won't affect the database UPDATE statement anymore. This gives drastic
performance benefits for the preUpdate event.
-# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4
-
-## CLI Controller changes
-
-CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\Common\Cli\CliController.
-Doctrine\Common\Cli\CliController now only deals with namespaces. Ready to go, Core, Dbal and Orm are available and you can subscribe new tasks by retrieving the namespace and including new task. Example:
-
- [php]
- $cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask');
-
-
-## CLI Tasks documentation
-
-Tasks have implemented a new way to build documentation. Although it is still possible to define the help manually by extending the basicHelp and extendedHelp, they are now optional.
-With new required method AbstractTask::buildDocumentation, its implementation defines the TaskDocumentation instance (accessible through AbstractTask::getDocumentation()), basicHelp and extendedHelp are now not necessary to be implemented.
-
-## Changes in Method Signatures
-
- * A bunch of Methods on both Doctrine\DBAL\Platforms\AbstractPlatform and Doctrine\DBAL\Schema\AbstractSchemaManager
- have changed quite significantly by adopting the new Schema instance objects.
-
-## Renamed Methods
-
- * Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
- * Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()
-
-## SchemaTool Changes
-
- * "doctrine schema-tool --drop" now always drops the complete database instead of
- only those tables defined by the current database model. The previous method had
- problems when foreign keys of orphaned tables pointed to tables that were schedulded
- for deletion.
- * Use "doctrine schema-tool --update" to get a save incremental update for your
- database schema without deleting any unused tables, sequences or foreign keys.
- * Use "doctrine schema-tool --complete-update" to do a full incremental update of
- your schema.
-
-
-# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3
-
-This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you
-to upgrade your projects to use this version.
-
-## CLI Changes
-
-The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments.
-
-## Proxy class changes
-
-You are now required to make supply some minimalist configuration with regards to proxy objects. That involves 2 new configuration options. First, the directory where generated proxy classes should be placed needs to be specified. Secondly, you need to configure the namespace used for proxy classes. The following snippet shows an example:
-
- [php]
- // step 1: configure directory for proxy classes
- // $config instanceof Doctrine\ORM\Configuration
- $config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies');
- $config->setProxyNamespace('MyProject\Generated\Proxies');
-
-Note that proxy classes behave exactly like any other classes when it comes to class loading. Therefore you need to make sure the proxy classes can be loaded by some class loader. If you place the generated proxy classes in a namespace and directory under your projects class files, like in the example above, it would be sufficient to register the MyProject namespace on a class loader. Since the proxy classes are contained in that namespace and adhere to the standards for class loading, no additional work is required.
-Generating the proxy classes into a namespace within your class library is the recommended setup.
-
-Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application.
-
-For more details refer to the Configuration section of the manual.
-
-## Removed allowPartialObjects configuration option
-
-The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed.
-The new behavior is as if the option were set to FALSE all the time, basically disallowing partial objects globally. However, you can still use the `Query::HINT_FORCE_PARTIAL_LOAD` query hint to force a query to return partial objects for optimization purposes.
-
-## Renamed Methods
-
-* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
-* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)
-
View
@@ -0,0 +1,35 @@
+# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3
+
+This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you
+to upgrade your projects to use this version.
+
+## CLI Changes
+
+The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments.
+
+## Proxy class changes
+
+You are now required to make supply some minimalist configuration with regards to proxy objects. That involves 2 new configuration options. First, the directory where generated proxy classes should be placed needs to be specified. Secondly, you need to configure the namespace used for proxy classes. The following snippet shows an example:
+
+ [php]
+ // step 1: configure directory for proxy classes
+ // $config instanceof Doctrine\ORM\Configuration
+ $config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies');
+ $config->setProxyNamespace('MyProject\Generated\Proxies');
+
+Note that proxy classes behave exactly like any other classes when it comes to class loading. Therefore you need to make sure the proxy classes can be loaded by some class loader. If you place the generated proxy classes in a namespace and directory under your projects class files, like in the example above, it would be sufficient to register the MyProject namespace on a class loader. Since the proxy classes are contained in that namespace and adhere to the standards for class loading, no additional work is required.
+Generating the proxy classes into a namespace within your class library is the recommended setup.
+
+Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application.
+
+For more details refer to the Configuration section of the manual.
+
+## Removed allowPartialObjects configuration option
+
+The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed.
+The new behavior is as if the option were set to FALSE all the time, basically disallowing partial objects globally. However, you can still use the `Query::HINT_FORCE_PARTIAL_LOAD` query hint to force a query to return partial objects for optimization purposes.
+
+## Renamed Methods
+
+* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
+* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)
View
@@ -0,0 +1,36 @@
+# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4
+
+## CLI Controller changes
+
+CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\Common\Cli\CliController.
+Doctrine\Common\Cli\CliController now only deals with namespaces. Ready to go, Core, Dbal and Orm are available and you can subscribe new tasks by retrieving the namespace and including new task. Example:
+
+ [php]
+ $cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask');
+
+
+## CLI Tasks documentation
+
+Tasks have implemented a new way to build documentation. Although it is still possible to define the help manually by extending the basicHelp and extendedHelp, they are now optional.
+With new required method AbstractTask::buildDocumentation, its implementation defines the TaskDocumentation instance (accessible through AbstractTask::getDocumentation()), basicHelp and extendedHelp are now not necessary to be implemented.
+
+## Changes in Method Signatures
+
+ * A bunch of Methods on both Doctrine\DBAL\Platforms\AbstractPlatform and Doctrine\DBAL\Schema\AbstractSchemaManager
+ have changed quite significantly by adopting the new Schema instance objects.
+
+## Renamed Methods
+
+ * Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
+ * Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()
+
+## SchemaTool Changes
+
+ * "doctrine schema-tool --drop" now always drops the complete database instead of
+ only those tables defined by the current database model. The previous method had
+ problems when foreign keys of orphaned tables pointed to tables that were schedulded
+ for deletion.
+ * Use "doctrine schema-tool --update" to get a save incremental update for your
+ database schema without deleting any unused tables, sequences or foreign keys.
+ * Use "doctrine schema-tool --complete-update" to do a full incremental update of
+ your schema.
@@ -32,6 +32,7 @@
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author David Abdemoulaie <dave@hobodave.com>
+ * @todo Rename: APCCache
*/
class ApcCache extends AbstractCache
{
@@ -46,7 +46,7 @@ class Configuration
* @var array
*/
protected $_attributes = array();
-
+
/**
* Creates a new DBAL configuration instance.
*/
@@ -56,7 +56,7 @@ public function __construct()
'sqlLogger' => null
);
}
-
+
/**
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
*
@@ -66,7 +66,7 @@ public function setSqlLogger($logger)
{
$this->_attributes['sqlLogger'] = $logger;
}
-
+
/**
* Gets the SQL logger that is used.
*
@@ -76,31 +76,4 @@ public function getSqlLogger()
{
return $this->_attributes['sqlLogger'];
}
-
- /**
- * Defines new custom types to be supported by Doctrine
- *
- * @param array $types Key-value map of types to include
- * @param boolean $override Optional flag to support only inclusion or also override
- */
- public function setCustomTypes(array $types, $override = false)
- {
- foreach ($types as $name => $typeClassName) {
- $method = (Type::hasType($name) && $override ? 'override' : 'add') . 'Type';
-
- Type::$method($name, $typeClassName);
- }
- }
-
- /**
- * Overrides existent types in Doctrine
- *
- * @param array $types Key-value map of types to override
- */
- public function setTypeOverrides(array $overrides)
- {
- foreach ($override as $name => $typeClassName) {
- Type::overrideType($name, $typeClassName);
- }
- }
}
@@ -66,7 +66,7 @@ class Connection
*/
const FETCH_ASSOC = 2;
const FETCH_BOTH = 4;
- const FETCH_COLUMN = 7;
+ //const FETCH_COLUMN = 7; Apparently not used.
const FETCH_NUM = 3;
const ATTR_AUTOCOMMIT = 0;
@@ -7,6 +7,7 @@
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
+ * @todo Rename: EchoSQLLogger
*/
class EchoSqlLogger implements SqlLogger
{
@@ -7,6 +7,7 @@
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
+ * @todo Rename: SQLLogger
*/
interface SqlLogger
{
@@ -579,7 +579,7 @@ public function getDropForeignKeySQL($foreignKey, $table)
*/
public function getCreateTableSQL(Table $table, $createFlags=self::CREATE_INDEXES)
{
- if (!is_int($createFlags)) {
+ if ( ! is_int($createFlags)) {
throw new \InvalidArgumentException("Second argument of AbstractPlatform::getCreateTableSQL() has to be integer.");
}
@@ -32,6 +32,7 @@
* @author Roman Borschel <roman@code-factory.org>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @todo Rename: MsSQLPlatform
*/
class MsSqlPlatform extends AbstractPlatform
{
@@ -32,6 +32,7 @@
* @since 2.0
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @todo Rename: MySQLPlatform
*/
class MySqlPlatform extends AbstractPlatform
{
@@ -21,7 +21,8 @@
namespace Doctrine\DBAL\Platforms;
-use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Schema\TableDiff,
+ Doctrine\DBAL\Schema\Table;
/**
* PostgreSqlPlatform.
@@ -30,6 +31,7 @@
* @author Roman Borschel <roman@code-factory.org>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @todo Rename: PostgreSQLPlatform
*/
class PostgreSqlPlatform extends AbstractPlatform
{
@@ -281,7 +283,7 @@ public function getCreateDatabaseSQL($name)
{
return 'CREATE DATABASE ' . $name;
}
-
+
/**
* drop an existing database
*
@@ -293,9 +295,8 @@ public function getDropDatabaseSQL($name)
{
return 'DROP DATABASE ' . $name;
}
-
+
/**
- * getAdvancedForeignKeyOptions
* Return the FOREIGN KEY query section dealing with non-standard options
* as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
*
@@ -30,6 +30,7 @@
* @since 2.0
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @todo Rename: SQLitePlatform
*/
class SqlitePlatform extends AbstractPlatform
{
@@ -21,9 +21,9 @@
namespace Doctrine\DBAL\Schema;
-use \Doctrine\DBAL\Types;
-use \Doctrine\DBAL\DBALException;
-use \Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Types;
+use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
/**
* Base class for schema managers. Schema managers are used to inspect and/or
@@ -1,4 +1,23 @@
<?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.doctrine-project.org>.
+ */
namespace Doctrine\DBAL\Types;
Oops, something went wrong.

0 comments on commit a53c2fb

Please sign in to comment.