From 96007c77022ee81be93bc67b200d541ecefc81b5 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Fri, 1 Mar 2024 12:53:24 -0700 Subject: [PATCH 1/6] Composer resolves to highest versions (except phpunit) --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 5c873cd0..83dbc1c8 100644 --- a/composer.json +++ b/composer.json @@ -51,11 +51,11 @@ "require": { "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", "ext-json": "*", - "doctrine/dbal": "^2.13.7 || ^3.3.2", + "doctrine/dbal": "^2.13.7 || ^3.3.2 || ~4.0.0", "doctrine/doctrine-laminas-hydrator": "^3.0.0", "doctrine/doctrine-module": "^5.3.0 || ^6.0.2", - "doctrine/event-manager": "^1.1.1", - "doctrine/orm": "^2.11.1", + "doctrine/event-manager": "^1.1.1 || ^2.0.0", + "doctrine/orm": "^3.0.0", "doctrine/persistence": "^2.3.0 || ^3.0.0", "laminas/laminas-eventmanager": "^3.4.0", "laminas/laminas-modulemanager": "^2.11.0", @@ -63,12 +63,12 @@ "laminas/laminas-paginator": "^2.12.2", "laminas/laminas-servicemanager": "^3.17.0", "laminas/laminas-stdlib": "^3.7.1", - "psr/container": "^1.1.2", - "symfony/console": "^5.4.3 || ^6.0.3" + "psr/container": "^1.1.2 || ^2.0.0", + "symfony/console": "^5.4.3 || ^6.0.3 || ^7.0.0" }, "require-dev": { - "doctrine/annotations": "^1.13.2", - "doctrine/coding-standard": "^9.0.0", + "doctrine/annotations": "^2.0", + "doctrine/coding-standard": "^12.0.0", "doctrine/data-fixtures": "^1.5.2", "doctrine/migrations": "^3.4.1", "laminas/laminas-cache-storage-adapter-filesystem": "^2.0", @@ -80,7 +80,7 @@ "ocramius/proxy-manager": "^2.2.0", "phpstan/phpstan": "^1.4.6", "phpstan/phpstan-phpunit": "^1.0.0", - "phpunit/phpunit": "^9.5.13", + "phpunit/phpunit": "^10.0.0", "squizlabs/php_codesniffer": "^3.6.2", "vimeo/psalm": "^5.4.0" }, From c93638301b06adb7917753123a0d308e9b626908 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Sat, 2 Mar 2024 15:38:15 -0700 Subject: [PATCH 2/6] Refactored entities through FormEntity --- tests/Assets/Entity/{Test.php => Auth.php} | 32 +++--- tests/Assets/Entity/Category.php | 22 ++-- tests/Assets/Entity/City.php | 27 ++--- tests/Assets/Entity/Country.php | 22 ++-- tests/Assets/Entity/Date.php | 22 ++-- .../Assets/Entity/EntityWithoutRepository.php | 16 +-- tests/Assets/Entity/FormEntity.php | 108 ++++++++---------- tests/Assets/Entity/FormEntityTarget.php | 4 +- tests/Assets/Entity/Product.php | 10 +- tests/Assets/Entity/ResolveTarget.php | 4 +- tests/Assets/Entity/TargetEntity.php | 4 +- 11 files changed, 112 insertions(+), 159 deletions(-) rename tests/Assets/Entity/{Test.php => Auth.php} (56%) diff --git a/tests/Assets/Entity/Test.php b/tests/Assets/Entity/Auth.php similarity index 56% rename from tests/Assets/Entity/Test.php rename to tests/Assets/Entity/Auth.php index 93a2274c..731fe078 100644 --- a/tests/Assets/Entity/Test.php +++ b/tests/Assets/Entity/Auth.php @@ -6,26 +6,22 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="doctrine_orm_module_test") - */ -class Test +#[ORM\Entity] +#[ORM\Table(name: 'doctrine_orm_module_auth')] +class Auth { - /** - * @ORM\Id - * @ORM\Column(type="integer"); - * @ORM\GeneratedValue(strategy="AUTO") - */ - protected int $id; + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] + private int $id; - /** @ORM\Column(type="string", nullable=true) */ - protected string $username; + #[ORM\Column(type: 'string', nullable: true)] + private string $username; - /** @ORM\Column(type="string", nullable=true) */ - protected string $password; + #[ORM\Column(type: 'string', nullable: true)] + private string $password; - public function getId(): ?int + public function getId(): int|null { return $this->id; } @@ -35,7 +31,7 @@ public function setPassword(string $password): void $this->password = (string) $password; } - public function getPassword(): ?string + public function getPassword(): string|null { return $this->password; } @@ -45,7 +41,7 @@ public function setUsername(string $username): void $this->username = (string) $username; } - public function getUsername(): ?string + public function getUsername(): string|null { return $this->username; } diff --git a/tests/Assets/Entity/Category.php b/tests/Assets/Entity/Category.php index 1a16f573..652675b4 100644 --- a/tests/Assets/Entity/Category.php +++ b/tests/Assets/Entity/Category.php @@ -6,23 +6,19 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="doctrine_orm_module_category") - */ +#[ORM\Entity] +#[ORM\Table(name: 'doctrine_orm_module_category')] class Category { - /** - * @ORM\Id - * @ORM\Column(type="integer"); - * @ORM\GeneratedValue(strategy="AUTO") - */ - protected int $id; + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] + private int $id; - /** @ORM\Column(type="string", nullable=true) */ - protected string $name; + #[ORM\Column(type: 'string', nullable: true)] + private string $name; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/City.php b/tests/Assets/Entity/City.php index 7dc8684f..9129e36f 100644 --- a/tests/Assets/Entity/City.php +++ b/tests/Assets/Entity/City.php @@ -6,26 +6,23 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="doctrine_orm_module_city") - */ +#[ORM\Entity] +#[ORM\Table(name: 'doctrine_orm_module_city')] class City { - /** - * @ORM\Id - * @ORM\Column(type="integer"); - * @ORM\GeneratedValue(strategy="AUTO") - */ - protected int $id; + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] + private int $id; - /** @ORM\Column(type="string", nullable=true) */ - protected string $name; + #[ORM\Column(type: 'string', nullable: true)] + private string $name; - /** @ORM\OneToOne(targetEntity="Country") */ - protected Country $country; + #[ORM\OneToOne(targetEntity: Country::class)] + #[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id')] + private Country $country; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/Country.php b/tests/Assets/Entity/Country.php index 882ad81b..fdf2f1b4 100644 --- a/tests/Assets/Entity/Country.php +++ b/tests/Assets/Entity/Country.php @@ -6,23 +6,19 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="doctrine_orm_module_country") - */ +#[ORM\Entity] +#[ORM\Table(name: 'doctrine_orm_module_country')] class Country { - /** - * @ORM\Id - * @ORM\Column(type="integer"); - * @ORM\GeneratedValue(strategy="AUTO") - */ - protected int $id; + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] + private int $id; - /** @ORM\Column(type="string", nullable=true) */ - protected string $name; + #[ORM\Column(type: 'string', nullable: true)] + private string $name; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/Date.php b/tests/Assets/Entity/Date.php index b7a09a3f..27730cd2 100644 --- a/tests/Assets/Entity/Date.php +++ b/tests/Assets/Entity/Date.php @@ -7,23 +7,19 @@ use DateTime; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="doctrine_orm_module_date") - */ +#[ORM\Entity] +#[ORM\Table(name: 'doctrine_orm_module_date')] class Date { - /** - * @ORM\Id - * @ORM\Column(type="integer"); - * @ORM\GeneratedValue(strategy="AUTO") - */ - protected int $id; + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] + private int $id; - /** @ORM\Column(type="date", nullable=true) */ - protected DateTime $date; + #[ORM\Column(type: 'date', nullable: true)] + private DateTime $date; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/EntityWithoutRepository.php b/tests/Assets/Entity/EntityWithoutRepository.php index 2a902425..f4ffa0f8 100644 --- a/tests/Assets/Entity/EntityWithoutRepository.php +++ b/tests/Assets/Entity/EntityWithoutRepository.php @@ -6,19 +6,15 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +#[ORM\Entity] class EntityWithoutRepository { - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ - private ?int $id = null; + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] + private int|null $id = null; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/FormEntity.php b/tests/Assets/Entity/FormEntity.php index 0e082771..073a1711 100644 --- a/tests/Assets/Entity/FormEntity.php +++ b/tests/Assets/Entity/FormEntity.php @@ -9,119 +9,105 @@ use Doctrine\ORM\Mapping as ORM; use Laminas\Form\Annotation as Form; -/** - * @ORM\Entity - * @ORM\Table(name="doctrine_orm_module_form_entity") - */ +#[ORM\Entity] +#[ORM\Table(name: 'doctrine_orm_module_form_entity')] class FormEntity { - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] protected int $id; - /** @ORM\Column(type="boolean") */ + #[ORM\Column(type: 'boolean', nullable: false)] protected bool $bool; - /** @ORM\Column(type="boolean") */ + #[ORM\Column(type: 'boolean', nullable: false)] protected bool $boolean; - /** @ORM\Column(type="float") */ + #[ORM\Column(type: 'float', nullable: false)] protected float $float; - /** @ORM\Column(type="bigint") */ - protected int $bigint; + #[ORM\Column(type: 'bigint', nullable: false)] + protected string $bigint; - /** @ORM\Column(type="integer") */ + #[ORM\Column(type: 'integer', nullable: false)] protected int $integer; - /** @ORM\Column(type="smallint") */ + #[ORM\Column(type: 'smallint', nullable: false)] protected int $smallint; - /** @ORM\Column(type="datetime") */ + #[ORM\Column(type: 'datetime', nullable: false)] protected DateTime $datetime; - /** @ORM\Column(type="datetime_immutable") */ - protected DateTime $datetimeImmutable; + #[ORM\Column(type: 'datetime_immutable', nullable: false)] + protected DateTimeImmutable $datetimeImmutable; - /** @ORM\Column(type="datetimetz") */ - protected DateTimeImmutable $datetimetz; + #[ORM\Column(type: 'datetimetz', nullable: false)] + protected DateTime $datetimetz; - /** @ORM\Column(type="datetimetz_immutable") */ + #[ORM\Column(type: 'datetimetz_immutable', nullable: false)] protected DateTimeImmutable $datetimetzImmutable; - /** @ORM\Column(type="date") */ + #[ORM\Column(type: 'date', nullable: false)] protected DateTime $date; - /** @ORM\Column(type="time") */ + #[ORM\Column(type: 'time', nullable: false)] protected DateTime $time; - /** @ORM\Column(type="text") */ + #[ORM\Column(type: 'text', nullable: false)] protected string $text; - /** @ORM\Column(type="string", nullable=false, length=20) */ + #[ORM\Column(type: 'string', length: 20, nullable: false)] protected string $string; - /** @ORM\Column(type="string", nullable=true) */ - protected ?string $stringNullable = null; + #[ORM\Column(type: 'string', nullable: true)] + protected string|null $stringNullable = null; - /** @ORM\OneToOne(targetEntity="Target") */ + #[ORM\OneToOne(targetEntity: Target::class)] protected Target $targetOne; - /** - * @ORM\OneToOne(targetEntity="Target") - * @ORM\JoinColumn(nullable=true) - */ - protected ?Target $targetOneNullable = null; - - /** - * @ORM\OneToOne(targetEntity="Target") - * @ORM\JoinColumn(nullable=true) - * - * @Form\Type("DoctrineModule\Form\Element\ObjectSelect") - * @Form\Options({"empty_option":null}) - */ - protected ?Target $noDisplayEmptyOption = null; + #[ORM\OneToOne(targetEntity: Target::class)] + #[ORM\JoinColumn(nullable: true)] + protected Target|null $targetOneNullable = null; /** - * @ORM\OneToMany(targetEntity="FormEntityTarget", mappedBy="formEntity") - * - * @var Target[] + * @Form\Type("File") + * @Form\Options({"label":"Image"}) */ - protected array $targetMany; + #[ORM\Column(type: 'string', length: 256, nullable: true)] + #[ORM\JoinColumn(nullable: true)] + protected string $image; /** - * @ORM\Column(type="integer") - * * @Form\Options({"label":"Please Choose", "value_options":{"f":"false","t":"true"}}) * @Form\Type("Radio") */ + #[ORM\Column(type: 'integer')] protected int $specificType; /** - * @ORM\OneToMany(targetEntity="FormEntityTarget", mappedBy="formEntityMulti") - * * @Form\Type("DoctrineORMModule\Form\Element\EntityMultiCheckbox") * * @var FormEntityTarget[] */ + #[ORM\OneToMany(targetEntity: FormEntityTarget::class, mappedBy: 'formEntityMulti')] protected array $specificMultiType; /** - * @ORM\Column(type="integer") - * - * @Form\Options({"label":"Please Choose", "value_options":{"f":"false","t":"true"}}) - * @Form\Attributes({"type":"textarea"}) + * @Form\Type("DoctrineModule\Form\Element\ObjectSelect") + * @Form\Options({"empty_option":null}) */ - protected int $specificAttributeType; + #[ORM\OneToOne(targetEntity: Target::class)] + #[ORM\JoinColumn(nullable: true)] + protected Target|null $noDisplayEmptyOption = null; + + /** @var Target[] */ + #[ORM\OneToMany(targetEntity: FormEntityTarget::class, mappedBy: 'formEntity')] + protected array $targetMany; /** - * @ORM\Column(type="string", length=256) - * @ORM\JoinColumn(nullable=true) - * - * @Form\Type("File") - * @Form\Options({"label":"Image"}) + * @Form\Options({"label":"Please Choose", "value_options":{"f":"false","t":"true"}}) + * @Form\Attributes({"type":"textarea"}) */ - protected string $image; + #[ORM\Column(type: 'integer')] + protected int $specificAttributeType; } diff --git a/tests/Assets/Entity/FormEntityTarget.php b/tests/Assets/Entity/FormEntityTarget.php index 08676bf7..d5dc8d55 100644 --- a/tests/Assets/Entity/FormEntityTarget.php +++ b/tests/Assets/Entity/FormEntityTarget.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +/** @ORM\Entity */ class FormEntityTarget { /** diff --git a/tests/Assets/Entity/Product.php b/tests/Assets/Entity/Product.php index a8cdba17..a1481c92 100644 --- a/tests/Assets/Entity/Product.php +++ b/tests/Assets/Entity/Product.php @@ -29,7 +29,7 @@ class Product */ protected array $categories; - public function getId(): ?int + public function getId(): int|null { return $this->id; } @@ -46,9 +46,7 @@ public function getName(): string return $this->name; } - /** - * @param Category[] $categories - */ + /** @param Category[] $categories */ public function setCategories(array $categories): self { $this->categories = $categories; @@ -56,9 +54,7 @@ public function setCategories(array $categories): self return $this; } - /** - * @return Category[] - */ + /** @return Category[] */ public function getCategories(): array { return $this->categories; diff --git a/tests/Assets/Entity/ResolveTarget.php b/tests/Assets/Entity/ResolveTarget.php index 1c2a43f6..a74901f1 100644 --- a/tests/Assets/Entity/ResolveTarget.php +++ b/tests/Assets/Entity/ResolveTarget.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +/** @ORM\Entity */ class ResolveTarget { /** diff --git a/tests/Assets/Entity/TargetEntity.php b/tests/Assets/Entity/TargetEntity.php index d252c78a..1412fd9b 100644 --- a/tests/Assets/Entity/TargetEntity.php +++ b/tests/Assets/Entity/TargetEntity.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +/** @ORM\Entity */ class TargetEntity implements Target { /** From 4ff145407743e7733162d0af32d38154affe3f5f Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Sat, 2 Mar 2024 15:52:18 -0700 Subject: [PATCH 3/6] Finished refactoring entities --- tests/Assets/Entity/FormEntityTarget.php | 10 ++++------ tests/Assets/Entity/Issue237.php | 14 +++++-------- tests/Assets/Entity/Product.php | 25 +++++++++--------------- tests/Assets/Entity/ResolveTarget.php | 13 ++++++------ tests/Assets/Entity/TargetEntity.php | 10 ++++------ 5 files changed, 28 insertions(+), 44 deletions(-) diff --git a/tests/Assets/Entity/FormEntityTarget.php b/tests/Assets/Entity/FormEntityTarget.php index d5dc8d55..f25eb9b5 100644 --- a/tests/Assets/Entity/FormEntityTarget.php +++ b/tests/Assets/Entity/FormEntityTarget.php @@ -6,13 +6,11 @@ use Doctrine\ORM\Mapping as ORM; -/** @ORM\Entity */ +#[ORM\Entity] class FormEntityTarget { - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] protected int $id; } diff --git a/tests/Assets/Entity/Issue237.php b/tests/Assets/Entity/Issue237.php index 4e8008df..b2fc7e69 100644 --- a/tests/Assets/Entity/Issue237.php +++ b/tests/Assets/Entity/Issue237.php @@ -6,16 +6,12 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="doctrine_orm_module_form_entity_issue237") - */ +#[ORM\Entity] +#[ORM\Table(name: 'doctrine_orm_module_form_entity_issue237')] class Issue237 { - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="IDENTITY") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'IDENTITY')] protected int $id; } diff --git a/tests/Assets/Entity/Product.php b/tests/Assets/Entity/Product.php index a1481c92..b96b3bf1 100644 --- a/tests/Assets/Entity/Product.php +++ b/tests/Assets/Entity/Product.php @@ -6,28 +6,21 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="doctrine_orm_module_product") - */ +#[ORM\Entity] +#[ORM\Table(name: 'doctrine_orm_module_product')] class Product { - /** - * @ORM\Id - * @ORM\Column(type="integer"); - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] protected int $id; - /** @ORM\Column(type="string", nullable=true) */ + #[ORM\Column(type: 'string', nullable: true)] protected string $name; - /** - * @ORM\ManyToMany(targetEntity="Category") - * - * @var Category[] - */ - protected array $categories; + /** @var Category[] */ + #[ORM\ManyToMany(targetEntity: Category::class)] + private array $categories; public function getId(): int|null { diff --git a/tests/Assets/Entity/ResolveTarget.php b/tests/Assets/Entity/ResolveTarget.php index a74901f1..c28c74ef 100644 --- a/tests/Assets/Entity/ResolveTarget.php +++ b/tests/Assets/Entity/ResolveTarget.php @@ -6,16 +6,15 @@ use Doctrine\ORM\Mapping as ORM; -/** @ORM\Entity */ +#[ORM\Entity] class ResolveTarget { - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] protected int $id; - /** @ORM\OneToOne(targetEntity="Target") */ + #[ORM\ManyToOne(targetEntity: Target::class)] + #[ORM\JoinColumn(name: 'target_id', referencedColumnName: 'id')] protected Target $target; } diff --git a/tests/Assets/Entity/TargetEntity.php b/tests/Assets/Entity/TargetEntity.php index 1412fd9b..e2c41a51 100644 --- a/tests/Assets/Entity/TargetEntity.php +++ b/tests/Assets/Entity/TargetEntity.php @@ -6,14 +6,12 @@ use Doctrine\ORM\Mapping as ORM; -/** @ORM\Entity */ +#[ORM\Entity] class TargetEntity implements Target { - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue(strategy: 'AUTO')] private int $id; public function getId(): int From 86f026f3a3c2f6fd3a2e2faa126c084cde8bf31e Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Sat, 2 Mar 2024 16:00:23 -0700 Subject: [PATCH 4/6] Corrected scope on entities --- tests/Assets/Entity/Category.php | 4 ++-- tests/Assets/Entity/City.php | 6 +++--- tests/Assets/Entity/Country.php | 4 ++-- tests/Assets/Entity/Date.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Assets/Entity/Category.php b/tests/Assets/Entity/Category.php index 652675b4..9fa4e52d 100644 --- a/tests/Assets/Entity/Category.php +++ b/tests/Assets/Entity/Category.php @@ -13,10 +13,10 @@ class Category #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] - private int $id; + protected int $id; #[ORM\Column(type: 'string', nullable: true)] - private string $name; + protected string $name; public function getId(): int|null { diff --git a/tests/Assets/Entity/City.php b/tests/Assets/Entity/City.php index 9129e36f..48342705 100644 --- a/tests/Assets/Entity/City.php +++ b/tests/Assets/Entity/City.php @@ -13,14 +13,14 @@ class City #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] - private int $id; + protected int $id; #[ORM\Column(type: 'string', nullable: true)] - private string $name; + protected string $name; #[ORM\OneToOne(targetEntity: Country::class)] #[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id')] - private Country $country; + protected Country $country; public function getId(): int|null { diff --git a/tests/Assets/Entity/Country.php b/tests/Assets/Entity/Country.php index fdf2f1b4..ed3e9be7 100644 --- a/tests/Assets/Entity/Country.php +++ b/tests/Assets/Entity/Country.php @@ -13,10 +13,10 @@ class Country #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] - private int $id; + protected int $id; #[ORM\Column(type: 'string', nullable: true)] - private string $name; + protected string $name; public function getId(): int|null { diff --git a/tests/Assets/Entity/Date.php b/tests/Assets/Entity/Date.php index 27730cd2..b53a1378 100644 --- a/tests/Assets/Entity/Date.php +++ b/tests/Assets/Entity/Date.php @@ -14,10 +14,10 @@ class Date #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] - private int $id; + protected int $id; #[ORM\Column(type: 'date', nullable: true)] - private DateTime $date; + protected DateTime $date; public function getId(): int|null { From c94e4c0e03e746492c2207cb255f0a3e2e77be05 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Sat, 2 Mar 2024 16:32:52 -0700 Subject: [PATCH 5/6] Pass 1 of review Entities --- tests/Assets/Entity/Auth.php | 12 +- tests/Assets/Entity/Category.php | 9 + tests/Assets/Entity/City.php | 4 +- tests/Assets/Entity/Country.php | 3 + tests/Assets/Entity/Date.php | 4 +- tests/Assets/Entity/Entity.skipper | 263 ++++++++++++++++++ .../Assets/Entity/EntityWithoutRepository.php | 4 +- tests/Assets/Entity/Product.php | 17 +- tests/Assets/Entity/TargetEntity.php | 4 +- 9 files changed, 307 insertions(+), 13 deletions(-) create mode 100644 tests/Assets/Entity/Entity.skipper diff --git a/tests/Assets/Entity/Auth.php b/tests/Assets/Entity/Auth.php index 731fe078..62b09e7d 100644 --- a/tests/Assets/Entity/Auth.php +++ b/tests/Assets/Entity/Auth.php @@ -26,9 +26,11 @@ public function getId(): int|null return $this->id; } - public function setPassword(string $password): void + public function setPassword(string $password): self { - $this->password = (string) $password; + $this->password = $password; + + return $this; } public function getPassword(): string|null @@ -36,9 +38,11 @@ public function getPassword(): string|null return $this->password; } - public function setUsername(string $username): void + public function setUsername(string $username): self { - $this->username = (string) $username; + $this->username = $username; + + return $this; } public function getUsername(): string|null diff --git a/tests/Assets/Entity/Category.php b/tests/Assets/Entity/Category.php index 9fa4e52d..49eb1045 100644 --- a/tests/Assets/Entity/Category.php +++ b/tests/Assets/Entity/Category.php @@ -4,6 +4,7 @@ namespace DoctrineORMModuleTest\Assets\Entity; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity] @@ -18,6 +19,14 @@ class Category #[ORM\Column(type: 'string', nullable: true)] protected string $name; + #[ORM\ManyToMany(targetEntity: Product::class, mappedBy: 'categories')] + private ArrayCollection $products; + + public function __construct() + { + $this->products = new ArrayCollection(); + } + public function getId(): int|null { return $this->id; diff --git a/tests/Assets/Entity/City.php b/tests/Assets/Entity/City.php index 48342705..1fb8682b 100644 --- a/tests/Assets/Entity/City.php +++ b/tests/Assets/Entity/City.php @@ -18,8 +18,8 @@ class City #[ORM\Column(type: 'string', nullable: true)] protected string $name; - #[ORM\OneToOne(targetEntity: Country::class)] - #[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id')] + #[ORM\OneToOne(targetEntity: Country::class, inversedBy: 'city')] + #[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id', unique: true)] protected Country $country; public function getId(): int|null diff --git a/tests/Assets/Entity/Country.php b/tests/Assets/Entity/Country.php index ed3e9be7..45d35b20 100644 --- a/tests/Assets/Entity/Country.php +++ b/tests/Assets/Entity/Country.php @@ -18,6 +18,9 @@ class Country #[ORM\Column(type: 'string', nullable: true)] protected string $name; + #[ORM\OneToOne(targetEntity: City::class, mappedBy: 'country')] + private City $city; + public function getId(): int|null { return $this->id; diff --git a/tests/Assets/Entity/Date.php b/tests/Assets/Entity/Date.php index b53a1378..e0b99f85 100644 --- a/tests/Assets/Entity/Date.php +++ b/tests/Assets/Entity/Date.php @@ -24,9 +24,11 @@ public function getId(): int|null return $this->id; } - public function setDate(DateTime $date): void + public function setDate(DateTime $date): self { $this->date = $date; + + return $this; } public function getDate(): DateTime diff --git a/tests/Assets/Entity/Entity.skipper b/tests/Assets/Entity/Entity.skipper new file mode 100644 index 00000000..f8568fd9 --- /dev/null +++ b/tests/Assets/Entity/Entity.skipper @@ -0,0 +1,263 @@ + + + + + + + + + + + AUTO + + + + + + + doctrine_orm_module_auth + Auth.php + + + + + + + AUTO + + + + + + doctrine_orm_module_date + Date.php + + + + + + + AUTO + + + + + EntityWithoutRepository.php + + + + + + + + + + + + + + + + + + + + + + + + + + + doctrine_orm_module_form_entity + FormEntity.php + + + + + + + + + + + + + + + + + + + + + + + + + + + + AUTO + + + + + FormEntityTarget.php + + + + + + + IDENTITY + + + + + doctrine_orm_module_form_entity_issue237 + Issue237.php + + + + + + + AUTO + + + + + + ResolveTarget.php + + + + + + + + + + + + + + AUTO + + + + + TargetEntity.php + + + + + + + + AUTO + + + + + + + doctrine_orm_module_city + City.php + + + + + + + AUTO + + + + + + doctrine_orm_module_country + Country.php + + + + + + + + + + + + + + + + + + + + + AUTO + + + + + + doctrine_orm_module_category + Category.php + + + + + + + AUTO + + + + + + doctrine_orm_module_product + Product.php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Assets/Entity/EntityWithoutRepository.php b/tests/Assets/Entity/EntityWithoutRepository.php index f4ffa0f8..a378230d 100644 --- a/tests/Assets/Entity/EntityWithoutRepository.php +++ b/tests/Assets/Entity/EntityWithoutRepository.php @@ -19,8 +19,10 @@ public function getId(): int|null return $this->id; } - public function setId(int $id): void + public function setId(int $id): self { $this->id = $id; + + return $this; } } diff --git a/tests/Assets/Entity/Product.php b/tests/Assets/Entity/Product.php index b96b3bf1..1a17ac60 100644 --- a/tests/Assets/Entity/Product.php +++ b/tests/Assets/Entity/Product.php @@ -4,6 +4,7 @@ namespace DoctrineORMModuleTest\Assets\Entity; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity] @@ -19,8 +20,16 @@ class Product protected string $name; /** @var Category[] */ - #[ORM\ManyToMany(targetEntity: Category::class)] - private array $categories; + #[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'products')] + #[ORM\JoinTable(name: 'ProductCategory')] + #[ORM\JoinColumn(name: 'Product_id', referencedColumnName: 'id')] + #[ORM\InverseJoinColumn(name: 'Category_id', referencedColumnName: 'id')] + private ArrayCollection $categories; + + public function __construct() + { + $this->categories = new ArrayCollection(); + } public function getId(): int|null { @@ -40,7 +49,7 @@ public function getName(): string } /** @param Category[] $categories */ - public function setCategories(array $categories): self + public function setCategories(ArrayCollection $categories): self { $this->categories = $categories; @@ -48,7 +57,7 @@ public function setCategories(array $categories): self } /** @return Category[] */ - public function getCategories(): array + public function getCategories(): ArrayCollection { return $this->categories; } diff --git a/tests/Assets/Entity/TargetEntity.php b/tests/Assets/Entity/TargetEntity.php index e2c41a51..0cdc8c1f 100644 --- a/tests/Assets/Entity/TargetEntity.php +++ b/tests/Assets/Entity/TargetEntity.php @@ -19,8 +19,10 @@ public function getId(): int return $this->id; } - public function setId(int $id): void + public function setId(int $id): self { $this->id = $id; + + return $this; } } From 68485077722fefa1de65c4006b9274d43a7648c5 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Sat, 2 Mar 2024 17:08:27 -0700 Subject: [PATCH 6/6] Pass 2 of review Entities --- tests/Assets/Entity/Entity.skipper | 232 ++++++++++++++------------ tests/Assets/Entity/FormEntity.php | 30 ++-- tests/Assets/Entity/ResolveTarget.php | 2 +- 3 files changed, 142 insertions(+), 122 deletions(-) diff --git a/tests/Assets/Entity/Entity.skipper b/tests/Assets/Entity/Entity.skipper index f8568fd9..7e07d9cd 100644 --- a/tests/Assets/Entity/Entity.skipper +++ b/tests/Assets/Entity/Entity.skipper @@ -1,9 +1,6 @@ - - - @@ -45,67 +42,6 @@ EntityWithoutRepository.php - - - - - - - - - - - - - - - - - - - - - - - - - doctrine_orm_module_form_entity - FormEntity.php - - - - - - - - - - - - - - - - - - - - - - - - - - - - AUTO - - - - - FormEntityTarget.php - - @@ -119,38 +55,7 @@ Issue237.php - - - - - AUTO - - - - - - ResolveTarget.php - - - - - - - - - - - - - - AUTO - - - - - TargetEntity.php - - + @@ -232,32 +137,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + doctrine_orm_module_form_entity + FormEntity.php + + + + + + + AUTO + + + + + FormEntityTarget.php + + + + + + + AUTO + + + + + + ResolveTarget.php + + + + + + + AUTO + + + + + TargetEntity.php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - + - - - + + + - + - + - - - + + + - - - - + + + + + + diff --git a/tests/Assets/Entity/FormEntity.php b/tests/Assets/Entity/FormEntity.php index 073a1711..209cde0d 100644 --- a/tests/Assets/Entity/FormEntity.php +++ b/tests/Assets/Entity/FormEntity.php @@ -62,9 +62,15 @@ class FormEntity #[ORM\Column(type: 'string', nullable: true)] protected string|null $stringNullable = null; + /** + * This join is odd because the targetEntity exists only as an interface + **/ #[ORM\OneToOne(targetEntity: Target::class)] protected Target $targetOne; + /** + * This join is odd because the targetEntity exists only as an interface + */ #[ORM\OneToOne(targetEntity: Target::class)] #[ORM\JoinColumn(nullable: true)] protected Target|null $targetOneNullable = null; @@ -84,6 +90,13 @@ class FormEntity #[ORM\Column(type: 'integer')] protected int $specificType; + /** + * @Form\Options({"label":"Please Choose", "value_options":{"f":"false","t":"true"}}) + * @Form\Attributes({"type":"textarea"}) + */ + #[ORM\Column(type: 'integer')] + protected int $specificAttributeType; + /** * @Form\Type("DoctrineORMModule\Form\Element\EntityMultiCheckbox") * @@ -92,22 +105,17 @@ class FormEntity #[ORM\OneToMany(targetEntity: FormEntityTarget::class, mappedBy: 'formEntityMulti')] protected array $specificMultiType; + /** @var Target[] */ + #[ORM\OneToMany(targetEntity: FormEntityTarget::class, mappedBy: 'formEntity')] + protected array $targetMany; + /** + * This join is odd because the targetEntity exists only as an interface + * * @Form\Type("DoctrineModule\Form\Element\ObjectSelect") * @Form\Options({"empty_option":null}) */ #[ORM\OneToOne(targetEntity: Target::class)] #[ORM\JoinColumn(nullable: true)] protected Target|null $noDisplayEmptyOption = null; - - /** @var Target[] */ - #[ORM\OneToMany(targetEntity: FormEntityTarget::class, mappedBy: 'formEntity')] - protected array $targetMany; - - /** - * @Form\Options({"label":"Please Choose", "value_options":{"f":"false","t":"true"}}) - * @Form\Attributes({"type":"textarea"}) - */ - #[ORM\Column(type: 'integer')] - protected int $specificAttributeType; } diff --git a/tests/Assets/Entity/ResolveTarget.php b/tests/Assets/Entity/ResolveTarget.php index c28c74ef..11012445 100644 --- a/tests/Assets/Entity/ResolveTarget.php +++ b/tests/Assets/Entity/ResolveTarget.php @@ -15,6 +15,6 @@ class ResolveTarget protected int $id; #[ORM\ManyToOne(targetEntity: Target::class)] - #[ORM\JoinColumn(name: 'target_id', referencedColumnName: 'id')] + #[ORM\JoinColumn(name: 'target_id', referencedColumnName: 'id', unique: true)] protected Target $target; }