diff --git a/bin/doctrine.php b/bin/doctrine.php
index 905dd17d2..a94cdff67 100644
--- a/bin/doctrine.php
+++ b/bin/doctrine.php
@@ -21,16 +21,16 @@ if (file_exists($configFile)) {
require $configFile;
foreach ($GLOBALS as $helperSetCandidate) {
- if ($helperSetCandidate instanceof \Symfony\Components\Console\Helper\HelperSet) {
+ if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
$helperSet = $helperSetCandidate;
break;
}
}
}
-$helperSet = ($helperSet) ?: new \Symfony\Components\Console\Helper\HelperSet();
+$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet();
-$cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\ORM\Version::VERSION);
+$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\ORM\Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->addCommands(array(
@@ -55,4 +55,4 @@ $cli->addCommands(array(
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
));
-$cli->run();
\ No newline at end of file
+$cli->run();
diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php
index 7c3c42f9c..21974b792 100644
--- a/lib/Doctrine/ORM/AbstractQuery.php
+++ b/lib/Doctrine/ORM/AbstractQuery.php
@@ -138,10 +138,16 @@ abstract class AbstractQuery
/**
* Frees the resources used by the query object.
+ *
+ * Resets Parameters, Parameter Types and Query Hints.
+ *
+ * @return void
*/
public function free()
{
$this->_params = array();
+ $this->_paramTypes = array();
+ $this->_hints = array();
}
/**
@@ -569,4 +575,14 @@ abstract class AbstractQuery
* @return Doctrine\DBAL\Driver\Statement The executed database statement that holds the results.
*/
abstract protected function _doExecute();
+
+ /**
+ * Cleanup Query resource when clone is called.
+ *
+ * @return void
+ */
+ public function __clone()
+ {
+ $this->free();
+ }
}
diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
index 7da64480b..400970d6d 100644
--- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
+++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
@@ -38,17 +38,40 @@ use ReflectionException,
*/
class ClassMetadataFactory
{
- private $_em;
- /** The targeted database platform. */
- private $_targetPlatform;
- /** The used metadata driver. */
- private $_driver;
- /** The event manager instance */
- private $_evm;
- /** The used cache driver. */
- private $_cacheDriver;
- private $_loadedMetadata = array();
- private $_initialized = false;
+ /**
+ * @var EntityManager
+ */
+ private $em;
+
+ /**
+ * @var AbstractPlatform
+ */
+ private $targetPlatform;
+
+ /**
+ * @var Driver\Driver
+ */
+ private $driver;
+
+ /**
+ * @var \Doctrine\Common\EventManager
+ */
+ private $evm;
+
+ /**
+ * @var \Doctrine\Common\Cache\Cache
+ */
+ private $cacheDriver;
+
+ /**
+ * @var array
+ */
+ private $loadedMetadata = array();
+
+ /**
+ * @var bool
+ */
+ private $initialized = false;
/**
* Creates a new factory instance that uses the given metadata driver implementation.
@@ -57,7 +80,7 @@ class ClassMetadataFactory
*/
public function __construct(EntityManager $em)
{
- $this->_em = $em;
+ $this->em = $em;
}
/**
@@ -67,7 +90,7 @@ class ClassMetadataFactory
*/
public function setCacheDriver($cacheDriver)
{
- $this->_cacheDriver = $cacheDriver;
+ $this->cacheDriver = $cacheDriver;
}
/**
@@ -77,12 +100,12 @@ class ClassMetadataFactory
*/
public function getCacheDriver()
{
- return $this->_cacheDriver;
+ return $this->cacheDriver;
}
public function getLoadedMetadata()
{
- return $this->_loadedMetadata;
+ return $this->loadedMetadata;
}
/**
@@ -93,12 +116,12 @@ class ClassMetadataFactory
*/
public function getAllMetadata()
{
- if ( ! $this->_initialized) {
- $this->_initialize();
+ if ( ! $this->initialized) {
+ $this->initialize();
}
$metadata = array();
- foreach ($this->_driver->getAllClassNames() as $className) {
+ foreach ($this->driver->getAllClassNames() as $className) {
$metadata[] = $this->getMetadataFor($className);
}
@@ -109,12 +132,12 @@ class ClassMetadataFactory
* Lazy initialization of this stuff, especially the metadata driver,
* since these are not needed at all when a metadata cache is active.
*/
- private function _initialize()
+ private function initialize()
{
- $this->_driver = $this->_em->getConfiguration()->getMetadataDriverImpl();
- $this->_targetPlatform = $this->_em->getConnection()->getDatabasePlatform();
- $this->_evm = $this->_em->getEventManager();
- $this->_initialized = true;
+ $this->driver = $this->em->getConfiguration()->getMetadataDriverImpl();
+ $this->targetPlatform = $this->em->getConnection()->getDatabasePlatform();
+ $this->evm = $this->em->getEventManager();
+ $this->initialized = true;
}
/**
@@ -125,43 +148,43 @@ class ClassMetadataFactory
*/
public function getMetadataFor($className)
{
- if ( ! isset($this->_loadedMetadata[$className])) {
+ if ( ! isset($this->loadedMetadata[$className])) {
$realClassName = $className;
// Check for namespace alias
if (strpos($className, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $className);
- $realClassName = $this->_em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
+ $realClassName = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
- if (isset($this->_loadedMetadata[$realClassName])) {
+ if (isset($this->loadedMetadata[$realClassName])) {
// We do not have the alias name in the map, include it
- $this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName];
+ $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
- return $this->_loadedMetadata[$realClassName];
+ return $this->loadedMetadata[$realClassName];
}
}
- if ($this->_cacheDriver) {
- if (($cached = $this->_cacheDriver->fetch("$realClassName\$CLASSMETADATA")) !== false) {
- $this->_loadedMetadata[$realClassName] = $cached;
+ if ($this->cacheDriver) {
+ if (($cached = $this->cacheDriver->fetch("$realClassName\$CLASSMETADATA")) !== false) {
+ $this->loadedMetadata[$realClassName] = $cached;
} else {
- foreach ($this->_loadMetadata($realClassName) as $loadedClassName) {
- $this->_cacheDriver->save(
- "$loadedClassName\$CLASSMETADATA", $this->_loadedMetadata[$loadedClassName], null
+ foreach ($this->loadMetadata($realClassName) as $loadedClassName) {
+ $this->cacheDriver->save(
+ "$loadedClassName\$CLASSMETADATA", $this->loadedMetadata[$loadedClassName], null
);
}
}
} else {
- $this->_loadMetadata($realClassName);
+ $this->loadMetadata($realClassName);
}
if ($className != $realClassName) {
// We do not have the alias name in the map, include it
- $this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName];
+ $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
}
}
- return $this->_loadedMetadata[$className];
+ return $this->loadedMetadata[$className];
}
/**
@@ -172,7 +195,7 @@ class ClassMetadataFactory
*/
public function hasMetadataFor($className)
{
- return isset($this->_loadedMetadata[$className]);
+ return isset($this->loadedMetadata[$className]);
}
/**
@@ -185,7 +208,7 @@ class ClassMetadataFactory
*/
public function setMetadataFor($className, $class)
{
- $this->_loadedMetadata[$className] = $class;
+ $this->loadedMetadata[$className] = $class;
}
/**
@@ -194,12 +217,12 @@ class ClassMetadataFactory
* @param string $name
* @return array $parentClasses
*/
- protected function _getParentClasses($name)
+ protected function getParentClasses($name)
{
// Collect parent classes, ignoring transient (not-mapped) classes.
$parentClasses = array();
foreach (array_reverse(class_parents($name)) as $parentClass) {
- if ( ! $this->_driver->isTransient($parentClass)) {
+ if ( ! $this->driver->isTransient($parentClass)) {
$parentClasses[] = $parentClass;
}
}
@@ -213,37 +236,37 @@ class ClassMetadataFactory
* @param string $name The name of the class for which the metadata should get loaded.
* @param array $tables The metadata collection to which the loaded metadata is added.
*/
- protected function _loadMetadata($name)
+ protected function loadMetadata($name)
{
- if ( ! $this->_initialized) {
- $this->_initialize();
+ if ( ! $this->initialized) {
+ $this->initialize();
}
$loaded = array();
- $parentClasses = $this->_getParentClasses($name);
+ $parentClasses = $this->getParentClasses($name);
$parentClasses[] = $name;
// Move down the hierarchy of parent classes, starting from the topmost class
$parent = null;
$visited = array();
foreach ($parentClasses as $className) {
- if (isset($this->_loadedMetadata[$className])) {
- $parent = $this->_loadedMetadata[$className];
+ if (isset($this->loadedMetadata[$className])) {
+ $parent = $this->loadedMetadata[$className];
if ( ! $parent->isMappedSuperclass) {
array_unshift($visited, $className);
}
continue;
}
- $class = $this->_newClassMetadataInstance($className);
+ $class = $this->newClassMetadataInstance($className);
if ($parent) {
$class->setInheritanceType($parent->inheritanceType);
$class->setDiscriminatorColumn($parent->discriminatorColumn);
$class->setIdGeneratorType($parent->generatorType);
- $this->_addInheritedFields($class, $parent);
- $this->_addInheritedRelations($class, $parent);
+ $this->addInheritedFields($class, $parent);
+ $this->addInheritedRelations($class, $parent);
$class->setIdentifier($parent->identifier);
$class->setVersioned($parent->isVersioned);
$class->setVersionField($parent->versionField);
@@ -254,7 +277,7 @@ class ClassMetadataFactory
// Invoke driver
try {
- $this->_driver->loadMetadataForClass($className, $class);
+ $this->driver->loadMetadataForClass($className, $class);
} catch (ReflectionException $e) {
throw MappingException::reflectionFailure($className, $e);
}
@@ -276,7 +299,17 @@ class ClassMetadataFactory
$class->setIdGenerator($parent->idGenerator);
}
} else {
- $this->_completeIdGeneratorMapping($class);
+ $this->completeIdGeneratorMapping($class);
+ }
+
+ // verify inheritance
+ if (!$parent && !$class->isMappedSuperclass && !$class->isInheritanceTypeNone()) {
+ if (count($class->discriminatorMap) == 0) {
+ throw MappingException::missingDiscriminatorMap($class->name);
+ }
+ if (!$class->discriminatorColumn) {
+ throw MappingException::missingDiscriminatorColumn($class->name);
+ }
}
if ($parent && $parent->isInheritanceTypeSingleTable()) {
@@ -285,12 +318,12 @@ class ClassMetadataFactory
$class->setParentClasses($visited);
- if ($this->_evm->hasListeners(Events::loadClassMetadata)) {
+ if ($this->evm->hasListeners(Events::loadClassMetadata)) {
$eventArgs = new \Doctrine\ORM\Event\LoadClassMetadataEventArgs($class);
- $this->_evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
+ $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
}
- $this->_loadedMetadata[$className] = $class;
+ $this->loadedMetadata[$className] = $class;
$parent = $class;
@@ -310,7 +343,7 @@ class ClassMetadataFactory
* @param string $className
* @return Doctrine\ORM\Mapping\ClassMetadata
*/
- protected function _newClassMetadataInstance($className)
+ protected function newClassMetadataInstance($className)
{
return new ClassMetadata($className);
}
@@ -321,7 +354,7 @@ class ClassMetadataFactory
* @param Doctrine\ORM\Mapping\ClassMetadata $subClass
* @param Doctrine\ORM\Mapping\ClassMetadata $parentClass
*/
- private function _addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
+ private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->fieldMappings as $fieldName => $mapping) {
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
@@ -343,7 +376,7 @@ class ClassMetadataFactory
* @param Doctrine\ORM\Mapping\ClassMetadata $subClass
* @param Doctrine\ORM\Mapping\ClassMetadata $parentClass
*/
- private function _addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
+ private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->associationMappings as $field => $mapping) {
//$subclassMapping = $mapping;
@@ -363,13 +396,13 @@ class ClassMetadataFactory
*
* @param Doctrine\ORM\Mapping\ClassMetadata $class
*/
- private function _completeIdGeneratorMapping(ClassMetadataInfo $class)
+ private function completeIdGeneratorMapping(ClassMetadataInfo $class)
{
$idGenType = $class->generatorType;
if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) {
- if ($this->_targetPlatform->prefersSequences()) {
+ if ($this->targetPlatform->prefersSequences()) {
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE);
- } else if ($this->_targetPlatform->prefersIdentityColumns()) {
+ } else if ($this->targetPlatform->prefersIdentityColumns()) {
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_IDENTITY);
} else {
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_TABLE);
@@ -382,7 +415,7 @@ class ClassMetadataFactory
// For PostgreSQL IDENTITY (SERIAL) we need a sequence name. It defaults to
//
__seq in PostgreSQL for SERIAL columns.
// Not pretty but necessary and the simplest solution that currently works.
- $seqName = $this->_targetPlatform instanceof Platforms\PostgreSQLPlatform ?
+ $seqName = $this->targetPlatform instanceof Platforms\PostgreSQLPlatform ?
$class->table['name'] . '_' . $class->columnNames[$class->identifier[0]] . '_seq' :
null;
$class->setIdGenerator(new \Doctrine\ORM\Id\IdentityGenerator($seqName));
@@ -392,7 +425,7 @@ class ClassMetadataFactory
$definition = $class->sequenceGeneratorDefinition;
if ( ! $definition) {
$sequenceName = $class->getTableName() . '_' . $class->getSingleIdentifierColumnName() . '_seq';
- $definition['sequenceName'] = $this->_targetPlatform->fixSchemaElementName($sequenceName);
+ $definition['sequenceName'] = $this->targetPlatform->fixSchemaElementName($sequenceName);
$definition['allocationSize'] = 1;
$definition['initialValue'] = 1;
$class->setSequenceGeneratorDefinition($definition);
diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
index fbf6ebdb3..971e2c980 100644
--- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
+++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
@@ -680,9 +680,11 @@ class ClassMetadataInfo
}
/**
- * Validates & completes the mapping. Mapping defaults are applied here.
+ * Validates & completes the basic mapping information that is common to all
+ * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many).
*
- * @param array $mapping
+ * @param array $mapping The mapping.
+ * @return array The updated mapping.
* @throws MappingException If something is wrong with the mapping.
*/
protected function _validateAndCompleteAssociationMapping(array $mapping)
@@ -693,10 +695,13 @@ class ClassMetadataInfo
if ( ! isset($mapping['inversedBy'])) {
$mapping['inversedBy'] = null;
}
- $mapping['isOwningSide'] = true;
+ $mapping['isOwningSide'] = true; // assume owning side until we hit mappedBy
+ // If targetEntity is unqualified, assume it is in the same namespace as
+ // the sourceEntity.
$mapping['sourceEntity'] = $this->name;
- if (isset($mapping['targetEntity']) && strpos($mapping['targetEntity'], '\\') === false && strlen($this->namespace) > 0) {
+ if (isset($mapping['targetEntity']) && strpos($mapping['targetEntity'], '\\') === false
+ && strlen($this->namespace) > 0) {
$mapping['targetEntity'] = $this->namespace . '\\' . $mapping['targetEntity'];
}
@@ -712,23 +717,18 @@ class ClassMetadataInfo
}
// Mandatory attributes for both sides
+ // Mandatory: fieldName, targetEntity
if ( ! isset($mapping['fieldName'])) {
throw MappingException::missingFieldName();
}
-
- if ( ! isset($mapping['sourceEntity'])) {
- throw MappingException::missingSourceEntity($mapping['fieldName']);
- }
-
if ( ! isset($mapping['targetEntity'])) {
throw MappingException::missingTargetEntity($mapping['fieldName']);
}
// Mandatory and optional attributes for either side
- if ( ! isset($mapping['mappedBy'])) {
- // Optional
+ if ( ! $mapping['mappedBy']) {
if (isset($mapping['joinTable']) && $mapping['joinTable']) {
- if ($mapping['joinTable']['name'][0] == '`') {
+ if (isset($mapping['joinTable']['name']) && $mapping['joinTable']['name'][0] == '`') {
$mapping['joinTable']['name'] = trim($mapping['joinTable']['name'], '`');
$mapping['joinTable']['quoted'] = true;
}
@@ -737,12 +737,13 @@ class ClassMetadataInfo
$mapping['isOwningSide'] = false;
}
- // Optional attributes for both sides
+ // Fetch mode. Default fetch mode to LAZY, if not set.
if ( ! isset($mapping['fetch'])) {
$mapping['fetch'] = self::FETCH_LAZY;
}
+
+ // Cascades
$cascades = isset($mapping['cascade']) ? $mapping['cascade'] : array();
-
if (in_array('all', $cascades)) {
$cascades = array(
'remove',
@@ -763,10 +764,10 @@ class ClassMetadataInfo
}
/**
- * {@inheritdoc}
+ * Validates & completes a one-to-one association mapping.
*
* @param array $mapping The mapping to validate & complete.
- * @return array The validated & completed mapping.
+ * @return array The validated & completed mapping.
* @override
*/
protected function _validateAndCompleteOneToOneMapping(array $mapping)
@@ -785,11 +786,16 @@ class ClassMetadataInfo
'referencedColumnName' => 'id'
));
}
- foreach ($mapping['joinColumns'] AS $key => $joinColumn) {
- if ($mapping['type'] == self::ONE_TO_ONE) {
- $mapping['joinColumns'][$key]['unique'] = true;
+ foreach ($mapping['joinColumns'] as $key => &$joinColumn) {
+ if ($mapping['type'] === self::ONE_TO_ONE) {
+ $joinColumn['unique'] = true;
+ }
+ if (empty($joinColumn['name'])) {
+ $joinColumn['name'] = $mapping['fieldName'] . '_id';
+ }
+ if (empty($joinColumn['referencedColumnName'])) {
+ $joinColumn['referencedColumnName'] = 'id';
}
-
$mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName'];
$mapping['joinColumnFieldNames'][$joinColumn['name']] = isset($joinColumn['fieldName'])
? $joinColumn['fieldName'] : $joinColumn['name'];
@@ -837,58 +843,49 @@ class ClassMetadataInfo
{
$mapping = $this->_validateAndCompleteAssociationMapping($mapping);
if ($mapping['isOwningSide']) {
+ $sourceShortName = strtolower(substr($mapping['sourceEntity'], strrpos($mapping['sourceEntity'], '\\') + 1));
+ $targetShortName = strtolower(substr($mapping['targetEntity'], strrpos($mapping['targetEntity'], '\\') + 1));
// owning side MUST have a join table
- if ( ! isset($mapping['joinTable']) || ! $mapping['joinTable']) {
- // Apply default join table
- $sourceShortName = substr($mapping['sourceEntity'], strrpos($mapping['sourceEntity'], '\\') + 1);
- $targetShortName = substr($mapping['targetEntity'], strrpos($mapping['targetEntity'], '\\') + 1);
- $mapping['joinTable'] = array(
- 'name' => $sourceShortName .'_' . $targetShortName,
- 'joinColumns' => array(
- array(
- 'name' => $sourceShortName . '_id',
- 'referencedColumnName' => 'id',
- 'onDelete' => 'CASCADE'
- )
- ),
- 'inverseJoinColumns' => array(
- array(
- 'name' => $targetShortName . '_id',
- 'referencedColumnName' => 'id',
- 'onDelete' => 'CASCADE'
- )
- )
- );
+ if ( ! isset($mapping['joinTable']['name'])) {
+ $mapping['joinTable']['name'] = $sourceShortName .'_' . $targetShortName;
}
- // owning side MUST specify joinColumns
- else if ( ! isset($mapping['joinTable']['joinColumns'])) {
- throw MappingException::missingRequiredOption(
- $mapping['fieldName'], 'joinColumns',
- 'Did you think of case sensitivity / plural s?'
- );
+ if ( ! isset($mapping['joinTable']['joinColumns'])) {
+ $mapping['joinTable']['joinColumns'] = array(array(
+ 'name' => $sourceShortName . '_id',
+ 'referencedColumnName' => 'id',
+ 'onDelete' => 'CASCADE'));
}
- // owning side MUST specify inverseJoinColumns
- else if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) {
- throw MappingException::missingRequiredOption(
- $mapping['fieldName'], 'inverseJoinColumns',
- 'Did you think of case sensitivity / plural s?'
- );
+ if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) {
+ $mapping['joinTable']['inverseJoinColumns'] = array(array(
+ 'name' => $targetShortName . '_id',
+ 'referencedColumnName' => 'id',
+ 'onDelete' => 'CASCADE'));
}
-
- foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
+
+ foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) {
+ if (empty($joinColumn['name'])) {
+ $joinColumn['name'] = $sourceShortName . '_id';
+ }
+ if (empty($joinColumn['referencedColumnName'])) {
+ $joinColumn['referencedColumnName'] = 'id';
+ }
if (isset($joinColumn['onDelete']) && strtolower($joinColumn['onDelete']) == 'cascade') {
$mapping['isOnDeleteCascade'] = true;
}
-
$mapping['relationToSourceKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName'];
$mapping['joinTableColumns'][] = $joinColumn['name'];
}
-
- foreach ($mapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) {
+
+ foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) {
+ if (empty($inverseJoinColumn['name'])) {
+ $inverseJoinColumn['name'] = $targetShortName . '_id';
+ }
+ if (empty($inverseJoinColumn['referencedColumnName'])) {
+ $inverseJoinColumn['referencedColumnName'] = 'id';
+ }
if (isset($inverseJoinColumn['onDelete']) && strtolower($inverseJoinColumn['onDelete']) == 'cascade') {
$mapping['isOnDeleteCascade'] = true;
}
-
$mapping['relationToTargetKeyColumns'][$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName'];
$mapping['joinTableColumns'][] = $inverseJoinColumn['name'];
}
@@ -899,7 +896,7 @@ class ClassMetadataInfo
throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
}
}
-
+
return $mapping;
}
@@ -1226,22 +1223,33 @@ class ClassMetadataInfo
* indexes => array of indexes (optional)
* uniqueConstraints => array of constraints (optional)
*
- * @param array $table
+ * If a key is omitted, the current value is kept.
+ *
+ * @param array $table The table description.
*/
public function setPrimaryTable(array $table)
{
- if (isset($table['name']) && $table['name'][0] == '`') {
- $table['name'] = trim($table['name'], '`');
- $table['quoted'] = true;
+ if (isset($table['name'])) {
+ if ($table['name'][0] == '`') {
+ $this->table['name'] = trim($table['name'], '`');
+ $this->table['quoted'] = true;
+ } else {
+ $this->table['name'] = $table['name'];
+ }
+ }
+ if (isset($table['indexes'])) {
+ $this->table['indexes'] = $table['indexes'];
+ }
+ if (isset($table['uniqueConstraints'])) {
+ $this->table['uniqueConstraints'] = $table['uniqueConstraints'];
}
- $this->table = $table;
}
/**
* Checks whether the given type identifies an inheritance type.
*
- * @param string $type
- * @return boolean
+ * @param integer $type
+ * @return boolean TRUE if the given type identifies an inheritance type, FALSe otherwise.
*/
private function _isInheritanceType($type)
{
diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
index 0f3db557a..be24e69db 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
@@ -179,16 +179,12 @@ class AnnotationDriver implements Driver
'type' => $discrColumnAnnot->type,
'length' => $discrColumnAnnot->length
));
- } else {
- throw MappingException::missingDiscriminatorColumn($className);
}
// Evaluate DiscriminatorMap annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorMap'])) {
$discrMapAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorMap'];
$metadata->setDiscriminatorMap($discrMapAnnot->value);
- } else {
- throw MappingException::missingDiscriminatorMap($className);
}
}
}
diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
index 3a95ca52c..7ffcd0001 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
@@ -87,8 +87,6 @@ class XmlDriver extends AbstractFileDriver
'type' => (string)$discrColumn['type'],
'length' => (string)$discrColumn['length']
));
- } else {
- throw MappingException::missingDiscriminatorColumn($className);
}
// Evaluate
@@ -98,8 +96,6 @@ class XmlDriver extends AbstractFileDriver
$map[(string)$discrMapElement['value']] = (string)$discrMapElement['class'];
}
$metadata->setDiscriminatorMap($map);
- } else {
- throw MappingException::missingDiscriminatorMap($className);
}
}
}
diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
index 5ab26e388..21130c349 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
@@ -79,15 +79,11 @@ class YamlDriver extends AbstractFileDriver
'type' => $discrColumn['type'],
'length' => $discrColumn['length']
));
- } else {
- throw MappingException::missingDiscriminatorColumn($className);
}
// Evaluate discriminatorMap
if (isset($element['discriminatorMap'])) {
$metadata->setDiscriminatorMap($element['discriminatorMap']);
- } else {
- throw MappingException::missingDiscriminatorMap($className);
}
}
}
@@ -452,6 +448,6 @@ class YamlDriver extends AbstractFileDriver
*/
protected function _loadMappingFile($file)
{
- return \Symfony\Components\Yaml\Yaml::load($file);
+ return \Symfony\Component\Yaml\Yaml::load($file);
}
}
diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php
index 34437d570..6c09e9697 100644
--- a/lib/Doctrine/ORM/PersistentCollection.php
+++ b/lib/Doctrine/ORM/PersistentCollection.php
@@ -661,4 +661,21 @@ final class PersistentCollection implements Collection
{
return $this->coll;
}
+
+ /**
+ * Extract a slice of $length elements starting at position $offset from the Collection.
+ *
+ * If $length is null it returns all elements from $offset to the end of the Collection.
+ * Keys have to be preserved by this method. Calling this method will only return the
+ * selected slice and NOT change the elements contained in the collection slice is called on.
+ *
+ * @param int $offset
+ * @param int $length
+ * @return array
+ */
+ public function slice($offset, $length = null)
+ {
+ $this->initialize();
+ return $this->coll->slice($offset, $length);
+ }
}
diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php
index 8aa82e9dd..3d3fb5f5e 100644
--- a/lib/Doctrine/ORM/Query/Parser.php
+++ b/lib/Doctrine/ORM/Query/Parser.php
@@ -425,15 +425,11 @@ class Parser
/**
* Checks if the given token indicates a mathematical operator.
*
- * @return boolean TRUE is the token is a mathematical operator, FALSE otherwise.
+ * @return boolean TRUE if the token is a mathematical operator, FALSE otherwise.
*/
private function _isMathOperator($token)
{
- if (in_array($token['value'], array("+", "-", "/", "*"))) {
- return true;
- }
-
- return false;
+ return in_array($token['value'], array("+", "-", "/", "*"));
}
/**
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php
index 198f228b3..0bb318995 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console;
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console;
/**
* Command to clear the metadata cache of the various cache drivers.
@@ -82,4 +82,4 @@ EOT
$output->write('No entries to be deleted.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php
index d42137e20..9b7129208 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console;
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console;
/**
* Command to clear the query cache of the various cache drivers.
@@ -82,4 +82,4 @@ EOT
$output->write('No entries to be deleted.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php
index 2354360e5..d994d708f 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console;
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console;
/**
* Command to clear the result cache of the various cache drivers.
@@ -165,4 +165,4 @@ EOT
$output->write('No entries to be deleted.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php
index 42985393b..a518b76e8 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console,
Doctrine\ORM\Tools\Export\ClassMetadataExporter,
Doctrine\ORM\Tools\ConvertDoctrine1Schema,
Doctrine\ORM\Tools\EntityGenerator;
@@ -220,4 +220,4 @@ EOT
$output->write('No Metadata Classes to process.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php
index 6770e6360..ad3134779 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console,
Doctrine\ORM\Tools\Console\MetadataFilter,
Doctrine\ORM\Tools\Export\ClassMetadataExporter,
Doctrine\ORM\Tools\EntityGenerator,
@@ -147,4 +147,4 @@ EOT
$output->write('No Metadata Classes to process.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php
index 7c33174f5..4fdd8fad7 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console;
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console;
/**
* Command to ensure that Doctrine is properly configured for a production environment.
@@ -82,4 +82,4 @@ EOT
$output->write('Environment is correctly configured for production.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php
index 7565442ca..08654ba18 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console,
Doctrine\ORM\Tools\Console\MetadataFilter,
Doctrine\ORM\Tools\EntityGenerator,
Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
@@ -142,4 +142,4 @@ EOT
$output->write('No Metadata Classes to process.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php
index 412cf869b..09376d867 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console,
Doctrine\ORM\Tools\Console\MetadataFilter;
/**
@@ -112,4 +112,4 @@ EOT
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php
index f417ee0f9..a70aa39d0 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console,
Doctrine\ORM\Tools\Console\MetadataFilter,
Doctrine\ORM\Tools\EntityRepositoryGenerator;
@@ -113,4 +113,4 @@ EOT
$output->write('No Metadata Classes to process.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php
index fc375812b..678b045d3 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console;
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console;
/**
* Command to execute DQL queries in a given EntityManager.
@@ -121,4 +121,4 @@ EOT
\Doctrine\Common\Util\Debug::dump($resultSet, $input->getOption('depth'));
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php
index 84267fbd7..cd53948c4 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php
@@ -21,11 +21,11 @@
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console\Input\InputInterface,
- Symfony\Components\Console\Output\OutputInterface,
- Symfony\Components\Console\Command\Command,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console\Input\InputInterface,
+ Symfony\Component\Console\Output\OutputInterface,
+ Symfony\Component\Console\Command\Command,
Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper,
Doctrine\ORM\Tools\SchemaTool,
Doctrine\ORM\Mapping\Driver\AbstractFileDriver;
@@ -61,4 +61,4 @@ abstract class AbstractCommand extends Command
$output->write('No Metadata Classes to process.' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php
index 06332a3eb..c3870221b 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php
@@ -21,10 +21,10 @@
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console\Input\InputInterface,
- Symfony\Components\Console\Output\OutputInterface,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console\Input\InputInterface,
+ Symfony\Component\Console\Output\OutputInterface,
Doctrine\ORM\Tools\SchemaTool;
/**
@@ -74,4 +74,4 @@ EOT
$output->write('Database schema created successfully!' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php
index 1c6d0c57a..0d6741717 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php
@@ -21,10 +21,10 @@
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console\Input\InputInterface,
- Symfony\Components\Console\Output\OutputInterface,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console\Input\InputInterface,
+ Symfony\Component\Console\Output\OutputInterface,
Doctrine\ORM\Tools\SchemaTool;
/**
@@ -75,4 +75,4 @@ EOT
$output->write('Database schema dropped successfully!' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php
index 32d8fd0f7..986d97954 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php
@@ -21,10 +21,10 @@
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console\Input\InputInterface,
- Symfony\Components\Console\Output\OutputInterface,
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console\Input\InputInterface,
+ Symfony\Component\Console\Output\OutputInterface,
Doctrine\ORM\Tools\SchemaTool;
/**
@@ -83,4 +83,4 @@ EOT
$output->write('Database schema updated successfully!' . PHP_EOL);
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php
index 29695ba12..994b89578 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php
@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Tools\Console\Command;
-use Symfony\Components\Console\Input\InputArgument,
- Symfony\Components\Console\Input\InputOption,
- Symfony\Components\Console;
+use Symfony\Component\Console\Input\InputArgument,
+ Symfony\Component\Console\Input\InputOption,
+ Symfony\Component\Console;
/**
* Validate that the current mapping is valid
@@ -86,4 +86,4 @@ EOT
exit($exit);
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php b/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php
index 2636006e3..c28622ebb 100644
--- a/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php
+++ b/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php
@@ -21,7 +21,7 @@
namespace Doctrine\ORM\Tools\Console\Helper;
-use Symfony\Components\Console\Helper\Helper,
+use Symfony\Component\Console\Helper\Helper,
Doctrine\ORM\EntityManager;
/**
@@ -71,4 +71,4 @@ class EntityManagerHelper extends Helper
{
return 'entityManager';
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php b/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php
index d0eb5e9f0..14c9ada9a 100644
--- a/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php
+++ b/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php
@@ -70,10 +70,10 @@ class ConvertDoctrine1Schema
if (is_dir($path)) {
$files = glob($path . '/*.yml');
foreach ($files as $file) {
- $schema = array_merge($schema, (array) \Symfony\Components\Yaml\Yaml::load($file));
+ $schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::load($file));
}
} else {
- $schema = array_merge($schema, (array) \Symfony\Components\Yaml\Yaml::load($path));
+ $schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::load($path));
}
}
@@ -271,4 +271,4 @@ class ConvertDoctrine1Schema
}
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php b/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php
index 4957b2c94..436c04b4f 100644
--- a/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php
+++ b/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php
@@ -44,7 +44,7 @@ class DisconnectedClassMetadataFactory extends ClassMetadataFactory
/**
* @override
*/
- protected function _newClassMetadataInstance($className)
+ protected function newClassMetadataInstance($className)
{
return new ClassMetadataInfo($className);
}
@@ -52,7 +52,7 @@ class DisconnectedClassMetadataFactory extends ClassMetadataFactory
/**
* @override
*/
- protected function _getParentClasses($name)
+ protected function getParentClasses($name)
{
return array();
}
diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
index 28414cdbd..1c140e1bf 100644
--- a/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
+++ b/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
@@ -198,6 +198,6 @@ class YamlExporter extends AbstractExporter
$array['lifecycleCallbacks'] = $metadata->lifecycleCallbacks;
}
- return \Symfony\Components\Yaml\Yaml::dump(array($metadata->name => $array), 10);
+ return \Symfony\Component\Yaml\Yaml::dump(array($metadata->name => $array), 10);
}
-}
\ No newline at end of file
+}
diff --git a/lib/vendor/Symfony/Components/Console/Application.php b/lib/vendor/Symfony/Component/Console/Application.php
similarity index 96%
rename from lib/vendor/Symfony/Components/Console/Application.php
rename to lib/vendor/Symfony/Component/Console/Application.php
index 929bc6bc0..af488e347 100644
--- a/lib/vendor/Symfony/Components/Console/Application.php
+++ b/lib/vendor/Symfony/Component/Console/Application.php
@@ -1,22 +1,22 @@
useModelSet('cms');
parent::setUp();
}
-
- /**
- * @expectedException Doctrine\ORM\Query\QueryException
- */
- public function testParameterIndexZeroThrowsException()
- {
- $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
- $query->execute(array(42)); // same as array(0 => 42), 0 is invalid parameter position
- }
-
- public function testGetParameters()
- {
- $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
- $this->assertEquals(array(), $query->getParameters());
- }
-
- public function testGetParameters_HasSomeAlready()
- {
- $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
- $query->setParameter(2, 84);
- $this->assertEquals(array(2 => 84), $query->getParameters());
- }
public function testSimpleQueries()
{
diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php
index fcdfb0c2a..6a691a1d6 100644
--- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php
@@ -19,7 +19,7 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testPostgresMetadataSequenceIncrementedBy10()
{
$address = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
- $this->assertEquals(10, $address->sequenceGeneratorDefinition['allocationSize']);
+ $this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']);
}
public function testGetCreateSchemaSql()
@@ -39,8 +39,8 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals("CREATE UNIQUE INDEX cms_users_username_uniq ON cms_users (username)", $sql[3]);
$this->assertEquals("CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))", $sql[4]);
$this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))", $sql[5]);
- $this->assertEquals("CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[6]);
- $this->assertEquals("CREATE SEQUENCE cms_users_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[7]);
+ $this->assertEquals("CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[6]);
+ $this->assertEquals("CREATE SEQUENCE cms_users_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[7]);
$this->assertEquals("ALTER TABLE cms_addresses ADD FOREIGN KEY (user_id) REFERENCES cms_users(id) NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[8]);
$this->assertEquals("ALTER TABLE cms_users_groups ADD FOREIGN KEY (user_id) REFERENCES cms_users(id) NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[9]);
$this->assertEquals("ALTER TABLE cms_users_groups ADD FOREIGN KEY (group_id) REFERENCES cms_groups(id) NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[10]);
@@ -61,7 +61,7 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(2, count($sql));
$this->assertEquals('CREATE TABLE decimal_model (id INT NOT NULL, "decimal" NUMERIC(5, 2) NOT NULL, "high_scale" NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id))', $sql[0]);
- $this->assertEquals("CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[1]);
+ $this->assertEquals("CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[1]);
}
public function testGetCreateSchemaSql3()
@@ -75,6 +75,6 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(2, count($sql));
$this->assertEquals("CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))", $sql[0]);
- $this->assertEquals("CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[1]);
+ $this->assertEquals("CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[1]);
}
}
diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php
index 1c3d91eff..468ef680d 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php
@@ -90,24 +90,6 @@ class AnnotationDriverTest extends AbstractMappingDriverTest
$this->assertNotContains($extraneousClassName, $classes);
}
- public function testInheritenceWithoutDiscriminatorMap()
- {
- $cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ClassWithoutDiscriminatorMap');
- $annotationDriver = $this->_loadDriver();
-
- $this->setExpectedException("Doctrine\ORM\Mapping\MappingException");
- $annotationDriver->loadMetadataForClass($cm->name, $cm);
- }
-
- public function testInheritenceWithoutDiscriminatorColumn()
- {
- $cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ClassWithoutDiscriminatorColumn');
- $annotationDriver = $this->_loadDriver();
-
- $this->setExpectedException("Doctrine\ORM\Mapping\MappingException");
- $annotationDriver->loadMetadataForClass($cm->name, $cm);
- }
-
protected function _loadDriverForCMSModels()
{
$annotationDriver = $this->_loadDriver();
@@ -137,25 +119,3 @@ class ColumnWithoutType
/** @Id @Column */
public $id;
}
-
-/**
- * @Entity
- * @InheritanceType("SINGLE_TABLE")
- * @DiscriminatorMap({"a" = "ClassWithoutDiscriminatorColumn"})
- */
-class ClassWithoutDiscriminatorColumn
-{
- /** @Id @Column */
- public $id;
-}
-
-/**
- * @Entity
- * @InheritanceType("SINGLE_TABLE")
- * @DiscriminatorColumn(name="discr", type="string")
- */
-class ClassWithoutDiscriminatorMap
-{
- /** @Id @Column */
- public $id;
-}
\ No newline at end of file
diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php
index 5236bdf91..cbd9ce5e5 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php
@@ -102,27 +102,27 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
/* Test subject class with overriden factory method for mocking purposes */
class ClassMetadataFactoryTestSubject extends \Doctrine\ORM\Mapping\ClassMetadataFactory
{
- private $_mockMetadata = array();
- private $_requestedClasses = array();
+ private $mockMetadata = array();
+ private $requestedClasses = array();
/** @override */
- protected function _newClassMetadataInstance($className)
+ protected function newClassMetadataInstance($className)
{
- $this->_requestedClasses[] = $className;
- if ( ! isset($this->_mockMetadata[$className])) {
+ $this->requestedClasses[] = $className;
+ if ( ! isset($this->mockMetadata[$className])) {
throw new InvalidArgumentException("No mock metadata found for class $className.");
}
- return $this->_mockMetadata[$className];
+ return $this->mockMetadata[$className];
}
public function setMetadataForClass($className, $metadata)
{
- $this->_mockMetadata[$className] = $metadata;
+ $this->mockMetadata[$className] = $metadata;
}
public function getRequestedClasses()
{
- return $this->_requestedClasses;
+ return $this->requestedClasses;
}
}
diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
index b51d34831..34829fcae 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
@@ -102,9 +102,9 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
$assoc = $cm->associationMappings['groups'];
//$this->assertTrue($assoc instanceof \Doctrine\ORM\Mapping\ManyToManyMapping);
$this->assertEquals(array(
- 'name' => 'CmsUser_CmsGroup',
- 'joinColumns' => array(array('name' => 'CmsUser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')),
- 'inverseJoinColumns' => array(array('name' => 'CmsGroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE'))
+ 'name' => 'cmsuser_cmsgroup',
+ 'joinColumns' => array(array('name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')),
+ 'inverseJoinColumns' => array(array('name' => 'cmsgroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE'))
), $assoc['joinTable']);
$this->assertTrue($assoc['isOnDeleteCascade']);
}
@@ -231,4 +231,49 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
$cm->mapField(array('fieldName' => 'name', 'columnName' => 'name'));
}
+
+ public function testDefaultTableName()
+ {
+ $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
+
+ // When table's name is not given
+ $primaryTable = array();
+ $cm->setPrimaryTable($primaryTable);
+
+ $this->assertEquals('CmsUser', $cm->getTableName());
+ $this->assertEquals('CmsUser', $cm->table['name']);
+
+ $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
+ // When joinTable's name is not given
+ $cm->mapManyToMany(array(
+ 'fieldName' => 'user',
+ 'targetEntity' => 'CmsUser',
+ 'inversedBy' => 'users',
+ 'joinTable' => array('joinColumns' => array(array('referencedColumnName' => 'id')),
+ 'inverseJoinColumns' => array(array('referencedColumnName' => 'id')))));
+ $this->assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']);
+ }
+
+ public function testDefaultJoinColumnName()
+ {
+ $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
+ // this is really dirty, but it's the simpliest way to test whether
+ // joinColumn's name will be automatically set to user_id
+ $cm->mapOneToOne(array(
+ 'fieldName' => 'user',
+ 'targetEntity' => 'CmsUser',
+ 'joinColumns' => array(array('referencedColumnName' => 'id'))));
+ $this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']);
+
+ $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
+ $cm->mapManyToMany(array(
+ 'fieldName' => 'user',
+ 'targetEntity' => 'CmsUser',
+ 'inversedBy' => 'users',
+ 'joinTable' => array('name' => 'user_CmsUser',
+ 'joinColumns' => array(array('referencedColumnName' => 'id')),
+ 'inverseJoinColumns' => array(array('referencedColumnName' => 'id')))));
+ $this->assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']);
+ $this->assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']);
+ }
}
\ No newline at end of file
diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php
index 2aad38645..9cc3b8f5c 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php
@@ -12,10 +12,10 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest
{
protected function _loadDriver()
{
- if (!class_exists('Symfony\Components\Yaml\Yaml', true)) {
+ if (!class_exists('Symfony\Component\Yaml\Yaml', true)) {
$this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
}
return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml');
}
-}
\ No newline at end of file
+}
diff --git a/tests/Doctrine/Tests/ORM/Query/AllTests.php b/tests/Doctrine/Tests/ORM/Query/AllTests.php
index 02ab07365..0d94856f9 100644
--- a/tests/Doctrine/Tests/ORM/Query/AllTests.php
+++ b/tests/Doctrine/Tests/ORM/Query/AllTests.php
@@ -26,6 +26,7 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Query\UpdateSqlGenerationTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\ExprTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\ParserResultTest');
+ $suite->addTestSuite('Doctrine\Tests\ORM\Query\QueryTest');
return $suite;
}
diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php
new file mode 100644
index 000000000..f606f0900
--- /dev/null
+++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php
@@ -0,0 +1,47 @@
+_em = $this->_getTestEntityManager();
+ }
+
+ /**
+ * @expectedException Doctrine\ORM\Query\QueryException
+ */
+ public function testParameterIndexZeroThrowsException()
+ {
+ $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
+ $query->execute(array(42)); // same as array(0 => 42), 0 is invalid parameter position
+ }
+
+ public function testGetParameters()
+ {
+ $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
+ $this->assertEquals(array(), $query->getParameters());
+ }
+
+ public function testGetParameters_HasSomeAlready()
+ {
+ $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
+ $query->setParameter(2, 84);
+ $this->assertEquals(array(2 => 84), $query->getParameters());
+ }
+
+ public function testFree()
+ {
+ $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
+ $query->setParameter(2, 84, \PDO::PARAM_INT);
+
+ $query->free();
+
+ $this->assertEquals(array(), $query->getParameters());
+ }
+}
\ No newline at end of file
diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php
index cf520fc39..a17073162 100644
--- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php
+++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php
@@ -13,7 +13,7 @@ class ConvertDoctrine1SchemaCommandTest extends \Doctrine\Tests\OrmTestCase
$command = new ConvertDoctrine1SchemaCommand();
$command->setEntityGenerator($entityGenerator);
- $output = $this->getMock('Symfony\Components\Console\Output\OutputInterface');
+ $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$output->expects($this->once())
->method('write')
->with($this->equalTo('No Metadata Classes to process.' . PHP_EOL));
diff --git a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php
index eafe63d1f..6f542dba9 100644
--- a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php
+++ b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php
@@ -61,7 +61,7 @@ class ConvertDoctrine1SchemaTest extends \Doctrine\Tests\OrmTestCase
public function testTest()
{
- if ( ! class_exists('Symfony\Components\Yaml\Yaml', true)) {
+ if ( ! class_exists('Symfony\Component\Yaml\Yaml', true)) {
$this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
}
@@ -100,4 +100,4 @@ class ConvertDoctrine1SchemaTest extends \Doctrine\Tests\OrmTestCase
unlink(__DIR__ . '/convert/Profile.dcm.yml');
rmdir(__DIR__ . '/convert');
}
-}
\ No newline at end of file
+}
diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php
index d7258a561..406101ac7 100644
--- a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php
+++ b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php
@@ -37,10 +37,10 @@ class YamlClassMetadataExporterTest extends AbstractClassMetadataExporterTest
{
protected function _getType()
{
- if (!class_exists('Symfony\Components\Yaml\Yaml', true)) {
+ if (!class_exists('Symfony\Component\Yaml\Yaml', true)) {
$this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
}
return 'yaml';
}
-}
\ No newline at end of file
+}
diff --git a/tools/sandbox/doctrine.php b/tools/sandbox/doctrine.php
index 9d498d440..fc3c96db4 100644
--- a/tools/sandbox/doctrine.php
+++ b/tools/sandbox/doctrine.php
@@ -18,7 +18,7 @@ $classLoader->register();
// Variable $helperSet is defined inside cli-config.php
require __DIR__ . '/cli-config.php';
-$cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
+$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
$cli->setCatchExceptions(true);
$helperSet = $cli->getHelperSet();
foreach ($helpers as $name => $helper) {
@@ -46,4 +46,4 @@ $cli->addCommands(array(
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
));
-$cli->run();
\ No newline at end of file
+$cli->run();