Skip to content

Commit

Permalink
Patch Attribute classes to support AnnotationDriver even with Doctrin…
Browse files Browse the repository at this point in the history
…e ORM 3 for unit tests
  • Loading branch information
ondrejmirtes committed Feb 9, 2024
1 parent bf19933 commit 0999cba
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ jobs:
include:
- php-version: "8.3"
dependencies: "highest"
update-packages: "composer require --dev doctrine/orm:^3.0 doctrine/dbal:^4.0 carbonphp/carbon-doctrine-types:^3 -W"
update-packages: |
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"]'
composer require --dev doctrine/orm:^3.0 doctrine/dbal:^4.0 carbonphp/carbon-doctrine-types:^3 -W
steps:
- name: "Checkout"
Expand Down
14 changes: 14 additions & 0 deletions compatibility/patches/Column.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- src/Mapping/Column.php 2024-02-03 17:50:09
+++ src/Mapping/Column.php 2024-02-08 14:19:31
@@ -7,6 +7,11 @@
use Attribute;
use BackedEnum;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor
+ * @Target({"PROPERTY","ANNOTATION"})
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class Column implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/DiscriminatorColumn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/DiscriminatorColumn.php 2024-02-03 17:50:09
+++ src/Mapping/DiscriminatorColumn.php 2024-02-08 14:25:37
@@ -6,7 +6,13 @@

use Attribute;
use BackedEnum;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("CLASS")
+ */
#[Attribute(Attribute::TARGET_CLASS)]
final class DiscriminatorColumn implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/DiscriminatorMap.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/DiscriminatorMap.php 2024-02-03 17:50:09
+++ src/Mapping/DiscriminatorMap.php 2024-02-08 14:26:01
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("CLASS")
+ */
#[Attribute(Attribute::TARGET_CLASS)]
final class DiscriminatorMap implements MappingAttribute
{
13 changes: 13 additions & 0 deletions compatibility/patches/Embeddable.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- src/Mapping/Embeddable.php 2024-02-03 17:50:09
+++ src/Mapping/Embeddable.php 2024-02-08 14:23:25
@@ -6,6 +6,10 @@

use Attribute;

+/**
+ * @Annotation
+ * @Target("CLASS")
+ */
#[Attribute(Attribute::TARGET_CLASS)]
final class Embeddable implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/Embedded.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/Embedded.php 2024-02-03 17:50:09
+++ src/Mapping/Embedded.php 2024-02-08 14:26:23
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class Embedded implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/Entity.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/Entity.php 2024-02-08 09:55:51
+++ src/Mapping/Entity.php 2024-02-08 09:55:54
@@ -7,7 +7,12 @@
use Attribute;
use Doctrine\ORM\EntityRepository;

-/** @template T of object */
+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("CLASS")
+ * @template T of object
+ */
#[Attribute(Attribute::TARGET_CLASS)]
final class Entity implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/GeneratedValue.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/GeneratedValue.php 2024-02-03 17:50:09
+++ src/Mapping/GeneratedValue.php 2024-02-08 14:20:21
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class GeneratedValue implements MappingAttribute
{
13 changes: 13 additions & 0 deletions compatibility/patches/Id.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- src/Mapping/Id.php 2024-02-08 14:18:20
+++ src/Mapping/Id.php 2024-02-08 14:18:23
@@ -6,6 +6,10 @@

use Attribute;

+/**
+ * @Annotation
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class Id implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/InheritanceType.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/InheritanceType.php 2024-02-03 17:50:09
+++ src/Mapping/InheritanceType.php 2024-02-08 14:25:10
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("CLASS")
+ */
#[Attribute(Attribute::TARGET_CLASS)]
final class InheritanceType implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/JoinColumn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/JoinColumn.php 2024-02-03 17:50:09
+++ src/Mapping/JoinColumn.php 2024-02-08 14:22:27
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target({"PROPERTY","ANNOTATION"})
+ */
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
final class JoinColumn implements MappingAttribute
{
13 changes: 13 additions & 0 deletions compatibility/patches/JoinColumns.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- src/Mapping/JoinColumns.php 2024-02-03 17:50:09
+++ src/Mapping/JoinColumns.php 2024-02-08 14:26:44
@@ -4,6 +4,10 @@

namespace Doctrine\ORM\Mapping;

+/**
+ * @Annotation
+ * @Target("PROPERTY")
+ */
final class JoinColumns implements MappingAttribute
{
/** @param array<JoinColumn> $value */
16 changes: 16 additions & 0 deletions compatibility/patches/ManyToMany.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/ManyToMany.php 2024-02-03 17:50:09
+++ src/Mapping/ManyToMany.php 2024-02-08 14:22:04
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class ManyToMany implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/ManyToOne.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/ManyToOne.php 2024-02-03 17:50:09
+++ src/Mapping/ManyToOne.php 2024-02-08 14:20:37
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class ManyToOne implements MappingAttribute
{
17 changes: 17 additions & 0 deletions compatibility/patches/MappedSuperclass.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- src/Mapping/MappedSuperclass.php 2024-02-03 17:50:09
+++ src/Mapping/MappedSuperclass.php 2024-02-08 14:23:56
@@ -5,8 +5,14 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Doctrine\ORM\EntityRepository;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("CLASS")
+ */
#[Attribute(Attribute::TARGET_CLASS)]
final class MappedSuperclass implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/OneToMany.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/OneToMany.php 2024-02-03 17:50:09
+++ src/Mapping/OneToMany.php 2024-02-08 14:21:43
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class OneToMany implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/OneToOne.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/OneToOne.php 2024-02-03 17:50:09
+++ src/Mapping/OneToOne.php 2024-02-08 14:23:03
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class OneToOne implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/OrderBy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/OrderBy.php 2024-02-03 17:50:09
+++ src/Mapping/OrderBy.php 2024-02-08 18:01:12
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class OrderBy implements MappingAttribute
{
16 changes: 16 additions & 0 deletions compatibility/patches/UniqueConstraint.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- src/Mapping/UniqueConstraint.php 2024-02-03 17:50:09
+++ src/Mapping/UniqueConstraint.php 2024-02-08 14:24:37
@@ -5,7 +5,13 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
+use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

+/**
+ * @Annotation
+ * @NamedArgumentConstructor()
+ * @Target("ANNOTATION")
+ */
#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]
final class UniqueConstraint implements MappingAttribute
{
13 changes: 13 additions & 0 deletions compatibility/patches/Version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- src/Mapping/Version.php 2024-02-03 17:50:09
+++ src/Mapping/Version.php 2024-02-08 14:24:16
@@ -6,6 +6,10 @@

use Attribute;

+/**
+ * @Annotation
+ * @Target("PROPERTY")
+ */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class Version implements MappingAttribute
{

0 comments on commit 0999cba

Please sign in to comment.