Skip to content

Commit 0999cba

Browse files
committed
Patch Attribute classes to support AnnotationDriver even with Doctrine ORM 3 for unit tests
1 parent bf19933 commit 0999cba

20 files changed

+294
-1
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ jobs:
111111
include:
112112
- php-version: "8.3"
113113
dependencies: "highest"
114-
update-packages: "composer require --dev doctrine/orm:^3.0 doctrine/dbal:^4.0 carbonphp/carbon-doctrine-types:^3 -W"
114+
update-packages: |
115+
composer config extra.patches.doctrine/orm --json --merge '["compatibility/patches/Column.patch", "compatibility/patches/DiscriminatorColumn.patch", "compatibility/patches/DiscriminatorMap.patch", "compatibility/patches/Embeddable.patch", "compatibility/patches/Embedded.patch", "compatibility/patches/Entity.patch", "compatibility/patches/GeneratedValue.patch", "compatibility/patches/Id.patch", "compatibility/patches/InheritanceType.patch", "compatibility/patches/JoinColumn.patch", "compatibility/patches/JoinColumns.patch", "compatibility/patches/ManyToMany.patch", "compatibility/patches/ManyToOne.patch", "compatibility/patches/MappedSuperclass.patch", "compatibility/patches/OneToMany.patch", "compatibility/patches/OneToOne.patch", "compatibility/patches/OrderBy.patch", "compatibility/patches/UniqueConstraint.patch", "compatibility/patches/Version.patch"]'
116+
composer require --dev doctrine/orm:^3.0 doctrine/dbal:^4.0 carbonphp/carbon-doctrine-types:^3 -W
115117
116118
steps:
117119
- name: "Checkout"

compatibility/patches/Column.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- src/Mapping/Column.php 2024-02-03 17:50:09
2+
+++ src/Mapping/Column.php 2024-02-08 14:19:31
3+
@@ -7,6 +7,11 @@
4+
use Attribute;
5+
use BackedEnum;
6+
7+
+/**
8+
+ * @Annotation
9+
+ * @NamedArgumentConstructor
10+
+ * @Target({"PROPERTY","ANNOTATION"})
11+
+ */
12+
#[Attribute(Attribute::TARGET_PROPERTY)]
13+
final class Column implements MappingAttribute
14+
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- src/Mapping/DiscriminatorColumn.php 2024-02-03 17:50:09
2+
+++ src/Mapping/DiscriminatorColumn.php 2024-02-08 14:25:37
3+
@@ -6,7 +6,13 @@
4+
5+
use Attribute;
6+
use BackedEnum;
7+
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
8+
9+
+/**
10+
+ * @Annotation
11+
+ * @NamedArgumentConstructor()
12+
+ * @Target("CLASS")
13+
+ */
14+
#[Attribute(Attribute::TARGET_CLASS)]
15+
final class DiscriminatorColumn implements MappingAttribute
16+
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- src/Mapping/DiscriminatorMap.php 2024-02-03 17:50:09
2+
+++ src/Mapping/DiscriminatorMap.php 2024-02-08 14:26:01
3+
@@ -5,7 +5,13 @@
4+
namespace Doctrine\ORM\Mapping;
5+
6+
use Attribute;
7+
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
8+
9+
+/**
10+
+ * @Annotation
11+
+ * @NamedArgumentConstructor()
12+
+ * @Target("CLASS")
13+
+ */
14+
#[Attribute(Attribute::TARGET_CLASS)]
15+
final class DiscriminatorMap implements MappingAttribute
16+
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- src/Mapping/Embeddable.php 2024-02-03 17:50:09
2+
+++ src/Mapping/Embeddable.php 2024-02-08 14:23:25
3+
@@ -6,6 +6,10 @@
4+
5+
use Attribute;
6+
7+
+/**
8+
+ * @Annotation
9+
+ * @Target("CLASS")
10+
+ */
11+
#[Attribute(Attribute::TARGET_CLASS)]
12+
final class Embeddable implements MappingAttribute
13+
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- src/Mapping/Embedded.php 2024-02-03 17:50:09
2+
+++ src/Mapping/Embedded.php 2024-02-08 14:26:23
3+
@@ -5,7 +5,13 @@
4+
namespace Doctrine\ORM\Mapping;
5+
6+
use Attribute;
7+
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
8+
9+
+/**
10+
+ * @Annotation
11+
+ * @NamedArgumentConstructor()
12+
+ * @Target("PROPERTY")
13+
+ */
14+
#[Attribute(Attribute::TARGET_PROPERTY)]
15+
final class Embedded implements MappingAttribute
16+
{

compatibility/patches/Entity.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- src/Mapping/Entity.php 2024-02-08 09:55:51
2+
+++ src/Mapping/Entity.php 2024-02-08 09:55:54
3+
@@ -7,7 +7,12 @@
4+
use Attribute;
5+
use Doctrine\ORM\EntityRepository;
6+
7+
-/** @template T of object */
8+
+/**
9+
+ * @Annotation
10+
+ * @NamedArgumentConstructor()
11+
+ * @Target("CLASS")
12+
+ * @template T of object
13+
+ */
14+
#[Attribute(Attribute::TARGET_CLASS)]
15+
final class Entity implements MappingAttribute
16+
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- src/Mapping/GeneratedValue.php 2024-02-03 17:50:09
2+
+++ src/Mapping/GeneratedValue.php 2024-02-08 14:20:21
3+
@@ -5,7 +5,13 @@
4+
namespace Doctrine\ORM\Mapping;
5+
6+
use Attribute;
7+
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
8+
9+
+/**
10+
+ * @Annotation
11+
+ * @NamedArgumentConstructor()
12+
+ * @Target("PROPERTY")
13+
+ */
14+
#[Attribute(Attribute::TARGET_PROPERTY)]
15+
final class GeneratedValue implements MappingAttribute
16+
{

compatibility/patches/Id.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- src/Mapping/Id.php 2024-02-08 14:18:20
2+
+++ src/Mapping/Id.php 2024-02-08 14:18:23
3+
@@ -6,6 +6,10 @@
4+
5+
use Attribute;
6+
7+
+/**
8+
+ * @Annotation
9+
+ * @Target("PROPERTY")
10+
+ */
11+
#[Attribute(Attribute::TARGET_PROPERTY)]
12+
final class Id implements MappingAttribute
13+
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- src/Mapping/InheritanceType.php 2024-02-03 17:50:09
2+
+++ src/Mapping/InheritanceType.php 2024-02-08 14:25:10
3+
@@ -5,7 +5,13 @@
4+
namespace Doctrine\ORM\Mapping;
5+
6+
use Attribute;
7+
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
8+
9+
+/**
10+
+ * @Annotation
11+
+ * @NamedArgumentConstructor()
12+
+ * @Target("CLASS")
13+
+ */
14+
#[Attribute(Attribute::TARGET_CLASS)]
15+
final class InheritanceType implements MappingAttribute
16+
{

0 commit comments

Comments
 (0)