1
0
mirror of synced 2025-01-19 06:51:40 +03:00

Fixing code sniff issues before continuing refactoring of

This commit is contained in:
Marco Pivetta 2012-06-09 15:17:45 +02:00
parent e522391ee9
commit 94714db132
7 changed files with 135 additions and 80 deletions

View File

@ -19,8 +19,6 @@
namespace Doctrine\ORM\Mapping; namespace Doctrine\ORM\Mapping;
use ReflectionClass, ReflectionProperty;
/** /**
* A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata * A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata
* of an entity and it's associations. * of an entity and it's associations.

View File

@ -26,11 +26,12 @@ use ReflectionException,
Doctrine\ORM\Events, Doctrine\ORM\Events,
Doctrine\Common\Persistence\Mapping\ReflectionService, Doctrine\Common\Persistence\Mapping\ReflectionService,
Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface, Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface,
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory; Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory,
Doctrine\ORM\Id\IdentityGenerator;
/** /**
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
* metadata mapping informations of a class which describes how a class should be mapped * metadata mapping information of a class which describes how a class should be mapped
* to a relational database. * to a relational database.
* *
* @since 2.0 * @since 2.0
@ -47,7 +48,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
private $em; private $em;
/** /**
* @var AbstractPlatform * @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/ */
private $targetPlatform; private $targetPlatform;
@ -62,7 +63,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
private $evm; private $evm;
/** /**
* @param EntityManager $$em * @param EntityManager $em
* @return void
*/ */
public function setEntityManager(EntityManager $em) public function setEntityManager(EntityManager $em)
{ {
@ -137,13 +139,13 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
} }
// If this class has a parent the id generator strategy is inherited. // If this class has a parent the id generator strategy is inherited.
// However this is only true if the hierachy of parents contains the root entity, // However this is only true if the hierarchy of parents contains the root entity,
// if it consinsts of mapped superclasses these don't necessarily include the id field. // if it consists of mapped superclasses these don't necessarily include the id field.
if ($parent && $rootEntityFound) { if ($parent && $rootEntityFound) {
if ($parent->isIdGeneratorSequence()) { if ($parent->isIdGeneratorSequence()) {
$class->setSequenceGeneratorDefinition($parent->sequenceGeneratorDefinition); $class->setSequenceGeneratorDefinition($parent->sequenceGeneratorDefinition);
} else if ($parent->isIdGeneratorTable()) { } else if ($parent->isIdGeneratorTable()) {
$class->getTableGeneratorDefinition($parent->tableGeneratorDefinition); $class->tableGeneratorDefinition = $parent->tableGeneratorDefinition;
} }
if ($parent->generatorType) { if ($parent->generatorType) {
$class->setIdGeneratorType($parent->generatorType); $class->setIdGeneratorType($parent->generatorType);
@ -208,7 +210,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
* Validate runtime metadata is correctly defined. * Validate runtime metadata is correctly defined.
* *
* @param ClassMetadata $class * @param ClassMetadata $class
* @param ClassMetadata $parent * @param $parent
* @throws MappingException
* @return void
*/ */
protected function validateRuntimeMetadata($class, $parent) protected function validateRuntimeMetadata($class, $parent)
{ {
@ -231,11 +235,11 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
throw MappingException::missingDiscriminatorColumn($class->name); throw MappingException::missingDiscriminatorColumn($class->name);
} }
} else if ($parent && !$class->reflClass->isAbstract() && !in_array($class->name, array_values($class->discriminatorMap))) { } else if ($parent && !$class->reflClass->isAbstract() && !in_array($class->name, array_values($class->discriminatorMap))) {
// enforce discriminator map for all entities of an inheritance hierachy, otherwise problems will occur. // enforce discriminator map for all entities of an inheritance hierarchy, otherwise problems will occur.
throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName); throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName);
} }
} else if ($class->isMappedSuperclass && $class->name == $class->rootEntityName && (count($class->discriminatorMap) || $class->discriminatorColumn)) { } else if ($class->isMappedSuperclass && $class->name == $class->rootEntityName && (count($class->discriminatorMap) || $class->discriminatorColumn)) {
// second condition is necessary for mapped superclasses in the middle of an inheritance hierachy // second condition is necessary for mapped superclasses in the middle of an inheritance hierarchy
throw MappingException::noInheritanceOnMappedSuperClass($class->name); throw MappingException::noInheritanceOnMappedSuperClass($class->name);
} }
} }
@ -252,18 +256,19 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
* Adds a default discriminator map if no one is given * Adds a default discriminator map if no one is given
* *
* If an entity is of any inheritance type and does not contain a * If an entity is of any inheritance type and does not contain a
* discrimiator map, then the map is generated automatically. This process * discriminator map, then the map is generated automatically. This process
* is expensive computation wise. * is expensive computation wise.
* *
* The automatically generated discriminator map contains the lowercase short name of * The automatically generated discriminator map contains the lowercase short name of
* each class as key. * each class as key.
* *
* @param \Doctrine\ORM\Mapping\ClassMetadata $class * @param \Doctrine\ORM\Mapping\ClassMetadata $class
* @throws MappingException
* @return void
*/ */
private function addDefaultDiscriminatorMap(ClassMetadata $class) private function addDefaultDiscriminatorMap(ClassMetadata $class)
{ {
$allClasses = $this->driver->getAllClassNames(); $allClasses = $this->driver->getAllClassNames();
$subClassesMetadata = array();
$fqcn = $class->getName(); $fqcn = $class->getName();
$map = array($this->getShortName($class->name) => $fqcn); $map = array($this->getShortName($class->name) => $fqcn);
@ -330,6 +335,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
* *
* @param \Doctrine\ORM\Mapping\ClassMetadata $subClass * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass
* @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
* @throws MappingException
* @return void
*/ */
private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass) private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
{ {
@ -427,7 +434,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
* Completes the ID generator mapping. If "auto" is specified we choose the generator * Completes the ID generator mapping. If "auto" is specified we choose the generator
* most appropriate for the targeted database platform. * most appropriate for the targeted database platform.
* *
* @param \Doctrine\ORM\Mapping\ClassMetadata $class * @param ClassMetadataInfo $class
* @throws ORMException
* @return void
*/ */
private function completeIdGeneratorMapping(ClassMetadataInfo $class) private function completeIdGeneratorMapping(ClassMetadataInfo $class)
{ {
@ -549,6 +558,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
*/ */
protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService) protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService)
{ {
/* @var $class ClassMetadata */
$class->wakeupReflection($reflService); $class->wakeupReflection($reflService);
} }
@ -557,6 +567,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
*/ */
protected function initializeReflection(ClassMetadataInterface $class, ReflectionService $reflService) protected function initializeReflection(ClassMetadataInterface $class, ReflectionService $reflService)
{ {
/* @var $class ClassMetadata */
$class->initializeReflection($reflService); $class->initializeReflection($reflService);
} }

View File

@ -19,9 +19,13 @@
namespace Doctrine\ORM\Mapping; namespace Doctrine\ORM\Mapping;
use BadMethodCallException;
use InvalidArgumentException;
use RuntimeException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use ReflectionClass; use ReflectionClass;
use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\ClassLoader;
/** /**
* A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata * A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata
@ -617,7 +621,7 @@ class ClassMetadataInfo implements ClassMetadata
* Gets a ReflectionProperty for a specific field of the mapped class. * Gets a ReflectionProperty for a specific field of the mapped class.
* *
* @param string $name * @param string $name
* @return ReflectionProperty * @return \ReflectionProperty
*/ */
public function getReflectionProperty($name) public function getReflectionProperty($name)
{ {
@ -627,13 +631,13 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Gets the ReflectionProperty for the single identifier field. * Gets the ReflectionProperty for the single identifier field.
* *
* @return ReflectionProperty * @return \ReflectionProperty
* @throws BadMethodCallException If the class has a composite identifier. * @throws BadMethodCallException If the class has a composite identifier.
*/ */
public function getSingleIdReflectionProperty() public function getSingleIdReflectionProperty()
{ {
if ($this->isIdentifierComposite) { if ($this->isIdentifierComposite) {
throw new \BadMethodCallException("Class " . $this->name . " has a composite identifier."); throw new BadMethodCallException("Class " . $this->name . " has a composite identifier.");
} }
return $this->reflFields[$this->identifier[0]]; return $this->reflFields[$this->identifier[0]];
} }
@ -831,7 +835,7 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Restores some state that can not be serialized/unserialized. * Restores some state that can not be serialized/unserialized.
* *
* @param ReflectionService $reflService * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService
* @return void * @return void
*/ */
public function wakeupReflection($reflService) public function wakeupReflection($reflService)
@ -856,7 +860,7 @@ class ClassMetadataInfo implements ClassMetadata
* Initializes a new ClassMetadata instance that will hold the object-relational mapping * Initializes a new ClassMetadata instance that will hold the object-relational mapping
* metadata of the class with the given name. * metadata of the class with the given name.
* *
* @param ReflectionService $reflService The reflection service. * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service.
*/ */
public function initializeReflection($reflService) public function initializeReflection($reflService)
{ {
@ -873,6 +877,7 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Validate Identifier * Validate Identifier
* *
* @throws MappingException
* @return void * @return void
*/ */
public function validateIdentifier() public function validateIdentifier()
@ -890,12 +895,13 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Validate association targets actually exist. * Validate association targets actually exist.
* *
* @throws MappingException
* @return void * @return void
*/ */
public function validateAssocations() public function validateAssocations()
{ {
foreach ($this->associationMappings as $mapping) { foreach ($this->associationMappings as $mapping) {
if ( ! \Doctrine\Common\ClassLoader::classExists($mapping['targetEntity']) ) { if ( ! ClassLoader::classExists($mapping['targetEntity']) ) {
throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']); throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
} }
} }
@ -904,12 +910,13 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Validate lifecycle callbacks * Validate lifecycle callbacks
* *
* @param ReflectionService $reflService * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService
* @throws MappingException
* @return void * @return void
*/ */
public function validateLifecycleCallbacks($reflService) public function validateLifecycleCallbacks($reflService)
{ {
foreach ($this->lifecycleCallbacks as $event => $callbacks) { foreach ($this->lifecycleCallbacks as $callbacks) {
foreach ($callbacks as $callbackFuncName) { foreach ($callbacks as $callbackFuncName) {
if ( ! $reflService->hasPublicMethod($this->name, $callbackFuncName)) { if ( ! $reflService->hasPublicMethod($this->name, $callbackFuncName)) {
throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callbackFuncName); throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callbackFuncName);
@ -1032,6 +1039,7 @@ class ClassMetadataInfo implements ClassMetadata
* reference to another object. * reference to another object.
* *
* @param string $fieldName The field name. * @param string $fieldName The field name.
* @throws MappingException
* @return array The field mapping. * @return array The field mapping.
*/ */
public function getFieldMapping($fieldName) public function getFieldMapping($fieldName)
@ -1048,6 +1056,7 @@ class ClassMetadataInfo implements ClassMetadata
* @see ClassMetadataInfo::$associationMappings * @see ClassMetadataInfo::$associationMappings
* @param string $fieldName The field name that represents the association in * @param string $fieldName The field name that represents the association in
* the object model. * the object model.
* @throws MappingException
* @return array The mapping. * @return array The mapping.
*/ */
public function getAssociationMapping($fieldName) public function getAssociationMapping($fieldName)
@ -1165,6 +1174,7 @@ class ClassMetadataInfo implements ClassMetadata
* Validates & completes the given field mapping. * Validates & completes the given field mapping.
* *
* @param array $mapping The field mapping to validated & complete. * @param array $mapping The field mapping to validated & complete.
* @throws MappingException
* @return array The validated and completed field mapping. * @return array The validated and completed field mapping.
*/ */
protected function _validateAndCompleteFieldMapping(array &$mapping) protected function _validateAndCompleteFieldMapping(array &$mapping)
@ -1342,8 +1352,9 @@ class ClassMetadataInfo implements ClassMetadata
* Validates & completes a one-to-one association mapping. * Validates & completes a one-to-one association mapping.
* *
* @param array $mapping The mapping to validate & complete. * @param array $mapping The mapping to validate & complete.
* @return array The validated & completed mapping. * @throws RuntimeException
* @override * @throws MappingException
* @return array The validated & completed mapping.@override
*/ */
protected function _validateAndCompleteOneToOneMapping(array $mapping) protected function _validateAndCompleteOneToOneMapping(array $mapping)
{ {
@ -1363,7 +1374,7 @@ class ClassMetadataInfo implements ClassMetadata
} }
$uniqueContraintColumns = array(); $uniqueContraintColumns = array();
foreach ($mapping['joinColumns'] as $key => &$joinColumn) { foreach ($mapping['joinColumns'] as &$joinColumn) {
if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) {
if (count($mapping['joinColumns']) == 1) { if (count($mapping['joinColumns']) == 1) {
if ( ! isset($mapping['id']) || ! $mapping['id']) { if ( ! isset($mapping['id']) || ! $mapping['id']) {
@ -1399,7 +1410,7 @@ class ClassMetadataInfo implements ClassMetadata
if ($uniqueContraintColumns) { if ($uniqueContraintColumns) {
if ( ! $this->table) { if ( ! $this->table) {
throw new \RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship."); throw new RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship.");
} }
$this->table['uniqueConstraints'][$mapping['fieldName']."_uniq"] = array( $this->table['uniqueConstraints'][$mapping['fieldName']."_uniq"] = array(
'columns' => $uniqueContraintColumns 'columns' => $uniqueContraintColumns
@ -1423,8 +1434,9 @@ class ClassMetadataInfo implements ClassMetadata
* Validates and completes the mapping. * Validates and completes the mapping.
* *
* @param array $mapping The mapping to validate and complete. * @param array $mapping The mapping to validate and complete.
* @return array The validated and completed mapping. * @throws MappingException
* @override * @throws InvalidArgumentException
* @return array The validated and completed mapping.@override
*/ */
protected function _validateAndCompleteOneToManyMapping(array $mapping) protected function _validateAndCompleteOneToManyMapping(array $mapping)
{ {
@ -1440,7 +1452,7 @@ class ClassMetadataInfo implements ClassMetadata
if (isset($mapping['orderBy'])) { if (isset($mapping['orderBy'])) {
if ( ! is_array($mapping['orderBy'])) { if ( ! is_array($mapping['orderBy'])) {
throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy'])); throw new InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
} }
} }
@ -1527,7 +1539,7 @@ class ClassMetadataInfo implements ClassMetadata
if (isset($mapping['orderBy'])) { if (isset($mapping['orderBy'])) {
if ( ! is_array($mapping['orderBy'])) { if ( ! is_array($mapping['orderBy'])) {
throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy'])); throw new InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
} }
} }
@ -1587,7 +1599,7 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Gets the mapped identifier field of this class. * Gets the mapped identifier field of this class.
* *
* @return string $identifier * @return array|string $identifier
*/ */
public function getIdentifier() public function getIdentifier()
{ {
@ -1597,7 +1609,8 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Checks whether the class has a (mapped) field with a certain name. * Checks whether the class has a (mapped) field with a certain name.
* *
* @return boolean * @param string $fieldName
* @return bool
*/ */
public function hasField($fieldName) public function hasField($fieldName)
{ {
@ -1607,6 +1620,7 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Gets an array containing all the column names. * Gets an array containing all the column names.
* *
* @param array $fieldNames
* @return array * @return array
*/ */
public function getColumnNames(array $fieldNames = null) public function getColumnNames(array $fieldNames = null)
@ -1734,7 +1748,7 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function isIdGeneratorTable() public function isIdGeneratorTable()
{ {
$this->generatorType == self::GENERATOR_TYPE_TABLE; return $this->generatorType == self::GENERATOR_TYPE_TABLE;
} }
/** /**
@ -1762,7 +1776,7 @@ class ClassMetadataInfo implements ClassMetadata
* Gets the type of a field. * Gets the type of a field.
* *
* @param string $fieldName * @param string $fieldName
* @return \Doctrine\DBAL\Types\Type * @return \Doctrine\DBAL\Types\Type|string
*/ */
public function getTypeOfField($fieldName) public function getTypeOfField($fieldName)
{ {
@ -1773,6 +1787,7 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Gets the type of a column. * Gets the type of a column.
* *
* @param string $columnName
* @return \Doctrine\DBAL\Types\Type * @return \Doctrine\DBAL\Types\Type
*/ */
public function getTypeOfColumn($columnName) public function getTypeOfColumn($columnName)
@ -1834,6 +1849,8 @@ class ClassMetadataInfo implements ClassMetadata
* Sets the inheritance type used by the class and it's subclasses. * Sets the inheritance type used by the class and it's subclasses.
* *
* @param integer $type * @param integer $type
* @throws MappingException
* @return void
*/ */
public function setInheritanceType($type) public function setInheritanceType($type)
{ {
@ -1848,6 +1865,8 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @param string $fieldName * @param string $fieldName
* @param array $overrideMapping * @param array $overrideMapping
* @throws MappingException
* @return void
*/ */
public function setAssociationOverride($fieldName, array $overrideMapping) public function setAssociationOverride($fieldName, array $overrideMapping)
{ {
@ -1893,7 +1912,10 @@ class ClassMetadataInfo implements ClassMetadata
* Sets the override for a mapped field. * Sets the override for a mapped field.
* *
* @param string $fieldName * @param string $fieldName
* @param array $mapping * @param array $overrideMapping
* @throws MappingException
* @param array $overrideMapping
* @return void
*/ */
public function setAttributeOverride($fieldName, array $overrideMapping) public function setAttributeOverride($fieldName, array $overrideMapping)
{ {
@ -1930,7 +1952,8 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Checks whether a mapped field is inherited from an entity superclass. * Checks whether a mapped field is inherited from an entity superclass.
* *
* @return boolean TRUE if the field is inherited, FALSE otherwise. * @param string $fieldName
* @return bool TRUE if the field is inherited, FALSE otherwise.
*/ */
public function isInheritedField($fieldName) public function isInheritedField($fieldName)
{ {
@ -2023,6 +2046,8 @@ class ClassMetadataInfo implements ClassMetadata
* Adds a mapped field to the class. * Adds a mapped field to the class.
* *
* @param array $mapping The field mapping. * @param array $mapping The field mapping.
* @throws MappingException
* @return void
*/ */
public function mapField(array $mapping) public function mapField(array $mapping)
{ {
@ -2039,6 +2064,8 @@ class ClassMetadataInfo implements ClassMetadata
* This is mainly used to add inherited association mappings to derived classes. * This is mainly used to add inherited association mappings to derived classes.
* *
* @param array $mapping * @param array $mapping
* @throws MappingException
* @return void
*/ */
public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/)
{ {
@ -2053,7 +2080,8 @@ class ClassMetadataInfo implements ClassMetadata
* Adds a field mapping without completing/validating it. * Adds a field mapping without completing/validating it.
* This is mainly used to add inherited field mappings to derived classes. * This is mainly used to add inherited field mappings to derived classes.
* *
* @param array $mapping * @internal param array $fieldMapping
* @return void
*/ */
public function addInheritedFieldMapping(array $fieldMapping) public function addInheritedFieldMapping(array $fieldMapping)
{ {
@ -2247,6 +2275,8 @@ class ClassMetadataInfo implements ClassMetadata
* Stores the association mapping. * Stores the association mapping.
* *
* @param array $assocMapping * @param array $assocMapping
* @throws MappingException
* @return void
*/ */
protected function _storeAssociationMapping(array $assocMapping) protected function _storeAssociationMapping(array $assocMapping)
{ {
@ -2277,8 +2307,8 @@ class ClassMetadataInfo implements ClassMetadata
* Dispatches the lifecycle event of the given entity to the registered * Dispatches the lifecycle event of the given entity to the registered
* lifecycle callbacks and lifecycle listeners. * lifecycle callbacks and lifecycle listeners.
* *
* @param string $event The lifecycle event. * @param string $lifecycleEvent The lifecycle event.
* @param Entity $entity The Entity on which the event occured. * @param \Object $entity The Entity on which the event occured.
*/ */
public function invokeLifecycleCallbacks($lifecycleEvent, $entity) public function invokeLifecycleCallbacks($lifecycleEvent, $entity)
{ {
@ -2335,6 +2365,10 @@ class ClassMetadataInfo implements ClassMetadata
* Sets the discriminator column definition. * Sets the discriminator column definition.
* *
* @param array $columnDef * @param array $columnDef
*
* @param $columnDef
* @throws MappingException
* @return void
* @see getDiscriminatorColumn() * @see getDiscriminatorColumn()
*/ */
public function setDiscriminatorColumn($columnDef) public function setDiscriminatorColumn($columnDef)
@ -2382,6 +2416,8 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @param string $name * @param string $name
* @param string $className * @param string $className
* @throws MappingException
* @return void
*/ */
public function addDiscriminatorMapClass($name, $className) public function addDiscriminatorMapClass($name, $className)
{ {
@ -2493,6 +2529,7 @@ class ClassMetadataInfo implements ClassMetadata
* Return the single association join column (if any). * Return the single association join column (if any).
* *
* @param string $fieldName * @param string $fieldName
* @throws MappingException
* @return string * @return string
*/ */
public function getSingleAssociationJoinColumnName($fieldName) public function getSingleAssociationJoinColumnName($fieldName)
@ -2507,6 +2544,7 @@ class ClassMetadataInfo implements ClassMetadata
* Return the single association referenced join column name (if any). * Return the single association referenced join column name (if any).
* *
* @param string $fieldName * @param string $fieldName
* @throws MappingException
* @return string * @return string
*/ */
public function getSingleAssociationReferencedJoinColumnName($fieldName) public function getSingleAssociationReferencedJoinColumnName($fieldName)
@ -2523,6 +2561,7 @@ class ClassMetadataInfo implements ClassMetadata
* This method is used in foreign-key as primary-key contexts. * This method is used in foreign-key as primary-key contexts.
* *
* @param string $columnName * @param string $columnName
* @throws MappingException
* @return string * @return string
*/ */
public function getFieldForColumn($columnName) public function getFieldForColumn($columnName)
@ -2545,7 +2584,7 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* Sets the ID generator used to generate IDs for instances of this class. * Sets the ID generator used to generate IDs for instances of this class.
* *
* @param AbstractIdGenerator $generator * @param \Doctrine\ORM\Id\AbstractIdGenerator $generator
*/ */
public function setIdGenerator($generator) public function setIdGenerator($generator)
{ {
@ -2591,6 +2630,8 @@ class ClassMetadataInfo implements ClassMetadata
* value to use depending on the column type. * value to use depending on the column type.
* *
* @param array $mapping The version field mapping array * @param array $mapping The version field mapping array
* @throws MappingException
* @return void
*/ */
public function setVersionMapping(array &$mapping) public function setVersionMapping(array &$mapping)
{ {
@ -2667,12 +2708,13 @@ class ClassMetadataInfo implements ClassMetadata
* Returns the target class name of the given association. * Returns the target class name of the given association.
* *
* @param string $assocName * @param string $assocName
* @throws InvalidArgumentException
* @return string * @return string
*/ */
public function getAssociationTargetClass($assocName) public function getAssociationTargetClass($assocName)
{ {
if ( ! isset($this->associationMappings[$assocName])) { if ( ! isset($this->associationMappings[$assocName])) {
throw new \InvalidArgumentException("Association name expected, '" . $assocName ."' is not an association."); throw new InvalidArgumentException("Association name expected, '" . $assocName ."' is not an association.");
} }
return $this->associationMappings[$assocName]['targetEntity']; return $this->associationMappings[$assocName]['targetEntity'];
@ -2693,7 +2735,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy
* *
* @param AbstractPlatform $platform * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return array * @return array
*/ */
public function getQuotedIdentifierColumnNames($platform) public function getQuotedIdentifierColumnNames($platform)
@ -2732,7 +2774,7 @@ class ClassMetadataInfo implements ClassMetadata
* @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy
* *
* @param string $field * @param string $field
* @param AbstractPlatform $platform * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return string * @return string
*/ */
public function getQuotedColumnName($field, $platform) public function getQuotedColumnName($field, $platform)
@ -2747,7 +2789,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy
* *
* @param AbstractPlatform $platform * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return string * @return string
*/ */
public function getQuotedTableName($platform) public function getQuotedTableName($platform)
@ -2760,7 +2802,8 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy
* *
* @param AbstractPlatform $platform * @param array $assoc
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return string * @return string
*/ */
public function getQuotedJoinTableName(array $assoc, $platform) public function getQuotedJoinTableName(array $assoc, $platform)

View File

@ -24,7 +24,8 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager,
Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, Doctrine\Common\Persistence\Mapping\Driver\MappingDriver,
Doctrine\Common\Persistence\Mapping\ClassMetadata, Doctrine\Common\Persistence\Mapping\ClassMetadata,
Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\Common\Util\Inflector; Doctrine\Common\Util\Inflector,
Doctrine\ORM\Mapping\MappingException;
/** /**
* The DatabaseDriver reverse engineers the mapping metadata from a database. * The DatabaseDriver reverse engineers the mapping metadata from a database.
@ -115,7 +116,7 @@ class DatabaseDriver implements MappingDriver
$this->tables = $this->manyToManyTables = $this->classToTableNames = array(); $this->tables = $this->manyToManyTables = $this->classToTableNames = array();
foreach ($tables as $tableName => $table) { foreach ($tables as $tableName => $table) {
/* @var $table Table */ /* @var $table \Doctrine\DBAL\Schema\Table */
if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$foreignKeys = $table->getForeignKeys(); $foreignKeys = $table->getForeignKeys();
} else { } else {

View File

@ -44,14 +44,14 @@ class DriverChain implements MappingDriver
/** /**
* The default driver * The default driver
* *
* @var Driver * @var MappingDriver
*/ */
private $defaultDriver; private $defaultDriver;
/** /**
* Get the default driver. * Get the default driver.
* *
* @return Driver * @return MappingDriver
*/ */
public function getDefaultDriver() public function getDefaultDriver()
{ {
@ -94,6 +94,8 @@ class DriverChain implements MappingDriver
* *
* @param string $className * @param string $className
* @param ClassMetadata $metadata * @param ClassMetadata $metadata
* @throws MappingException
* @return
*/ */
public function loadMetadataForClass($className, ClassMetadata $metadata) public function loadMetadataForClass($className, ClassMetadata $metadata)
{ {

View File

@ -550,7 +550,7 @@ class XmlDriver extends FileDriver
/** /**
* Parses (nested) option elements. * Parses (nested) option elements.
* *
* @param $options The XML element. * @param SimpleXMLElement $options the XML element.
* @return array The options array. * @return array The options array.
*/ */
private function _parseOptions(SimpleXMLElement $options) private function _parseOptions(SimpleXMLElement $options)
@ -580,7 +580,7 @@ class XmlDriver extends FileDriver
* Constructs a joinColumn mapping array based on the information * Constructs a joinColumn mapping array based on the information
* found in the given SimpleXMLElement. * found in the given SimpleXMLElement.
* *
* @param $joinColumnElement The XML element. * @param SimpleXMLElement $joinColumnElement the XML element.
* @return array The mapping array. * @return array The mapping array.
*/ */
private function joinColumnToArray(SimpleXMLElement $joinColumnElement) private function joinColumnToArray(SimpleXMLElement $joinColumnElement)
@ -650,7 +650,7 @@ class XmlDriver extends FileDriver
} }
if (isset($fieldMapping['version']) && $fieldMapping['version']) { if (isset($fieldMapping['version']) && $fieldMapping['version']) {
$metadata->setVersionMapping($mapping); $mapping['version'] = $fieldMapping['version'];
} }
if (isset($fieldMapping['column-definition'])) { if (isset($fieldMapping['column-definition'])) {
@ -667,7 +667,7 @@ class XmlDriver extends FileDriver
/** /**
* Gathers a list of cascade options found in the given cascade element. * Gathers a list of cascade options found in the given cascade element.
* *
* @param $cascadeElement The cascade element. * @param SimpleXMLElement $cascadeElement the cascade element.
* @return array The list of cascade options. * @return array The list of cascade options.
*/ */
private function _getCascadeMappings($cascadeElement) private function _getCascadeMappings($cascadeElement)

View File

@ -571,7 +571,7 @@ class YamlDriver extends FileDriver
* Constructs a joinColumn mapping array based on the information * Constructs a joinColumn mapping array based on the information
* found in the given join column element. * found in the given join column element.
* *
* @param $joinColumnElement The array join column element * @param array $joinColumnElement The array join column element
* @return array The mapping array. * @return array The mapping array.
*/ */
private function joinColumnToArray($joinColumnElement) private function joinColumnToArray($joinColumnElement)
@ -660,7 +660,7 @@ class YamlDriver extends FileDriver
} }
if (isset($column['version']) && $column['version']) { if (isset($column['version']) && $column['version']) {
$metadata->setVersionMapping($mapping); $mapping['version'] = $column['version'];
} }
if (isset($column['columnDefinition'])) { if (isset($column['columnDefinition'])) {