From f810c775adf0f7046ea34d43e79f24f7fb8c4a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Jusi=C4=99ga?= Date: Mon, 18 Nov 2019 18:45:28 +0100 Subject: [PATCH 1/2] Add missing imports --- lib/Doctrine/ORM/Mapping/AssociationOverride.php | 2 ++ lib/Doctrine/ORM/Mapping/Cache.php | 2 ++ lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php | 2 ++ lib/Doctrine/ORM/Mapping/GeneratedValue.php | 2 ++ lib/Doctrine/ORM/Mapping/InheritanceType.php | 2 ++ lib/Doctrine/ORM/Mapping/ManyToMany.php | 2 ++ lib/Doctrine/ORM/Mapping/ManyToOne.php | 2 ++ lib/Doctrine/ORM/Mapping/OneToMany.php | 2 ++ lib/Doctrine/ORM/Mapping/OneToOne.php | 2 ++ 9 files changed, 18 insertions(+) diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverride.php b/lib/Doctrine/ORM/Mapping/AssociationOverride.php index e208b16228a..1c5b993612e 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationOverride.php +++ b/lib/Doctrine/ORM/Mapping/AssociationOverride.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * This annotation is used to override association mapping of property for an entity relationship. * diff --git a/lib/Doctrine/ORM/Mapping/Cache.php b/lib/Doctrine/ORM/Mapping/Cache.php index 3226b603160..155b75609a8 100644 --- a/lib/Doctrine/ORM/Mapping/Cache.php +++ b/lib/Doctrine/ORM/Mapping/Cache.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * Caching to an entity or a collection. * diff --git a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php index 3657b764f1e..916202d3faf 100644 --- a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php +++ b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * @Annotation * @Target("CLASS") diff --git a/lib/Doctrine/ORM/Mapping/GeneratedValue.php b/lib/Doctrine/ORM/Mapping/GeneratedValue.php index 27c03d4bee7..8b23356bede 100644 --- a/lib/Doctrine/ORM/Mapping/GeneratedValue.php +++ b/lib/Doctrine/ORM/Mapping/GeneratedValue.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * @Annotation * @Target("PROPERTY") diff --git a/lib/Doctrine/ORM/Mapping/InheritanceType.php b/lib/Doctrine/ORM/Mapping/InheritanceType.php index de803369a30..66021e8ddfd 100644 --- a/lib/Doctrine/ORM/Mapping/InheritanceType.php +++ b/lib/Doctrine/ORM/Mapping/InheritanceType.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * @Annotation * @Target("CLASS") diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/lib/Doctrine/ORM/Mapping/ManyToMany.php index ca2f53c9eea..c9c3c60891d 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * @Annotation * @Target("PROPERTY") diff --git a/lib/Doctrine/ORM/Mapping/ManyToOne.php b/lib/Doctrine/ORM/Mapping/ManyToOne.php index d3414e6a956..c429090d7f2 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToOne.php +++ b/lib/Doctrine/ORM/Mapping/ManyToOne.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * @Annotation * @Target("PROPERTY") diff --git a/lib/Doctrine/ORM/Mapping/OneToMany.php b/lib/Doctrine/ORM/Mapping/OneToMany.php index 4b2465718e1..fecac2b8307 100644 --- a/lib/Doctrine/ORM/Mapping/OneToMany.php +++ b/lib/Doctrine/ORM/Mapping/OneToMany.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * @Annotation * @Target("PROPERTY") diff --git a/lib/Doctrine/ORM/Mapping/OneToOne.php b/lib/Doctrine/ORM/Mapping/OneToOne.php index b2ab81f88d9..1455632c86a 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOne.php +++ b/lib/Doctrine/ORM/Mapping/OneToOne.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Annotations\Annotation\Enum; + /** * @Annotation * @Target("PROPERTY") From 93d6e628ffac38d3e9d6691419da2fd3bca0cf0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Jusi=C4=99ga?= Date: Mon, 18 Nov 2019 20:57:14 +0100 Subject: [PATCH 2/2] Add test (but generated other error) --- .../ORM/Mapping/ImportsAnnotationsTest.php | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Mapping/ImportsAnnotationsTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ImportsAnnotationsTest.php b/tests/Doctrine/Tests/ORM/Mapping/ImportsAnnotationsTest.php new file mode 100644 index 00000000000..22f3f7b4462 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/ImportsAnnotationsTest.php @@ -0,0 +1,77 @@ +annotationReader = $this->createAnnotationDriver()->getReader(); + + // ... but if use a default annotation reader is there a problem. + $this->annotationReader = new AnnotationReader(); + } + + /** + * If exception was thrown so is there a error during parsing something with class. + * + * @dataProvider dataProviderReflectionClass + * + * @param ReflectionClass $reflectionClass + * + * @return void + */ + public function testClassShouldValidImportedAnnotations($reflectionClass) + { + $this->assertIsArray($this->annotationReader->getClassAnnotations($reflectionClass)); + + foreach ($reflectionClass->getMethods() as $reflectionMethod) { + $this->assertIsArray($this->annotationReader->getMethodAnnotations($reflectionMethod)); + } + + foreach ($reflectionClass->getProperties() as $reflectionProperty) { + $this->assertIsArray($this->annotationReader->getPropertyAnnotations($reflectionProperty)); + } + } + + /** + * @throws \ReflectionException + * @return ReflectionClass[] + */ + public function dataProviderReflectionClass() + { + return [ + [new ReflectionClass(AssociationOverride::class)], + [new ReflectionClass(Cache::class)], + [new ReflectionClass(ChangeTrackingPolicy::class)], + [new ReflectionClass(GeneratedValue::class)], + [new ReflectionClass(InheritanceType::class)], + [new ReflectionClass(ManyToMany::class)], + [new ReflectionClass(ManyToOne::class)], + [new ReflectionClass(OneToMany::class)], + [new ReflectionClass(OneToOne::class)], + ]; + } +}