Skip to content

Commit a53c2fb

Browse files
author
romanb
committed
[2.0] Code cleanups. Preparations for DDC-193. Fixed DDC-399, type configuration 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.
1 parent ed94a34 commit a53c2fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+498
-903
lines changed

UPGRADE_TO_2_0

+8-85
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,25 @@
1-
> **NOTE**
2-
> This document does not describe how to upgrade from Doctrine 1.x to Doctrine 2 as this is a more
3-
> complicated process.
41

5-
# Upgrade from 2.0-ALPHA4 to 2.0 ...
2+
# Upgrade from 2.0-ALPHA4 to 2.0-BETA1
63

7-
## Default Property for Field Mappings removed
4+
## Default Property for Field Mappings
85

9-
The "default" option for database column defaults has been removed. If desired database column defaults can
10-
be implemented by using the @columnDefinition annotation (or the approriate XML and YAML equivalents).
11-
12-
Additionally keep in mind that Doctrine's focus in on objects and you can specifiy default values for an Entitiy's
13-
mapped fields inside PHP easily. Upon persist() invocation these values are saved as if they were default values.
6+
The "default" option for database column defaults has been removed. If desired, database column defaults can
7+
be implemented by using the columnDefinition attribute of the @Column annotation (or the approriate XML and YAML equivalents).
8+
Prefer PHP default values, if possible.
149

1510
## Partial Objects
1611

12+
xxx
13+
1714
## XML Mapping Driver
1815

1916
The 'inheritance-type' attribute changed to take last bit of ClassMetadata constant names, i.e.
2017
NONE, SINGLE_TABLE, INHERITANCE_TYPE_JOINED
2118

22-
## Change of PreUpdate Event Listener
19+
## PreUpdate Event Listeners
2320

2421
Event Listeners listening to the 'preUpdate' event can only affect the primitive values of entity changesets
2522
by using the API on the `PreUpdateEventArgs` instance passed to the preUpdate listener method. Any changes
2623
to the state of the entitys properties won't affect the database UPDATE statement anymore. This gives drastic
2724
performance benefits for the preUpdate event.
2825

29-
# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4
30-
31-
## CLI Controller changes
32-
33-
CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\Common\Cli\CliController.
34-
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:
35-
36-
[php]
37-
$cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask');
38-
39-
40-
## CLI Tasks documentation
41-
42-
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.
43-
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.
44-
45-
## Changes in Method Signatures
46-
47-
* A bunch of Methods on both Doctrine\DBAL\Platforms\AbstractPlatform and Doctrine\DBAL\Schema\AbstractSchemaManager
48-
have changed quite significantly by adopting the new Schema instance objects.
49-
50-
## Renamed Methods
51-
52-
* Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
53-
* Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()
54-
55-
## SchemaTool Changes
56-
57-
* "doctrine schema-tool --drop" now always drops the complete database instead of
58-
only those tables defined by the current database model. The previous method had
59-
problems when foreign keys of orphaned tables pointed to tables that were schedulded
60-
for deletion.
61-
* Use "doctrine schema-tool --update" to get a save incremental update for your
62-
database schema without deleting any unused tables, sequences or foreign keys.
63-
* Use "doctrine schema-tool --complete-update" to do a full incremental update of
64-
your schema.
65-
66-
67-
# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3
68-
69-
This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you
70-
to upgrade your projects to use this version.
71-
72-
## CLI Changes
73-
74-
The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments.
75-
76-
## Proxy class changes
77-
78-
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:
79-
80-
[php]
81-
// step 1: configure directory for proxy classes
82-
// $config instanceof Doctrine\ORM\Configuration
83-
$config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies');
84-
$config->setProxyNamespace('MyProject\Generated\Proxies');
85-
86-
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.
87-
Generating the proxy classes into a namespace within your class library is the recommended setup.
88-
89-
Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application.
90-
91-
For more details refer to the Configuration section of the manual.
92-
93-
## Removed allowPartialObjects configuration option
94-
95-
The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed.
96-
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.
97-
98-
## Renamed Methods
99-
100-
* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
101-
* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)
102-

UPGRADE_TO_ALPHA3

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3
2+
3+
This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you
4+
to upgrade your projects to use this version.
5+
6+
## CLI Changes
7+
8+
The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments.
9+
10+
## Proxy class changes
11+
12+
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:
13+
14+
[php]
15+
// step 1: configure directory for proxy classes
16+
// $config instanceof Doctrine\ORM\Configuration
17+
$config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies');
18+
$config->setProxyNamespace('MyProject\Generated\Proxies');
19+
20+
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.
21+
Generating the proxy classes into a namespace within your class library is the recommended setup.
22+
23+
Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application.
24+
25+
For more details refer to the Configuration section of the manual.
26+
27+
## Removed allowPartialObjects configuration option
28+
29+
The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed.
30+
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.
31+
32+
## Renamed Methods
33+
34+
* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
35+
* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)

UPGRADE_TO_ALPHA4

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4
2+
3+
## CLI Controller changes
4+
5+
CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\Common\Cli\CliController.
6+
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:
7+
8+
[php]
9+
$cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask');
10+
11+
12+
## CLI Tasks documentation
13+
14+
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.
15+
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.
16+
17+
## Changes in Method Signatures
18+
19+
* A bunch of Methods on both Doctrine\DBAL\Platforms\AbstractPlatform and Doctrine\DBAL\Schema\AbstractSchemaManager
20+
have changed quite significantly by adopting the new Schema instance objects.
21+
22+
## Renamed Methods
23+
24+
* Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
25+
* Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()
26+
27+
## SchemaTool Changes
28+
29+
* "doctrine schema-tool --drop" now always drops the complete database instead of
30+
only those tables defined by the current database model. The previous method had
31+
problems when foreign keys of orphaned tables pointed to tables that were schedulded
32+
for deletion.
33+
* Use "doctrine schema-tool --update" to get a save incremental update for your
34+
database schema without deleting any unused tables, sequences or foreign keys.
35+
* Use "doctrine schema-tool --complete-update" to do a full incremental update of
36+
your schema.

lib/Doctrine/Common/Cache/ApcCache.php

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* @author Jonathan Wage <[email protected]>
3333
* @author Roman Borschel <[email protected]>
3434
* @author David Abdemoulaie <[email protected]>
35+
* @todo Rename: APCCache
3536
*/
3637
class ApcCache extends AbstractCache
3738
{

lib/Doctrine/DBAL/Configuration.php

+3-30
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Configuration
4646
* @var array
4747
*/
4848
protected $_attributes = array();
49-
49+
5050
/**
5151
* Creates a new DBAL configuration instance.
5252
*/
@@ -56,7 +56,7 @@ public function __construct()
5656
'sqlLogger' => null
5757
);
5858
}
59-
59+
6060
/**
6161
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
6262
*
@@ -66,7 +66,7 @@ public function setSqlLogger($logger)
6666
{
6767
$this->_attributes['sqlLogger'] = $logger;
6868
}
69-
69+
7070
/**
7171
* Gets the SQL logger that is used.
7272
*
@@ -76,31 +76,4 @@ public function getSqlLogger()
7676
{
7777
return $this->_attributes['sqlLogger'];
7878
}
79-
80-
/**
81-
* Defines new custom types to be supported by Doctrine
82-
*
83-
* @param array $types Key-value map of types to include
84-
* @param boolean $override Optional flag to support only inclusion or also override
85-
*/
86-
public function setCustomTypes(array $types, $override = false)
87-
{
88-
foreach ($types as $name => $typeClassName) {
89-
$method = (Type::hasType($name) && $override ? 'override' : 'add') . 'Type';
90-
91-
Type::$method($name, $typeClassName);
92-
}
93-
}
94-
95-
/**
96-
* Overrides existent types in Doctrine
97-
*
98-
* @param array $types Key-value map of types to override
99-
*/
100-
public function setTypeOverrides(array $overrides)
101-
{
102-
foreach ($override as $name => $typeClassName) {
103-
Type::overrideType($name, $typeClassName);
104-
}
105-
}
10679
}

lib/Doctrine/DBAL/Connection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Connection
6666
*/
6767
const FETCH_ASSOC = 2;
6868
const FETCH_BOTH = 4;
69-
const FETCH_COLUMN = 7;
69+
//const FETCH_COLUMN = 7; Apparently not used.
7070
const FETCH_NUM = 3;
7171
const ATTR_AUTOCOMMIT = 0;
7272

lib/Doctrine/DBAL/Logging/EchoSqlLogger.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @author Roman Borschel <[email protected]>
99
* @since 2.0
10+
* @todo Rename: EchoSQLLogger
1011
*/
1112
class EchoSqlLogger implements SqlLogger
1213
{

lib/Doctrine/DBAL/Logging/SqlLogger.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @author Roman Borschel <[email protected]>
99
* @since 2.0
10+
* @todo Rename: SQLLogger
1011
*/
1112
interface SqlLogger
1213
{

lib/Doctrine/DBAL/Platforms/AbstractPlatform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public function getDropForeignKeySQL($foreignKey, $table)
579579
*/
580580
public function getCreateTableSQL(Table $table, $createFlags=self::CREATE_INDEXES)
581581
{
582-
if (!is_int($createFlags)) {
582+
if ( ! is_int($createFlags)) {
583583
throw new \InvalidArgumentException("Second argument of AbstractPlatform::getCreateTableSQL() has to be integer.");
584584
}
585585

lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* @author Roman Borschel <[email protected]>
3333
* @author Jonathan H. Wage <[email protected]>
3434
* @author Benjamin Eberlei <[email protected]>
35+
* @todo Rename: MsSQLPlatform
3536
*/
3637
class MsSqlPlatform extends AbstractPlatform
3738
{

lib/Doctrine/DBAL/Platforms/MySqlPlatform.php

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* @since 2.0
3333
* @author Roman Borschel <[email protected]>
3434
* @author Benjamin Eberlei <[email protected]>
35+
* @todo Rename: MySQLPlatform
3536
*/
3637
class MySqlPlatform extends AbstractPlatform
3738
{

lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
namespace Doctrine\DBAL\Platforms;
2323

24-
use Doctrine\DBAL\Schema\TableDiff;
24+
use Doctrine\DBAL\Schema\TableDiff,
25+
Doctrine\DBAL\Schema\Table;
2526

2627
/**
2728
* PostgreSqlPlatform.
@@ -30,6 +31,7 @@
3031
* @author Roman Borschel <[email protected]>
3132
* @author Lukas Smith <[email protected]> (PEAR MDB2 library)
3233
* @author Benjamin Eberlei <[email protected]>
34+
* @todo Rename: PostgreSQLPlatform
3335
*/
3436
class PostgreSqlPlatform extends AbstractPlatform
3537
{
@@ -281,7 +283,7 @@ public function getCreateDatabaseSQL($name)
281283
{
282284
return 'CREATE DATABASE ' . $name;
283285
}
284-
286+
285287
/**
286288
* drop an existing database
287289
*
@@ -293,9 +295,8 @@ public function getDropDatabaseSQL($name)
293295
{
294296
return 'DROP DATABASE ' . $name;
295297
}
296-
298+
297299
/**
298-
* getAdvancedForeignKeyOptions
299300
* Return the FOREIGN KEY query section dealing with non-standard options
300301
* as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
301302
*

lib/Doctrine/DBAL/Platforms/SqlitePlatform.php

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* @since 2.0
3131
* @author Roman Borschel <[email protected]>
3232
* @author Benjamin Eberlei <[email protected]>
33+
* @todo Rename: SQLitePlatform
3334
*/
3435
class SqlitePlatform extends AbstractPlatform
3536
{

lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
namespace Doctrine\DBAL\Schema;
2323

24-
use \Doctrine\DBAL\Types;
25-
use \Doctrine\DBAL\DBALException;
26-
use \Doctrine\DBAL\Platforms\AbstractPlatform;
24+
use Doctrine\DBAL\Types;
25+
use Doctrine\DBAL\DBALException;
26+
use Doctrine\DBAL\Platforms\AbstractPlatform;
2727

2828
/**
2929
* Base class for schema managers. Schema managers are used to inspect and/or

lib/Doctrine/DBAL/Types/StringType.php

+19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
<?php
2+
/*
3+
* $Id$
4+
*
5+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16+
*
17+
* This software consists of voluntary contributions made by many individuals
18+
* and is licensed under the LGPL. For more information, see
19+
* <http://www.doctrine-project.org>.
20+
*/
221

322
namespace Doctrine\DBAL\Types;
423

0 commit comments

Comments
 (0)