From a07c63dde68d38037d2ae04f67978b76c7086218 Mon Sep 17 00:00:00 2001 From: "Fabio B. Silva" Date: Mon, 12 Nov 2012 14:18:11 -0200 Subject: [PATCH] added support for @Enum --- .../ORM/Mapping/ChangeTrackingPolicy.php | 8 +++- lib/Doctrine/ORM/Mapping/GeneratedValue.php | 6 ++- lib/Doctrine/ORM/Mapping/InheritanceType.php | 6 ++- lib/Doctrine/ORM/Mapping/ManyToMany.php | 38 +++++++++++++++---- lib/Doctrine/ORM/Mapping/ManyToOne.php | 23 ++++++++--- lib/Doctrine/ORM/Mapping/OneToMany.php | 31 ++++++++++++--- lib/Doctrine/ORM/Mapping/OneToOne.php | 33 ++++++++++++---- lib/vendor/doctrine-common | 2 +- .../ORM/Mapping/AnnotationDriverTest.php | 4 +- 9 files changed, 118 insertions(+), 33 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php index bab34a6b5..566207d78 100644 --- a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php +++ b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php @@ -25,6 +25,10 @@ namespace Doctrine\ORM\Mapping; */ final class ChangeTrackingPolicy implements Annotation { - /** @var string */ + /** + * @var string The change tracking policy. + * + * @Enum({"DEFERRED_IMPLICIT", "DEFERRED_EXPLICIT", "NOTIFY"}) + */ public $value; -} +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/GeneratedValue.php b/lib/Doctrine/ORM/Mapping/GeneratedValue.php index d128d1628..1dee4e0c8 100644 --- a/lib/Doctrine/ORM/Mapping/GeneratedValue.php +++ b/lib/Doctrine/ORM/Mapping/GeneratedValue.php @@ -25,6 +25,10 @@ namespace Doctrine\ORM\Mapping; */ final class GeneratedValue implements Annotation { - /** @var string */ + /** + * @var string The type of Id generator. + * + * @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "UUID", "CUSTOM"}) + */ public $strategy = 'AUTO'; } diff --git a/lib/Doctrine/ORM/Mapping/InheritanceType.php b/lib/Doctrine/ORM/Mapping/InheritanceType.php index d9a247186..28d383ab4 100644 --- a/lib/Doctrine/ORM/Mapping/InheritanceType.php +++ b/lib/Doctrine/ORM/Mapping/InheritanceType.php @@ -25,6 +25,10 @@ namespace Doctrine\ORM\Mapping; */ final class InheritanceType implements Annotation { - /** @var string */ + /** + * @var string The inheritance type used by the class and it's subclasses. + * + * @Enum({"NONE", "JOINED", "SINGLE_TABLE", "TABLE_PER_CLASS"}) + */ public $value; } diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/lib/Doctrine/ORM/Mapping/ManyToMany.php index 9c7968927..3a476a7b3 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -25,18 +25,40 @@ namespace Doctrine\ORM\Mapping; */ final class ManyToMany implements Annotation { - /** @var string */ + /** + * @var string + */ public $targetEntity; - /** @var string */ + + /** + * @var string + */ public $mappedBy; - /** @var string */ + + /** + * @var string + */ public $inversedBy; - /** @var array */ + + /** + * @var array + */ public $cascade; - /** @var string */ + + /** + * @var string The fetching strategy to use for the association. + * + * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) + */ public $fetch = 'LAZY'; - /** @var boolean */ + + /** + * @var boolean + */ public $orphanRemoval = false; - /** @var string */ + + /** + * @var string + */ public $indexBy; -} +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/ManyToOne.php b/lib/Doctrine/ORM/Mapping/ManyToOne.php index eb0975575..9ff3e86ef 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToOne.php +++ b/lib/Doctrine/ORM/Mapping/ManyToOne.php @@ -25,12 +25,25 @@ namespace Doctrine\ORM\Mapping; */ final class ManyToOne implements Annotation { - /** @var string */ + /** + * @var string + */ public $targetEntity; - /** @var array */ + + /** + * @var array + */ public $cascade; - /** @var string */ + + /** + * @var string The fetching strategy to use for the association. + * + * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) + */ public $fetch = 'LAZY'; - /** @var string */ + + /** + * @var string + */ public $inversedBy; -} +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/OneToMany.php b/lib/Doctrine/ORM/Mapping/OneToMany.php index 233dc90f8..63096a0e6 100644 --- a/lib/Doctrine/ORM/Mapping/OneToMany.php +++ b/lib/Doctrine/ORM/Mapping/OneToMany.php @@ -25,16 +25,35 @@ namespace Doctrine\ORM\Mapping; */ final class OneToMany implements Annotation { - /** @var string */ + /** + * @var string + */ public $mappedBy; - /** @var string */ + + /** + * @var string + */ public $targetEntity; - /** @var array */ + + /** + * @var array + */ public $cascade; - /** @var string */ + + /** + * @var string The fetching strategy to use for the association. + * + * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) + */ public $fetch = 'LAZY'; - /** @var boolean */ + + /** + * @var boolean + */ public $orphanRemoval = false; - /** @var string */ + + /** + * @var string + */ public $indexBy; } diff --git a/lib/Doctrine/ORM/Mapping/OneToOne.php b/lib/Doctrine/ORM/Mapping/OneToOne.php index 68689eff3..340b4ff39 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOne.php +++ b/lib/Doctrine/ORM/Mapping/OneToOne.php @@ -25,16 +25,35 @@ namespace Doctrine\ORM\Mapping; */ final class OneToOne implements Annotation { - /** @var string */ + /** + * @var string + */ public $targetEntity; - /** @var string */ + + /** + * @var string + */ public $mappedBy; - /** @var string */ + + /** + * @var string + */ public $inversedBy; - /** @var array */ + + /** + * @var array + */ public $cascade; - /** @var string */ + + /** + * @var string The fetching strategy to use for the association. + * + * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) + */ public $fetch = 'LAZY'; - /** @var boolean */ + + /** + * @var boolean + */ public $orphanRemoval = false; -} +} \ No newline at end of file diff --git a/lib/vendor/doctrine-common b/lib/vendor/doctrine-common index 0f7ba7fa7..cab6ec62f 160000 --- a/lib/vendor/doctrine-common +++ b/lib/vendor/doctrine-common @@ -1 +1 @@ -Subproject commit 0f7ba7fa7179bf445779f63fe5ccad355c81c06b +Subproject commit cab6ec62f72c9af5d444c2b4fffe3ebcacac2479 diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index 96933ac9d..5c4438d08 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -211,8 +211,8 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); $factory->setEntityManager($em); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "Entity 'Doctrine\Tests\ORM\Mapping\InvalidFetchOption' has a mapping with invalid fetch mode 'eager"); + $this->setExpectedException('Doctrine\Common\Annotations\AnnotationException', + '[Enum Error] Attribute "fetch" of @Doctrine\ORM\Mapping\OneToMany declared on property Doctrine\Tests\ORM\Mapping\InvalidFetchOption::$collection accept only [LAZY, EAGER, EXTRA_LAZY], but got eager.'); $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\InvalidFetchOption'); }