From 0bce2472f2c59369b00f3c0afc4e2259efdd89aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 23 Feb 2021 23:28:30 +0100 Subject: [PATCH] Manually fix cs --- .../Models/Company/CompanyFlexContract.php | 17 +++++--- .../Company/CompanyFlexUltraContract.php | 4 +- .../CompanyFlexUltraContractListener.php | 1 + .../Tests/Models/Company/CompanyManager.php | 6 +-- .../Tests/Models/Company/CompanyRaffle.php | 9 +++-- .../CustomType/CustomIdObjectTypeParent.php | 6 ++- .../Models/CustomType/CustomTypeChild.php | 5 ++- .../Models/CustomType/CustomTypeParent.php | 14 ++++++- .../Models/CustomType/CustomTypeUpperCase.php | 10 ++++- .../Models/DDC117/DDC117ApproveChanges.php | 17 +++++--- .../Tests/Models/DDC117/DDC117Editor.php | 7 +++- .../Tests/Models/DDC1590/DDC1590Entity.php | 15 ++----- .../Tests/Models/DDC2372/DDC2372Address.php | 10 +++-- .../Tests/Models/DDC2372/DDC2372User.php | 11 +++--- ...ait.php => DDC2372AddressAndAccessors.php} | 6 +-- .../Tests/Models/DDC3293/DDC3293Address.php | 5 +++ .../Tests/Models/DDC3579/DDC3579Group.php | 22 +++++++---- .../Tests/Models/DDC3579/DDC3579User.php | 5 ++- .../Tests/Models/DDC3597/DDC3597Root.php | 4 +- .../Tests/Models/DDC3899/DDC3899Contract.php | 5 ++- .../Tests/Models/DDC4006/DDC4006User.php | 5 ++- .../Models/DDC5934/DDC5934BaseContract.php | 4 +- .../Tests/Models/DDC6412/DDC6412File.php | 6 ++- .../Tests/Models/DDC869/DDC869Payment.php | 5 ++- .../Tests/Models/DDC964/DDC964Address.php | 37 +++++++++++++----- .../Tests/Models/DDC964/DDC964Group.php | 13 +++++-- .../Tests/Models/DDC964/DDC964User.php | 13 +++++-- .../DirectoryTree/AbstractContentItem.php | 8 ++-- .../Tests/Models/DirectoryTree/Directory.php | 4 +- .../Tests/Models/DirectoryTree/File.php | 4 +- .../Tests/Models/ECommerce/ECommerceCart.php | 28 ++++++++----- .../Models/ECommerce/ECommerceCategory.php | 18 ++++++--- .../Models/ECommerce/ECommerceCustomer.php | 13 ++++--- .../Models/ECommerce/ECommerceFeature.php | 15 ++++--- .../Models/ECommerce/ECommerceProduct.php | 39 +++++++++++++------ .../Models/ECommerce/ECommerceShipping.php | 10 ++++- .../Tests/Models/Forum/ForumCategory.php | 2 +- .../Tests/Models/Forum/ForumEntry.php | 2 +- .../Tests/ORM/Tools/EntityGeneratorTest.php | 4 +- 39 files changed, 273 insertions(+), 136 deletions(-) rename tests/Doctrine/Tests/Models/DDC2372/Traits/{DDC2372AddressTrait.php => DDC2372AddressAndAccessors.php} (79%) diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index 62de14a57f2..321113b4b0e 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Company; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadataInfo; /** @@ -58,12 +59,13 @@ class CompanyFlexContract extends CompanyContract private $hoursWorked = 0; /** - * @column(type="integer") * @var int + * @Column(type="integer") */ private $pricePerHour = 0; /** + * @psalm-var Collection * @ManyToMany(targetEntity="CompanyManager", inversedBy="managedContracts", fetch="EXTRA_LAZY") * @JoinTable(name="company_contract_managers", * joinColumns={@JoinColumn(name="contract_id", referencedColumnName="id", onDelete="CASCADE")}, @@ -77,27 +79,30 @@ public function calculatePrice(): int return $this->hoursWorked * $this->pricePerHour; } - public function getHoursWorked() + public function getHoursWorked(): int { return $this->hoursWorked; } - public function setHoursWorked($hoursWorked): void + public function setHoursWorked(int $hoursWorked): void { $this->hoursWorked = $hoursWorked; } - public function getPricePerHour() + public function getPricePerHour(): int { return $this->pricePerHour; } - public function setPricePerHour($pricePerHour): void + public function setPricePerHour(int $pricePerHour): void { $this->pricePerHour = $pricePerHour; } - public function getManagers() + /** + * @psalm-return Collection + */ + public function getManagers(): Collection { return $this->managers; } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php index 6f95f9fa0be..198aea0ea85 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -26,12 +26,12 @@ public function calculatePrice(): int return max($this->maxPrice, parent::calculatePrice()); } - public function getMaxPrice() + public function getMaxPrice(): int { return $this->maxPrice; } - public function setMaxPrice($maxPrice): void + public function setMaxPrice(int $maxPrice): void { $this->maxPrice = $maxPrice; } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php index dfc997ee829..53410e1d997 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php @@ -10,6 +10,7 @@ class CompanyFlexUltraContractListener { + /** @psalm-var list */ public $prePersistCalls; /** diff --git a/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/tests/Doctrine/Tests/Models/Company/CompanyManager.php index 02ae9781e41..c4a560ec8d4 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyManager.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyManager.php @@ -31,17 +31,17 @@ class CompanyManager extends CompanyEmployee */ public $managedContracts; - public function getTitle() + public function getTitle(): string { return $this->title; } - public function setTitle($title): void + public function setTitle(string $title): void { $this->title = $title; } - public function getCar() + public function getCar(): CompanyCar { return $this->car; } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php index 08194609c4d..e349d0b22dd 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php @@ -7,15 +7,18 @@ /** @Entity @Table(name="company_raffles") */ class CompanyRaffle extends CompanyEvent { - /** @Column */ + /** + * @var string + * @Column + */ private $data; - public function setData($data): void + public function setData(string $data): void { $this->data = $data; } - public function getData() + public function getData(): string { return $this->data; } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php index 6a00b6326a4..7f012f4455c 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\Models\CustomType; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\Tests\DbalTypes\CustomIdObject; /** @@ -19,7 +20,10 @@ class CustomIdObjectTypeParent */ public $id; - /** @OneToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild", cascade={"persist", "remove"}, mappedBy="parent") */ + /** + * @psalm-var Collection + * @OneToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild", cascade={"persist", "remove"}, mappedBy="parent") + */ public $children; public function __construct(CustomIdObject $id) diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php index 1613927e749..3d53af6e0ab 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php @@ -17,6 +17,9 @@ class CustomTypeChild */ public $id; - /** @Column(type="upper_case_string") */ + /** + * @var string + * @Column(type="upper_case_string") + */ public $lowerCaseString = 'foo'; } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php index 07bc3120cb3..bc563e50a01 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php @@ -20,7 +20,10 @@ class CustomTypeParent */ public $id; - /** @Column(type="negative_to_positive", nullable=true) */ + /** + * @var int + * @Column(type="negative_to_positive", nullable=true) + */ public $customInteger; /** @@ -36,6 +39,7 @@ class CustomTypeParent private $friendsWithMe; /** + * @psalm-var Collection * @ManyToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeParent", inversedBy="friendsWithMe") * @JoinTable( * name="customtype_parent_friends", @@ -57,7 +61,10 @@ public function addMyFriend(CustomTypeParent $friend): void $friend->addFriendWithMe($this); } - public function getMyFriends() + /** + * @psalm-return Collection + */ + public function getMyFriends(): Collection { return $this->myFriends; } @@ -67,6 +74,9 @@ public function addFriendWithMe(CustomTypeParent $friend): void $this->getFriendsWithMe()->add($friend); } + /** + * @psalm-return Collection + */ public function getFriendsWithMe() { return $this->friendsWithMe; diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php index bc91077e1d6..d8dc2e9d644 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php @@ -17,9 +17,15 @@ class CustomTypeUpperCase */ public $id; - /** @Column(type="upper_case_string") */ + /** + * @var string + * @Column(type="upper_case_string") + */ public $lowerCaseString; - /** @Column(type="upper_case_string", name="named_lower_case_string", nullable = true) */ + /** + * @var string + * @Column(type="upper_case_string", name="named_lower_case_string", nullable = true) + */ public $namedLowerCaseString; } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php index db344373c10..78d3b7618f1 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php @@ -25,6 +25,7 @@ class DDC117ApproveChanges private $articleDetails; /** + * @var DDC117Reference * @ManyToOne(targetEntity="DDC117Reference") * @JoinColumns({ * @JoinColumn(name="source_id", referencedColumnName="source_id"), @@ -34,6 +35,7 @@ class DDC117ApproveChanges private $reference; /** + * @var DDC117Translation * @ManyToOne(targetEntity="DDC117Translation") * @JoinColumns({ * @JoinColumn(name="trans_article_id", referencedColumnName="article_id"), @@ -42,29 +44,32 @@ class DDC117ApproveChanges */ private $translation; - public function __construct($details, $reference, $translation) - { + public function __construct( + DDC117ArticleDetails $details, + DDC117Reference $reference, + DDC117Translation $translation + ) { $this->articleDetails = $details; $this->reference = $reference; $this->translation = $translation; } - public function getId() + public function getId(): int { return $this->id; } - public function getArticleDetails() + public function getArticleDetails(): DDC117ArticleDetails { return $this->articleDetails; } - public function getReference() + public function getReference(): DDC117Reference { return $this->reference; } - public function getTranslation() + public function getTranslation(): DDC117Translation { return $this->translation; } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php index f7cb81cf192..8c6311ff4d0 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\Models\DDC117; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; /** * @Entity @@ -20,12 +21,13 @@ class DDC117Editor public $id; /** - * @var string + * @var string|null * @Column(type="string") */ public $name; /** + * @psalm-var Collection * @ManyToMany(targetEntity="DDC117Translation", inversedBy="reviewedByEditors") * @JoinTable( * inverseJoinColumns={ @@ -40,6 +42,7 @@ class DDC117Editor public $reviewingTranslations; /** + * @var DDC117Translation * @ManyToOne(targetEntity="DDC117Translation", inversedBy="lastTranslatedBy") * @JoinColumns({ * @JoinColumn(name="lt_article_id", referencedColumnName="article_id"), @@ -48,7 +51,7 @@ class DDC117Editor */ public $lastTranslation; - public function __construct($name = '') + public function __construct(?string $name = '') { $this->name = $name; $this->reviewingTranslations = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php b/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php index a9ef69b254a..764817b356c 100644 --- a/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php +++ b/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php @@ -24,31 +24,22 @@ abstract class DDC1590Entity * @var DateTime * @Column(type="datetime") */ - protected $created_at; + protected $createdAt; - /** - * Get id - */ public function getId(): int { return $this->id; } - /** - * Set createdAt - */ public function setCreatedAt(DateTime $createdAt): DDC1590User { - $this->created_at = $createdAt; + $this->createdAt = $createdAt; return $this; } - /** - * Get createdAt - */ public function getCreatedAt(): DateTime { - return $this->created_at; + return $this->createdAt; } } diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php index 7035171cecf..e473ad5553f 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php @@ -13,33 +13,35 @@ class DDC2372Address * @GeneratedValue(strategy="AUTO") */ private $id; + /** * @var string * @Column(type="string", length=255) */ private $street; + /** * @var User * @OneToOne(targetEntity="User", mappedBy="address") */ private $user; - public function getId() + public function getId(): int { return $this->id; } - public function getStreet() + public function getStreet(): string { return $this->street; } - public function setStreet($street): void + public function setStreet(string $street): void { $this->street = $street; } - public function getUser() + public function getUser(): User { return $this->user; } diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php index 6d2e9b23b60..8e09179a383 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\Models\DDC2372; -use Doctrine\Tests\Models\DDC2372\Traits\DDC2372AddressTrait; +use Doctrine\Tests\Models\DDC2372\Traits\DDC2372AddressAndAccessors; /** @Entity @Table(name="users") */ class DDC2372User { - use DDC2372AddressTrait; + use DDC2372AddressAndAccessors; /** * @var int @@ -17,23 +17,24 @@ class DDC2372User * @GeneratedValue(strategy="AUTO") */ private $id; + /** * @var string * @Column(type="string", length=50) */ private $name; - public function getId() + public function getId(): int { return $this->id; } - public function getName() + public function getName(): string { return $this->name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } diff --git a/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressTrait.php b/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php similarity index 79% rename from tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressTrait.php rename to tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php index 44d7953ca7f..206254824d8 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressTrait.php +++ b/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php @@ -6,7 +6,7 @@ use Doctrine\Tests\Models\DDC2372\DDC2372Address; -trait DDC2372AddressTrait +trait DDC2372AddressAndAccessors { /** * @var DDC2372Address @@ -15,12 +15,12 @@ trait DDC2372AddressTrait */ private $address; - public function getAddress() + public function getAddress(): DDC2372Address { return $this->address; } - public function setAddress(Address $address): void + public function setAddress(DDC2372Address $address): void { if ($this->address !== $address) { $this->address = $address; diff --git a/tests/Doctrine/Tests/Models/DDC3293/DDC3293Address.php b/tests/Doctrine/Tests/Models/DDC3293/DDC3293Address.php index 09e6a7d291e..2c5288b48f5 100644 --- a/tests/Doctrine/Tests/Models/DDC3293/DDC3293Address.php +++ b/tests/Doctrine/Tests/Models/DDC3293/DDC3293Address.php @@ -6,7 +6,12 @@ class DDC3293Address { + /** @var string */ public $street; + + /** @var string */ public $city; + + /** @var string */ public $country; } diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php index f9f92527b80..a8d0f21e125 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\Models\DDC3579; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; /** * @Entity @@ -12,24 +13,28 @@ class DDC3579Group { /** + * @var int * @GeneratedValue * @Id @Column(type="integer") */ private $id; - /** @Column */ + /** + * @var string|null + * @Column + */ private $name; /** - * @ArrayCollection + * @psalm-var Collection * @ManyToMany(targetEntity="DDC3579Admin", mappedBy="groups") */ private $admins; - public function __construct($name = null) + public function __construct(?string $name = null) { - $this->name = $name; - $this->users = new ArrayCollection(); + $this->name = $name; + $this->admins = new ArrayCollection(); } public function setName(string $name): void @@ -37,7 +42,7 @@ public function setName(string $name): void $this->name = $name; } - public function getName(): string + public function getName(): ?string { return $this->name; } @@ -47,7 +52,10 @@ public function addAdmin(DDC3579Admin $admin): void $this->admins[] = $admin; } - public function getAdmins(): ArrayCollection + /** + * @psalm-return Collection + */ + public function getAdmins(): Collection { return $this->admins; } diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php index 68f4e1c4555..fae4bf9d687 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php @@ -20,7 +20,10 @@ class DDC3579User */ protected $id; - /** @Column(name="user_name", nullable=true, unique=false, length=250) */ + /** + * @var string + * @Column(name="user_name", nullable=true, unique=false, length=250) + */ protected $name; /** diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php index 93da278efa6..40bbdf4490a 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php @@ -43,7 +43,7 @@ abstract class DDC3597Root * * @PrePersist */ - public function _prePersist(): void + public function prePersist(): void { $this->updatedAt = $this->createdAt = new DateTime(); } @@ -53,7 +53,7 @@ public function _prePersist(): void * * @PreUpdate */ - public function _preUpdate(): void + public function preUpdate(): void { $this->updatedAt = new DateTime(); } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php index 25389de72eb..6354e50ff8b 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php @@ -23,7 +23,10 @@ abstract class DDC3899Contract */ public $id; - /** @Column(type="boolean") */ + /** + * @var bool + * @Column(type="boolean") + */ public $completed = false; /** diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php index cb77086c2d8..b7610c22de1 100644 --- a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php +++ b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php @@ -9,6 +9,9 @@ */ class DDC4006User { - /** @Embedded(class="DDC4006UserId") */ + /** + * @var DDC4006UserId + * @Embedded(class="DDC4006UserId") + */ private $id; } diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php b/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php index ff94fb959dd..4a1aef97bf7 100644 --- a/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php +++ b/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\Models\DDC5934; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -18,6 +19,7 @@ class DDC5934BaseContract { /** + * @var int * @Id() * @Column(name="id", type="integer") * @GeneratedValue() @@ -25,7 +27,7 @@ class DDC5934BaseContract public $id; /** - * @var ArrayCollection + * @psalm-var Collection * @ManyToMany(targetEntity="DDC5934Member", fetch="LAZY", inversedBy="contracts") */ public $members; diff --git a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php b/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php index 5d97e80a4c4..9943df4f21a 100644 --- a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php +++ b/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php @@ -10,11 +10,15 @@ class DDC6412File { /** + * @var int * @Column(type="integer") * @GeneratedValue */ public $id; - /** @Column(length=50, name="file_name") */ + /** + * @var string + * @Column(length=50, name="file_name") + */ public $name; } diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php index e0cacdd3586..0492f452251 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php @@ -19,7 +19,10 @@ class DDC869Payment */ protected $id; - /** @Column(type="float") */ + /** + * @var float + * @Column(type="float") + */ protected $value; public static function loadMetadata(ClassMetadataInfo $metadata): void diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php index 6c2dbf73ad7..49c69bb20d2 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php @@ -10,25 +10,42 @@ class DDC964Address { /** + * @var int * @GeneratedValue * @Id @Column(type="integer") */ private $id; - /** @Column */ + /** + * @var string|null + * @Column + */ private $country; - /** @Column */ + /** + * @var string|null + * @Column + */ private $zip; - /** @Column */ + /** + * @var string|null + * @Column + */ private $city; - /** @Column */ + /** + * @var string|null + * @Column + */ private $street; - public function __construct(?string $zip = null, ?string $country = null, ?string $city = null, ?string $street = null) - { + public function __construct( + ?string $zip = null, + ?string $country = null, + ?string $city = null, + ?string $street = null + ) { $this->zip = $zip; $this->country = $country; $this->city = $city; @@ -40,7 +57,7 @@ public function getId(): int return $this->id; } - public function getCountry(): string + public function getCountry(): ?string { return $this->country; } @@ -50,7 +67,7 @@ public function setCountry(string $country): void $this->country = $country; } - public function getZip(): string + public function getZip(): ?string { return $this->zip; } @@ -60,7 +77,7 @@ public function setZip(string $zip): void $this->zip = $zip; } - public function getCity(): string + public function getCity(): ?string { return $this->city; } @@ -70,7 +87,7 @@ public function setCity(string $city): void $this->city = $city; } - public function getStreet(): string + public function getStreet(): ?string { return $this->street; } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php index 2e3f61466e3..c87def125c4 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php @@ -12,16 +12,20 @@ class DDC964Group { /** + * @var int * @GeneratedValue * @Id @Column(type="integer") */ private $id; - /** @Column */ + /** + * @var string|null + * @Column + */ private $name; /** - * @ArrayCollection + * @psalm-var ArrayCollection * @ManyToMany(targetEntity="DDC964User", mappedBy="groups") */ private $users; @@ -37,7 +41,7 @@ public function setName(string $name): void $this->name = $name; } - public function getName(): string + public function getName(): ?string { return $this->name; } @@ -47,6 +51,9 @@ public function addUser(DDC964User $user): void $this->users[] = $user; } + /** + * @psalm-return ArrayCollection + */ public function getUsers(): ArrayCollection { return $this->users; diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php index f834faba507..168e7066647 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\Models\DDC964; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadataInfo; /** @@ -20,11 +21,14 @@ class DDC964User */ protected $id; - /** @Column(name="user_name", nullable=true, unique=false, length=250) */ + /** + * @var string|null + * @Column(name="user_name", nullable=true, unique=false, length=250) + */ protected $name; /** - * @var ArrayCollection + * @psalm-var Collection * @ManyToMany(targetEntity="DDC964Group", inversedBy="users", cascade={"persist", "merge", "detach"}) * @JoinTable(name="ddc964_users_groups", * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, @@ -51,7 +55,7 @@ public function getId(): int return $this->id; } - public function getName(): string + public function getName(): ?string { return $this->name; } @@ -67,6 +71,9 @@ public function addGroup(DDC964Group $group): void $group->addUser($this); } + /** + * @psalm-return Collection + */ public function getGroups(): ArrayCollection { return $this->groups; diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php index 371aed9453c..133c660b845 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php @@ -48,22 +48,22 @@ public function __construct(?Directory $parentDir = null) $this->parentDirectory = $parentDir; } - public function getId() + public function getId(): int { return $this->id; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } - public function getName() + public function getName(): string { return $this->name; } - public function getParent() + public function getParent(): Directory { return $this->parentDirectory; } diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php index 04054f5dd05..3f2501992d8 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php @@ -15,12 +15,12 @@ class Directory extends AbstractContentItem */ protected $path; - public function setPath($path): void + public function setPath(string $path): void { $this->path = $path; } - public function getPath() + public function getPath(): string { return $this->path; } diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/File.php b/tests/Doctrine/Tests/Models/DirectoryTree/File.php index 3fd5a665a1d..ad03de7fd2b 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/File.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/File.php @@ -21,12 +21,12 @@ public function __construct(?Directory $parent = null) parent::__construct($parent); } - public function getExtension() + public function getExtension(): string { return $this->extension; } - public function setExtension($ext): void + public function setExtension(string $ext): void { $this->extension = $ext; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php index 8159cfd3e95..bcce39df087 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\Models\ECommerce; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; /** * ECommerceCart @@ -23,21 +24,25 @@ class ECommerceCart */ private $id; - /** @Column(length=50, nullable=true) */ + /** + * @var string + * @Column(length=50, nullable=true) + */ private $payment; /** - * @var ECommerceCustomer + * @var ECommerceCustomer|null * @OneToOne(targetEntity="ECommerceCustomer", inversedBy="cart") * @JoinColumn(name="customer_id", referencedColumnName="id") */ private $customer; /** + * @psalm-var Collection * @ManyToMany(targetEntity="ECommerceProduct", cascade={"persist"}) * @JoinTable(name="ecommerce_carts_products", - joinColumns={@JoinColumn(name="cart_id", referencedColumnName="id")}, - inverseJoinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}) + * joinColumns={@JoinColumn(name="cart_id", referencedColumnName="id")}, + * inverseJoinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}) */ private $products; @@ -46,17 +51,17 @@ public function __construct() $this->products = new ArrayCollection(); } - public function getId() + public function getId(): int { return $this->id; } - public function getPayment() + public function getPayment(): string { return $this->payment; } - public function setPayment($payment): void + public function setPayment(string $payment): void { $this->payment = $payment; } @@ -78,12 +83,15 @@ public function removeCustomer(): void } } - public function getCustomer() + public function getCustomer(): ?ECommerceCustomer { return $this->customer; } - public function getProducts() + /** + * @psalm-return Collection + */ + public function getProducts(): Collection { return $this->products; } @@ -93,7 +101,7 @@ public function addProduct(ECommerceProduct $product): void $this->products[] = $product; } - public function removeProduct(ECommerceProduct $product) + public function removeProduct(ECommerceProduct $product): bool { return $this->products->removeElement($product); } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php index beb3cc6877d..cebeb8a6a25 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php @@ -54,17 +54,17 @@ public function __construct() $this->children = new ArrayCollection(); } - public function getId() + public function getId(): int { return $this->id; } - public function getName() + public function getName(): string { return $this->name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } @@ -85,7 +85,10 @@ public function removeProduct(ECommerceProduct $product): void } } - public function getProducts() + /** + * @psalm-return Collection + */ + public function getProducts(): Collection { return $this->products; } @@ -95,12 +98,15 @@ private function setParent(ECommerceCategory $parent): void $this->parent = $parent; } - public function getChildren() + /** + * @psalm-return Collection + */ + public function getChildren(): Collection { return $this->children; } - public function getParent() + public function getParent(): ?ECommerceCategory { return $this->parent; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php index af2ba454c3b..6339efc3738 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php @@ -28,7 +28,7 @@ class ECommerceCustomer private $name; /** - * @var ECommerceCart + * @var ECommerceCart|null * @OneToOne(targetEntity="ECommerceCart", mappedBy="customer", cascade={"persist"}) */ private $cart; @@ -38,22 +38,23 @@ class ECommerceCustomer * only one customer at the time, while a customer can choose only one * mentor. Not properly appropriate but it works. * + * @var ECommerceCustomer|null * @OneToOne(targetEntity="ECommerceCustomer", cascade={"persist"}, fetch="EAGER") * @JoinColumn(name="mentor_id", referencedColumnName="id") */ private $mentor; - public function getId() + public function getId(): int { return $this->id; } - public function getName() + public function getName(): string { return $this->name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } @@ -72,7 +73,7 @@ public function brokenSetCart(ECommerceCart $cart): void $this->cart = $cart; } - public function getCart() + public function getCart(): ?ECommerceCart { return $this->cart; } @@ -96,7 +97,7 @@ public function removeMentor(): void $this->mentor = null; } - public function getMentor() + public function getMentor(): ?ECommerceCustomer { return $this->mentor; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php index 49f8ce3fa37..80fec7aa253 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php @@ -20,27 +20,30 @@ class ECommerceFeature */ private $id; - /** @Column(length=50) */ + /** + * @var string|null + * @Column(length=50) + */ private $description; /** - * @var ECommerceProduct + * @var ECommerceProduct|null * @ManyToOne(targetEntity="ECommerceProduct", inversedBy="features") * @JoinColumn(name="product_id", referencedColumnName="id") */ private $product; - public function getId() + public function getId(): int { return $this->id; } - public function getDescription() + public function getDescription(): ?string { return $this->description; } - public function setDescription($description): void + public function setDescription(string $description): void { $this->description = $description; } @@ -59,7 +62,7 @@ public function removeProduct(): void } } - public function getProduct() + public function getProduct(): ?ECommerceProduct { return $this->product; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php index 28ca2cd4909..d5d5fd964be 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php @@ -31,7 +31,7 @@ class ECommerceProduct private $name; /** - * @var ECommerceShipping + * @var ECommerceShipping|null * @OneToOne(targetEntity="ECommerceShipping", cascade={"persist"}) * @JoinColumn(name="shipping_id", referencedColumnName="id") */ @@ -44,6 +44,7 @@ class ECommerceProduct private $features; /** + * @psalm-var Collection * @ManyToMany(targetEntity="ECommerceCategory", cascade={"persist"}, inversedBy="products") * @JoinTable(name="ecommerce_products_categories", * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, @@ -55,6 +56,7 @@ class ECommerceProduct * This relation is saved with two records in the association table for * simplicity. * + * @psalm-var Collection * @ManyToMany(targetEntity="ECommerceProduct", cascade={"persist"}) * @JoinTable(name="ecommerce_products_related", * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, @@ -62,8 +64,11 @@ class ECommerceProduct */ private $related; + /** @var bool */ public $isCloned = false; - public $wakeUp = false; + + /** @var bool */ + public $wakeUp = false; public function __construct() { @@ -72,22 +77,22 @@ public function __construct() $this->related = new ArrayCollection(); } - public function getId() + public function getId(): int { return $this->id; } - public function getName() + public function getName(): string { return $this->name; } - public function setName($name): void + public function setName(string $name): void { $this->name = $name; } - public function getShipping() + public function getShipping(): ?ECommerceShipping { return $this->shipping; } @@ -102,7 +107,10 @@ public function removeShipping(): void $this->shipping = null; } - public function getFeatures() + /** + * @psalm-return Collection + */ + public function getFeatures(): Collection { return $this->features; } @@ -119,7 +127,7 @@ public function brokenAddFeature(ECommerceFeature $feature): void $this->features[] = $feature; } - public function removeFeature(ECommerceFeature $feature) + public function removeFeature(ECommerceFeature $feature): bool { $removed = $this->features->removeElement($feature); if ($removed) { @@ -145,17 +153,26 @@ public function removeCategory(ECommerceCategory $category): void } } - public function setCategories($categories): void + /** + * @psalm-param Collection $categories + */ + public function setCategories(Collection $categories): void { $this->categories = $categories; } - public function getCategories() + /** + * @psalm-return Collection $categories + */ + public function getCategories(): Collection { return $this->categories; } - public function getRelated() + /** + * @psalm-return Collection $categories + */ + public function getRelated(): Collection { return $this->related; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php index 97e6a1f5445..81deea04bbb 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php @@ -21,21 +21,27 @@ class ECommerceShipping private $id; /** - * @var int + * @var int|string * @Column(type="integer") */ private $days; - public function getId() + public function getId(): int { return $this->id; } + /** + * @return int|string + */ public function getDays() { return $this->days; } + /** + * @param int|string $days + */ public function setDays($days): void { $this->days = $days; diff --git a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php b/tests/Doctrine/Tests/Models/Forum/ForumCategory.php index cdde27f81e0..20ee0cdd176 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumCategory.php @@ -37,7 +37,7 @@ class ForumCategory */ public $boards; - public function getId() + public function getId(): int { return $this->id; } diff --git a/tests/Doctrine/Tests/Models/Forum/ForumEntry.php b/tests/Doctrine/Tests/Models/Forum/ForumEntry.php index bf6ec03bd08..e04b6d5cf84 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumEntry.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumEntry.php @@ -23,7 +23,7 @@ class ForumEntry */ public $topic; - public function &getTopicByReference() + public function &getTopicByReference(): string { return $this->topic; } diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index dae2a8f784b..85d2d4b87cb 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -902,7 +902,7 @@ public function testMethodsAndPropertiesAreNotDuplicatedInChildClasses(): void $this->assertTrue($rc2->hasProperty('name')); $this->assertTrue($rc2->hasProperty('id')); - $this->assertTrue($rc2->hasProperty('created_at')); + $this->assertTrue($rc2->hasProperty('createdAt')); $this->assertTrue($rc2->hasMethod('getName')); $this->assertTrue($rc2->hasMethod('setName')); @@ -916,7 +916,7 @@ public function testMethodsAndPropertiesAreNotDuplicatedInChildClasses(): void $this->assertTrue($rc3->hasProperty('name')); $this->assertFalse($rc3->hasProperty('id')); - $this->assertFalse($rc3->hasProperty('created_at')); + $this->assertFalse($rc3->hasProperty('createdAt')); $this->assertTrue($rc3->hasMethod('getName')); $this->assertTrue($rc3->hasMethod('setName'));