Commit 1013eb66 authored by romanb's avatar romanb

[2.0] Fixed PHP Notice in SchemaTest (only variables should be passed by...

[2.0] Fixed PHP Notice in SchemaTest (only variables should be passed by reference...) and a few other cosmetics in various parts.
parent 329d0952
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
namespace Doctrine\ORM\Internal\Hydration; namespace Doctrine\ORM\Internal\Hydration;
use Doctrine\DBAL\Connection, use Doctrine\DBAL\Connection,
Doctrine\DBAL\Types\Type, Doctrine\DBAL\Types\Type;
Doctrine\Common\DoctrineException;
/** /**
* Base class for all hydrators. A hydrator is a class that provides some form * Base class for all hydrators. A hydrator is a class that provides some form
...@@ -38,7 +37,7 @@ use Doctrine\DBAL\Connection, ...@@ -38,7 +37,7 @@ use Doctrine\DBAL\Connection,
*/ */
abstract class AbstractHydrator abstract class AbstractHydrator
{ {
/** The ResultSetMapping. */ /** @var ResultSetMapping The ResultSetMapping. */
protected $_rsm; protected $_rsm;
/** @var EntityManager The EntityManager instance. */ /** @var EntityManager The EntityManager instance. */
...@@ -152,7 +151,7 @@ abstract class AbstractHydrator ...@@ -152,7 +151,7 @@ abstract class AbstractHydrator
*/ */
protected function _hydrateRow(array &$data, array &$cache, array &$result) protected function _hydrateRow(array &$data, array &$cache, array &$result)
{ {
throw new DoctrineException("_hydrateRow() not implemented by this hydrator."); throw new HydrationException("_hydrateRow() not implemented by this hydrator.");
} }
/** /**
...@@ -301,7 +300,7 @@ abstract class AbstractHydrator ...@@ -301,7 +300,7 @@ abstract class AbstractHydrator
* during hydration because the hydrator caches effectively. * during hydration because the hydrator caches effectively.
* *
* @return string The field name. * @return string The field name.
* @throws DoctrineException If the field name could not be found. * @throws HydrationException If the field name could not be found.
* @todo Remove. See inline FIXME comment. * @todo Remove. See inline FIXME comment.
*/ */
private function _lookupDeclaringClass($class, $fieldName) private function _lookupDeclaringClass($class, $fieldName)
...@@ -317,6 +316,6 @@ abstract class AbstractHydrator ...@@ -317,6 +316,6 @@ abstract class AbstractHydrator
} }
} }
throw DoctrineException::noOwnerFoundForField($class, $fieldName); throw new HydrationException("No owner found for field $fieldName.");
} }
} }
...@@ -81,8 +81,7 @@ class ArrayHydrator extends AbstractHydrator ...@@ -81,8 +81,7 @@ class ArrayHydrator extends AbstractHydrator
unset($rowData['scalars']); unset($rowData['scalars']);
} }
// 3) Now hydrate the rest of the data found in the current row, that // 2) Now hydrate the data found in the current row.
// belongs to other (related) entities.
foreach ($rowData as $dqlAlias => $data) { foreach ($rowData as $dqlAlias => $data) {
$index = false; $index = false;
......
...@@ -137,7 +137,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -137,7 +137,7 @@ class ObjectHydrator extends AbstractHydrator
$value = new ArrayCollection; $value = new ArrayCollection;
} }
if ($value instanceof ArrayCollection) { if ( ! $value instanceof PersistentCollection) {
$value = new PersistentCollection( $value = new PersistentCollection(
$this->_em, $this->_em,
$this->_ce[$relation->targetEntityName], $this->_ce[$relation->targetEntityName],
......
...@@ -42,10 +42,4 @@ class SingleScalarHydrator extends AbstractHydrator ...@@ -42,10 +42,4 @@ class SingleScalarHydrator extends AbstractHydrator
$result = $this->_gatherScalarRowData($result[key($result)], $cache); $result = $this->_gatherScalarRowData($result[key($result)], $cache);
return array_shift($result); return array_shift($result);
} }
/** {@inheritdoc} */
protected function _getRowContainer()
{
return array();
}
} }
\ No newline at end of file
...@@ -120,8 +120,10 @@ abstract class AssociationMapping ...@@ -120,8 +120,10 @@ abstract class AssociationMapping
*/ */
public function __construct(array $mapping) public function __construct(array $mapping)
{ {
if ($mapping) {
$this->_validateAndCompleteMapping($mapping); $this->_validateAndCompleteMapping($mapping);
} }
}
/** /**
* Validates & completes the mapping. Mapping defaults are applied here. * Validates & completes the mapping. Mapping defaults are applied here.
......
...@@ -183,8 +183,10 @@ class AnnotationDriver implements Driver ...@@ -183,8 +183,10 @@ class AnnotationDriver implements Driver
$mapping['precision'] = $columnAnnot->precision; $mapping['precision'] = $columnAnnot->precision;
$mapping['scale'] = $columnAnnot->scale; $mapping['scale'] = $columnAnnot->scale;
$mapping['nullable'] = $columnAnnot->nullable; $mapping['nullable'] = $columnAnnot->nullable;
$mapping['options'] = $columnAnnot->options;
$mapping['unique'] = $columnAnnot->unique; $mapping['unique'] = $columnAnnot->unique;
if ($columnAnnot->options) {
$mapping['options'] = $columnAnnot->options;
}
if (isset($columnAnnot->default)) { if (isset($columnAnnot->default)) {
$mapping['default'] = $columnAnnot->default; $mapping['default'] = $columnAnnot->default;
......
...@@ -255,4 +255,33 @@ class OneToOneMapping extends AssociationMapping ...@@ -255,4 +255,33 @@ class OneToOneMapping extends AssociationMapping
return $targetEntity; return $targetEntity;
} }
/**
* @internal Experimental. For MetaModel API, Doctrine 2.1.
*/
public static function __set_state(array $state)
{
$assoc = new self(array());
$assoc->isOptional = $state['isOptional'];
$assoc->joinColumnFieldNames = $state['joinColumnFieldNames'];
$assoc->joinColumns = $state['joinColumns'];
$assoc->orphanRemoval = $state['orphanRemoval'];
$assoc->sourceToTargetKeyColumns = $state['sourceToTargetKeyColumns'];
$assoc->targetToSourceKeyColumns = $state['targetToSourceKeyColumns'];
$assoc->fetchMode = $state['fetchMode'];
$assoc->isCascadeDetach = $state['isCascadeDetach'];
$assoc->isCascadeRefresh = $state['isCascadeRefresh'];
$assoc->isCascadeRemove = $state['isCascadeRemove'];
$assoc->isCascadePersist = $state['isCascadePersist'];
$assoc->isCascadeMerge = $state['isCascadeMerge'];
$assoc->isOwningSide = $state['isOwningSide'];
$assoc->joinTable = $state['joinTable'];
$assoc->mappedByFieldName = $state['mappedByFieldName'];
$assoc->sourceEntityName = $state['sourceEntityName'];
$assoc->targetEntityName = $state['targetEntityName'];
$assoc->sourceFieldName = $state['sourceFieldName'];
return $assoc;
}
} }
...@@ -30,5 +30,10 @@ namespace Doctrine\ORM; ...@@ -30,5 +30,10 @@ namespace Doctrine\ORM;
* @since 2.0 * @since 2.0
* @version $Revision$ * @version $Revision$
*/ */
class OptimisticLockException extends \Doctrine\Common\DoctrineException class OptimisticLockException extends ORMException
{} {
\ No newline at end of file public static function lockFailed()
{
return new self("The optimistic lock failed.");
}
}
\ No newline at end of file
...@@ -256,7 +256,7 @@ class StandardEntityPersister ...@@ -256,7 +256,7 @@ class StandardEntityPersister
$result = $this->_conn->executeUpdate($sql, $params); $result = $this->_conn->executeUpdate($sql, $params);
if ($isVersioned && ! $result) { if ($isVersioned && ! $result) {
throw \Doctrine\ORM\OptimisticLockException::optimisticLockFailed(); throw \Doctrine\ORM\OptimisticLockException::lockFailed();
} }
} }
......
...@@ -1344,7 +1344,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1344,7 +1344,7 @@ class UnitOfWork implements PropertyChangedListener
$entityVersion = $class->reflFields[$class->versionField]->getValue($entity); $entityVersion = $class->reflFields[$class->versionField]->getValue($entity);
// Throw exception if versions dont match. // Throw exception if versions dont match.
if ($managedCopyVersion != $entityVersion) { if ($managedCopyVersion != $entityVersion) {
throw OptimisticLockException::versionMismatch(); throw OptimisticLockException::lockFailed();
} }
} }
......
...@@ -183,7 +183,8 @@ class SchemaTest extends \PHPUnit_Framework_TestCase ...@@ -183,7 +183,8 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
$schema->visit(new \Doctrine\DBAL\Schema\Visitor\FixSchema(true)); $schema->visit(new \Doctrine\DBAL\Schema\Visitor\FixSchema(true));
$this->assertEquals(1, count($tableB->getIndexes())); $this->assertEquals(1, count($tableB->getIndexes()));
$index = current($tableB->getIndexes()); $indexes = $tableB->getIndexes();
$index = current($indexes);
$this->assertTrue($index->hasColumnAtPosition('foo_id', 0)); $this->assertTrue($index->hasColumnAtPosition('foo_id', 0));
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment