From 353ba4dfd1045333bf46023a9947fcaa171f2ef0 Mon Sep 17 00:00:00 2001 From: Vitali Yakavenka Date: Wed, 30 Nov 2011 00:20:00 +0300 Subject: [PATCH] Remove trailing whitespaces and fix brace locations --- doctrine-mapping.xsd | 2 +- .../ORM/Mapping/ClassMetadataInfo.php | 11 +-- .../ORM/Mapping/CustomIdGenerator.php | 3 +- .../ORM/Mapping/Driver/YamlDriver.php | 10 +-- .../ORM/Mapping/AbstractMappingDriverTest.php | 6 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 72 +++++++++++-------- 6 files changed, 58 insertions(+), 46 deletions(-) diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index 5fb261e13..b04e8a87c 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -273,7 +273,7 @@ - + diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 99ce88968..5e13d3dfc 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -181,7 +181,7 @@ class ClassMetadataInfo implements ClassMetadata public $rootEntityName; /** - * READ-ONLY: The definition of custom generator. Only used for CUSTOM + * READ-ONLY: The definition of custom generator. Only used for CUSTOM * generator type * * The definition has the following structure: @@ -1828,12 +1828,13 @@ class ClassMetadataInfo implements ClassMetadata { $this->idGenerator = $generator; } - + /** - * Sets definition - * @param array $definition + * Sets definition + * @param array $definition */ - public function setCustomGeneratorDefinition(array $definition) { + public function setCustomGeneratorDefinition(array $definition) + { $this->customGeneratorDefinition = $definition; } diff --git a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php b/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php index 62d31a20c..a4a5d8e35 100644 --- a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php +++ b/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php @@ -23,7 +23,8 @@ namespace Doctrine\ORM\Mapping; * @Annotation * @Target("PROPERTY") */ -final class CustomIdGenerator implements Annotation { +final class CustomIdGenerator implements Annotation +{ /** @var string */ public $class; /** @var array */ diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php index 8f61920c1..76881cab7 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -192,11 +192,11 @@ class YamlDriver extends AbstractFileDriver if (isset($idElement['sequenceGenerator'])) { $metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']); } else if (isset($idElement['customIdGenerator'])) { - $customGenerator = $idElement['customIdGenerator']; - $metadata->setCustomGeneratorDefinition(array( - 'class' => (string) $customGenerator['class'], - 'args' => $customGenerator['args'] - )); + $customGenerator = $idElement['customIdGenerator']; + $metadata->setCustomGeneratorDefinition(array( + 'class' => (string) $customGenerator['class'], + 'args' => $customGenerator['args'] + )); } else if (isset($idElement['tableGenerator'])) { throw MappingException::tableIdGeneratorNotImplemented($className); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 1b5191039..e80bca23a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -88,12 +88,12 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase $class->sequenceGeneratorDefinition ); } - + public function testEntityCustomGenerator() { $class = $this->createClassMetadata('Doctrine\Tests\ORM\Mapping\Animal'); - - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, + + $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $class->generatorType, "Generator Type"); $this->assertEquals( array("class" => "stdClass", "args" => array("par1", "par2")), diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 2b21a5b59..a05e7380f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -48,23 +48,25 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals(ClassMetadata::GENERATOR_TYPE_SEQUENCE, $cm1->generatorType); } - public function testGetMetadataFor_ReturnsLoadedCustomIdGenerator() { + public function testGetMetadataFor_ReturnsLoadedCustomIdGenerator() + { $cm1 = $this->_createValidClassMetadata(); $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cm1->customGeneratorDefinition = array( "class" => "Doctrine\Tests\ORM\Mapping\CustomIdGenerator"); $cmf = $this->_createTestFactory(); $cmf->setMetadataForClass($cm1->name, $cm1); - + $actual = $cmf->getMetadataFor($cm1->name); - - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, + + $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $actual->generatorType); $this->assertInstanceOf("Doctrine\Tests\ORM\Mapping\CustomIdGenerator", $actual->idGenerator); } - - public function testGetMetadataFor_PasesArgumentsToGeneratorsConstructor() { + + public function testGetMetadataFor_PasesArgumentsToGeneratorsConstructor() + { $cm1 = $this->_createValidClassMetadata(); $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cm1->customGeneratorDefinition = array( @@ -73,39 +75,41 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase $cmf = $this->_createTestFactory(); $cmf->setMetadataForClass($cm1->name, $cm1); $expected = new CustomIdGenerator("parameter"); - + $actual = $cmf->getMetadataFor($cm1->name); - - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, + + $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $actual->generatorType); $this->assertEquals($expected, $actual->idGenerator); } - - public function testGetMetadataFor_ThrowsExceptionOnUnknownCustomGeneratorClass() { + + public function testGetMetadataFor_ThrowsExceptionOnUnknownCustomGeneratorClass() + { $cm1 = $this->_createValidClassMetadata(); $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cm1->customGeneratorDefinition = array("class" => "NotExistingGenerator"); $cmf = $this->_createTestFactory(); $cmf->setMetadataForClass($cm1->name, $cm1); $this->setExpectedException("Doctrine\ORM\ORMException"); - + $actual = $cmf->getMetadataFor($cm1->name); } - - public function testGetMetadataFor_ThrowsExceptionOnMissingCustomGeneratorDefinition() { + + public function testGetMetadataFor_ThrowsExceptionOnMissingCustomGeneratorDefinition() + { $cm1 = $this->_createValidClassMetadata(); $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cmf = $this->_createTestFactory(); $cmf->setMetadataForClass($cm1->name, $cm1); $this->setExpectedException("Doctrine\ORM\ORMException"); - + $actual = $cmf->getMetadataFor($cm1->name); } public function testHasGetMetadata_NamespaceSeperatorIsNotNormalized() { require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; - + $metadataDriver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/Global/')); $entityManager = $this->_createEntityManager($metadataDriver); @@ -120,7 +124,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase $this->assertFalse($h2); $this->assertTrue($h1); } - + /** * @group DDC-1512 */ @@ -136,13 +140,13 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase ->method('isTransient') ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) ->will($this->returnValue(false)); - + $em = $this->_createEntityManager($driver); - + $this->assertTrue($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsUser')); $this->assertFalse($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsArticle')); } - + /** * @group DDC-1512 */ @@ -158,10 +162,10 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase ->method('isTransient') ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) ->will($this->returnValue(false)); - + $em = $this->_createEntityManager($driver); $em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - + $this->assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); $this->assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); } @@ -179,23 +183,25 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase return EntityManagerMock::create($conn, $config, $eventManager); } - + /** - * @return ClassMetadataFactoryTestSubject + * @return ClassMetadataFactoryTestSubject */ - protected function _createTestFactory() { + protected function _createTestFactory() + { $mockDriver = new MetadataDriverMock(); $entityManager = $this->_createEntityManager($mockDriver); $cmf = new ClassMetadataFactoryTestSubject(); $cmf->setEntityManager($entityManager); return $cmf; } - + /** * @param string $class - * @return ClassMetadata + * @return ClassMetadata */ - protected function _createValidClassMetadata() { + protected function _createValidClassMetadata() + { $cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1'); $cm1->setPrimaryTable(array('name' => '`group`')); // Add a mapped field @@ -250,10 +256,14 @@ class TestEntity1 private $association; } -class CustomIdGenerator extends \Doctrine\ORM\Id\AbstractIdGenerator { +class CustomIdGenerator extends \Doctrine\ORM\Id\AbstractIdGenerator +{ public $parameter; - public function __construct($parameter = null) { + public function __construct($parameter = null) + { $this->parameter = $parameter; } - public function generate(\Doctrine\ORM\EntityManager $em, $entity) {} + public function generate(\Doctrine\ORM\EntityManager $em, $entity) + { + } }