Skip to content

Commit fd6b34a

Browse files
authored
feature #1219 [make:entity] Add PHPDoc var type for Collections
1 parent 74a8918 commit fd6b34a

File tree

19 files changed

+65
-0
lines changed

19 files changed

+65
-0
lines changed

src/Util/ClassSourceManipulator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ private function addCollectionRelation(BaseCollectionRelation $relation): void
594594
$this->addProperty(
595595
name: $relation->getPropertyName(),
596596
attributes: $attributes,
597+
// add @var that advertises this as a collection of specific objects
598+
comments: [sprintf('@var %s<int, %s>', $collectionTypeHint, $typeHint)],
597599
propertyType: $collectionTypeHint,
598600
);
599601

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/Client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Client extends BaseClient
1717
#[ORM\Column]
1818
private ?string $apiKey = null;
1919

20+
/**
21+
* @var Collection<int, Tag>
22+
*/
2023
#[ORM\ManyToMany(targetEntity: Tag::class)]
2124
private Collection $tags;
2225

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/User.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ class User
1414
#[ORM\Column]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, UserAvatar>
19+
*/
1720
#[ORM\OneToMany(targetEntity: UserAvatar::class, mappedBy: 'user')]
1821
private Collection $avatars;
1922

2023
#[ORM\OneToOne(mappedBy: 'user')]
2124
private ?UserProfile $userProfile = null;
2225

26+
/**
27+
* @var Collection<int, Tag>
28+
*/
2329
#[ORM\ManyToMany(targetEntity: Tag::class)]
2430
private Collection $tags;
2531

tests/Doctrine/fixtures/expected_overwrite/src/Entity/Client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Client extends BaseClient
1717
#[ORM\Column]
1818
private ?string $apiKey = null;
1919

20+
/**
21+
* @var Collection<int, Tag>
22+
*/
2023
#[ORM\ManyToMany(targetEntity: Tag::class)]
2124
private Collection $tags;
2225

tests/Doctrine/fixtures/expected_overwrite/src/Entity/User.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ class User
1414
#[ORM\Column]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, UserAvatar>
19+
*/
1720
#[ORM\OneToMany(targetEntity: UserAvatar::class, mappedBy: 'user')]
1821
private Collection $avatars;
1922

2023
#[ORM\OneToOne(mappedBy: 'user')]
2124
private ?UserProfile $userProfile = null;
2225

26+
/**
27+
* @var Collection<int, Tag>
28+
*/
2329
#[ORM\ManyToMany(targetEntity: Tag::class)]
2430
private Collection $tags;
2531

tests/Doctrine/fixtures/expected_xml/src/Entity/UserXml.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class UserXml
1111

1212
private ?string $name = null;
1313

14+
/**
15+
* @var Collection<int, UserAvatar>
16+
*/
1417
private Collection $avatars;
1518

1619
public function __construct()

tests/Doctrine/fixtures/source_project/src/Entity/Client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class Client extends BaseClient
1616
#[ORM\Column]
1717
private ?string $apiKey = null;
1818

19+
/**
20+
* @var Collection<int, Tag>
21+
*/
1922
#[ORM\ManyToMany(targetEntity: Tag::class)]
2023
private Collection $tags;
2124

tests/Doctrine/fixtures/source_project/src/Entity/User.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ class User
1414
#[ORM\Column]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, UserAvatar>
19+
*/
1720
#[ORM\OneToMany(targetEntity: UserAvatar::class, mappedBy: 'user')]
1821
private Collection $avatars;
1922

2023
#[ORM\OneToOne(mappedBy: 'user')]
2124
private ?UserProfile $userProfile = null;
2225

26+
/**
27+
* @var Collection<int, Tag>
28+
*/
2329
#[ORM\ManyToMany(targetEntity: Tag::class)]
2430
private Collection $tags;
2531

tests/Util/fixtures/add_many_to_many_relation/User_simple_inverse.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class User
1414
#[ORM\Column()]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, Recipe>
19+
*/
1720
#[ORM\ManyToMany(targetEntity: Recipe::class, mappedBy: 'foods')]
1821
private Collection $recipes;
1922

tests/Util/fixtures/add_many_to_many_relation/User_simple_no_inverse.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class User
1414
#[ORM\Column()]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, Recipe>
19+
*/
1720
#[ORM\ManyToMany(targetEntity: Recipe::class)]
1821
private Collection $recipes;
1922

tests/Util/fixtures/add_many_to_many_relation/User_simple_owning.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class User
1414
#[ORM\Column()]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, Recipe>
19+
*/
1720
#[ORM\ManyToMany(targetEntity: Recipe::class, inversedBy: 'foods')]
1821
private Collection $recipes;
1922

tests/Util/fixtures/add_one_to_many_relation/User_simple.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class User
1414
#[ORM\Column()]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, UserAvatarPhoto>
19+
*/
1720
#[ORM\OneToMany(targetEntity: UserAvatarPhoto::class, mappedBy: 'user')]
1821
private Collection $avatarPhotos;
1922

tests/Util/fixtures/add_one_to_many_relation/User_simple_orphan_removal.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class User
1414
#[ORM\Column()]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, UserAvatarPhoto>
19+
*/
1720
#[ORM\OneToMany(targetEntity: UserAvatarPhoto::class, mappedBy: 'user', orphanRemoval: true)]
1821
private Collection $avatarPhotos;
1922

tests/Util/fixtures/add_one_to_many_relation/User_with_use_statements.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class User
1717
#[ORM\Column()]
1818
private ?int $id = null;
1919

20+
/**
21+
* @var Collection<int, UserAvatarPhoto>
22+
*/
2023
#[ORM\OneToMany(targetEntity: UserAvatarPhoto::class, mappedBy: 'user')]
2124
private Collection $avatarPhotos;
2225

tests/Util/fixtures/add_one_to_many_relation/legacy/User_simple.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class User
1414
#[ORM\Column()]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, UserAvatarPhoto>
19+
*/
1720
#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserAvatarPhoto::class)]
1821
private Collection $avatarPhotos;
1922

tests/Util/fixtures/add_one_to_many_relation/legacy/User_simple_orphan_removal.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class User
1414
#[ORM\Column()]
1515
private ?int $id = null;
1616

17+
/**
18+
* @var Collection<int, UserAvatarPhoto>
19+
*/
1720
#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserAvatarPhoto::class, orphanRemoval: true)]
1821
private Collection $avatarPhotos;
1922

tests/Util/fixtures/add_one_to_many_relation/legacy/User_with_use_statements.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class User
1717
#[ORM\Column()]
1818
private ?int $id = null;
1919

20+
/**
21+
* @var Collection<int, UserAvatarPhoto>
22+
*/
2023
#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserAvatarPhoto::class)]
2124
private Collection $avatarPhotos;
2225

tests/fixtures/make-entity/regenerate/attributes/src/Entity/User.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class User
2020
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
2121
private ?\DateTimeInterface $createdAt = null;
2222

23+
/**
24+
* @var Collection<int, UserAvatar>
25+
*/
2326
#[ORM\OneToMany(targetEntity: UserAvatar::class, mappedBy: 'user')]
2427
private Collection $avatars;
2528

tests/fixtures/make-form/SourFood.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class SourFood
1717
#[ORM\Column(name: 'title', length: 255)]
1818
private ?string $title = null;
1919

20+
/**
21+
* @var Collection<int, Property>
22+
*/
2023
#[ORM\OneToMany(targetEntity: Property::class, mappedBy: 'sourFood')]
2124
private Collection $properties;
2225

0 commit comments

Comments
 (0)