From 71c0edfd65c95bd05705d7c037766f477aac2791 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Thu, 12 Aug 2021 14:39:50 +0200 Subject: [PATCH 1/1] Add strict type Cleanup --- Entity/Civility.php | 45 +++++++++++++++++++++++++-------------- Entity/Group.php | 51 +++++++++++++++++++++++++++++---------------- Entity/User.php | 30 ++++++++++++++++++-------- 3 files changed, 83 insertions(+), 43 deletions(-) diff --git a/Entity/Civility.php b/Entity/Civility.php index 83c7f47..8e1719c 100644 --- a/Entity/Civility.php +++ b/Entity/Civility.php @@ -1,7 +1,20 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Rapsys\UserBundle\Entity; +use Doctrine\Common\Collections\ArrayCollection; + +use Rapsys\UserBundle\Entity\User; + /** * Civility */ @@ -27,7 +40,7 @@ class Civility { protected $updated; /** - * @var \Doctrine\Common\Collections\Collection + * @var ArrayCollection */ protected $users; @@ -35,7 +48,7 @@ class Civility { * Constructor */ public function __construct() { - $this->users = new \Doctrine\Common\Collections\ArrayCollection(); + $this->users = new ArrayCollection(); } /** @@ -43,7 +56,7 @@ class Civility { * * @return integer */ - public function getId() { + public function getId(): int { return $this->id; } @@ -54,7 +67,7 @@ class Civility { * * @return Civility */ - public function setTitle($title) { + public function setTitle(string $title) { $this->title = $title; return $this; @@ -65,7 +78,7 @@ class Civility { * * @return string */ - public function getTitle() { + public function getTitle(): ?string { return $this->title; } @@ -76,7 +89,7 @@ class Civility { * * @return Civility */ - public function setCreated($created) { + public function setCreated(\DateTime $created) { $this->created = $created; return $this; @@ -87,7 +100,7 @@ class Civility { * * @return \DateTime */ - public function getCreated() { + public function getCreated(): \DateTime { return $this->created; } @@ -98,7 +111,7 @@ class Civility { * * @return Civility */ - public function setUpdated($updated) { + public function setUpdated(\DateTime $updated) { $this->updated = $updated; return $this; @@ -109,18 +122,18 @@ class Civility { * * @return \DateTime */ - public function getUpdated() { + public function getUpdated(): \DateTime { return $this->updated; } /** * Add user * - * @param \Rapsys\UserBundle\Entity\User $user + * @param User $user * * @return Civility */ - public function addUser(\Rapsys\UserBundle\Entity\User $user) { + public function addUser(User $user): Civility { $this->users[] = $user; return $this; @@ -129,18 +142,18 @@ class Civility { /** * Remove user * - * @param \Rapsys\UserBundle\Entity\User $user + * @param User $user */ - public function removeUser(\Rapsys\UserBundle\Entity\User $user) { + public function removeUser(User $user) { $this->users->removeElement($user); } /** * Get users * - * @return \Doctrine\Common\Collections\Collection + * @return ArrayCollection */ - public function getUsers() { + public function getUsers(): ArrayCollection { return $this->users; } diff --git a/Entity/Group.php b/Entity/Group.php index c503b2f..1141f91 100644 --- a/Entity/Group.php +++ b/Entity/Group.php @@ -1,8 +1,23 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -// src/Rapsys/UserBundle/Entity/Group.php namespace Rapsys\UserBundle\Entity; +use Doctrine\Common\Collections\ArrayCollection; + +use Rapsys\UserBundle\Entity\User; + +/** + * Group + */ class Group { /** * @var integer @@ -25,7 +40,7 @@ class Group { protected $updated; /** - * @var \Doctrine\Common\Collections\Collection + * @var ArrayCollection */ protected $users; @@ -36,7 +51,7 @@ class Group { */ public function __construct(string $title) { $this->title = (string) $title; - $this->users = new \Doctrine\Common\Collections\ArrayCollection(); + $this->users = new ArrayCollection(); } /** @@ -44,7 +59,7 @@ class Group { * * @return integer */ - public function getId() { + public function getId(): int { return $this->id; } @@ -55,7 +70,7 @@ class Group { * * @return User */ - public function setTitle($title) { + public function setTitle(string $title) { $this->title = $title; return $this; @@ -66,7 +81,7 @@ class Group { * * @return string */ - public function getTitle() { + public function getTitle(): ?string { return $this->title; } @@ -77,7 +92,7 @@ class Group { * * @return User */ - public function setCreated($created) { + public function setCreated(\DateTime $created) { $this->created = $created; return $this; @@ -88,7 +103,7 @@ class Group { * * @return \DateTime */ - public function getCreated() { + public function getCreated(): \DateTime { return $this->created; } @@ -99,7 +114,7 @@ class Group { * * @return User */ - public function setUpdated($updated) { + public function setUpdated(\DateTime $updated) { $this->updated = $updated; return $this; @@ -110,18 +125,18 @@ class Group { * * @return \DateTime */ - public function getUpdated() { + public function getUpdated(): \DateTime { return $this->updated; } /** * Add user * - * @param \Rapsys\UserBundle\Entity\User $user + * @param User $user * * @return Group */ - public function addUser(\Rapsys\UserBundle\Entity\User $user) { + public function addUser(User $user) { $this->users[] = $user; return $this; @@ -130,18 +145,18 @@ class Group { /** * Remove user * - * @param \Rapsys\UserBundle\Entity\User $user + * @param User $user */ - public function removeUser(\Rapsys\UserBundle\Entity\User $user) { + public function removeUser(User $user) { $this->users->removeElement($user); } /** * Get users * - * @return \Doctrine\Common\Collections\Collection + * @return ArrayCollection */ - public function getUsers() { + public function getUsers(): ArrayCollection { return $this->users; } @@ -159,7 +174,7 @@ class Group { * * @return string */ - public function getRole() { + public function getRole(): string { return 'ROLE_'.strtoupper($this->title); } } diff --git a/Entity/User.php b/Entity/User.php index 3c1c768..8e6a671 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -1,13 +1,25 @@ - + * + * for the full copyright and license information, please view the license + * file that was distributed with this source code. + */ -// src/Rapsys/UserBundle/Entity/User.php namespace Rapsys\UserBundle\Entity; -use Rapsys\UserBundle\Entity\Group; -use Symfony\Component\Security\Core\User\UserInterface; use Doctrine\Common\Collections\ArrayCollection; +use Symfony\Component\Security\Core\User\UserInterface; + use Rapsys\UserBundle\Entity\Civility; +use Rapsys\UserBundle\Entity\Group; +/** + * User + */ class User implements UserInterface, \Serializable { /** * @var integer @@ -60,12 +72,12 @@ class User implements UserInterface, \Serializable { protected $updated; /** - * @var \Rapsys\UserBundle\Entity\Civility + * @var Civility */ protected $civility; /** - * @var \Doctrine\Common\Collections\ArrayCollection + * @var ArrayCollection */ protected $groups; @@ -306,7 +318,7 @@ class User implements UserInterface, \Serializable { /** * Add group * - * @param \Rapsys\UserBundle\Entity\Group $group + * @param Group $group * * @return User */ @@ -319,7 +331,7 @@ class User implements UserInterface, \Serializable { /** * Remove group * - * @param \Rapsys\UserBundle\Entity\Group $group + * @param Group $group */ public function removeGroup(Group $group) { $this->groups->removeElement($group); @@ -328,7 +340,7 @@ class User implements UserInterface, \Serializable { /** * Get groups * - * @return \Doctrine\Common\Collections\ArrayCollection + * @return ArrayCollection */ public function getGroups(): ArrayCollection { return $this->groups; -- 2.41.1