From 9f8c7e7014e3dfd8823926a3fc21c1fb2fe60de5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 00:13:29 +0100 Subject: [PATCH 01/16] Fix header comment Document member variables --- Entity/User.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Entity/User.php b/Entity/User.php index 4b3d4e3..7a82144 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -1,11 +1,11 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -19,62 +19,62 @@ use Rapsys\UserBundle\Entity\User as BaseUser; class User extends BaseUser { /** - * @var ?string + * City */ private ?string $city; /** - * @var ?string + * Phone */ private ?string $phone; /** - * @var Country + * Country */ private ?Country $country; /** - * @var ?string + * Pseudonym */ private ?string $pseudonym; /** - * @var ?string + * Zipcode */ private ?string $zipcode; /** - * @var \Doctrine\Common\Collections\Collection + * Applications collection */ private Collection $applications; /** - * @var \Doctrine\Common\Collections\Collection + * Dances collection */ private Collection $dances; /** - * @var \Doctrine\Common\Collections\Collection + * Locations collection */ private Collection $locations; /** - * @var \Doctrine\Common\Collections\Collection + * Snippets collection */ private Collection $snippets; /** - * @var \Doctrine\Common\Collections\Collection + * Subscribers collection */ private Collection $subscribers; /** - * @var \Doctrine\Common\Collections\Collection + * Subscriptions collection */ private Collection $subscriptions; /** - * @var \Doctrine\Common\Collections\Collection + * Google tokens collection */ private Collection $googleTokens; -- 2.41.1 From 45d4262949d2f96811d692cf1e6608c83963ea64 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 00:14:35 +0100 Subject: [PATCH 02/16] Cleanup --- Entity/Session.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Entity/Session.php b/Entity/Session.php index 1cba677..3532309 100644 --- a/Entity/Session.php +++ b/Entity/Session.php @@ -123,6 +123,8 @@ class Session { //Set defaults $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); + + //Set collections $this->applications = new ArrayCollection(); } -- 2.41.1 From 07ee75c0ded3f104345cf801bb6fbb1f0f9565a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:14:59 +0100 Subject: [PATCH 03/16] Cleanup --- Entity/Civility.php | 3 +++ Entity/Group.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Entity/Civility.php b/Entity/Civility.php index befa349..5e111c1 100644 --- a/Entity/Civility.php +++ b/Entity/Civility.php @@ -13,5 +13,8 @@ namespace Rapsys\AirBundle\Entity; use Rapsys\UserBundle\Entity\Civility as BaseCivility; +/** + * {@inheritdoc} + */ class Civility extends BaseCivility { } diff --git a/Entity/Group.php b/Entity/Group.php index 7e972ff..6e340ad 100644 --- a/Entity/Group.php +++ b/Entity/Group.php @@ -13,5 +13,8 @@ namespace Rapsys\AirBundle\Entity; use Rapsys\UserBundle\Entity\Group as BaseGroup; +/** + * {@inheritdoc} + */ class Group extends BaseGroup { } -- 2.41.1 From 3f4eae21e72bf3261fa8b939a50408de6b119f74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:15:07 +0100 Subject: [PATCH 04/16] Add default values to class member variables Cleanup --- Entity/User.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Entity/User.php b/Entity/User.php index 7a82144..178bcec 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -17,31 +17,34 @@ use Doctrine\Common\Collections\ArrayCollection; use Rapsys\UserBundle\Entity\Civility; use Rapsys\UserBundle\Entity\User as BaseUser; +/** + * {@inheritdoc} + */ class User extends BaseUser { /** * City */ - private ?string $city; + private ?string $city = null; /** - * Phone + * Country */ - private ?string $phone; + private ?Country $country = null; /** - * Country + * Phone */ - private ?Country $country; + private ?string $phone = null; /** * Pseudonym */ - private ?string $pseudonym; + private ?string $pseudonym = null; /** * Zipcode */ - private ?string $zipcode; + private ?string $zipcode = null; /** * Applications collection @@ -93,13 +96,6 @@ class User extends BaseUser { //Call parent constructor parent::__construct($this->mail, $this->password, $this->civility, $this->forename, $this->surname, $this->active, $this->enable); - //Set defaults - $this->city = null; - $this->country = null; - $this->phone = null; - $this->pseudonym = null; - $this->zipcode = null; - //Set collections $this->applications = new ArrayCollection(); $this->dances = new ArrayCollection(); -- 2.41.1 From 080a3edad6e32b0bea88f39b1b01367e4d5b1fed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:16:22 +0100 Subject: [PATCH 05/16] Fix header comment Strict types Cleanup --- Entity/Slot.php | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Entity/Slot.php b/Entity/Slot.php index 445f053..25ef3e8 100644 --- a/Entity/Slot.php +++ b/Entity/Slot.php @@ -1,16 +1,17 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Rapsys\AirBundle\Entity; +use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\PreUpdateEventArgs; @@ -19,37 +20,34 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class Slot { /** - * @var integer + * Primary key */ - private $id; + private ?int $id = null; /** - * @var string + * Create datetime */ - protected $title; + private \DateTime $created; /** - * @var \DateTime + * Update datetime */ - private $created; + private \DateTime $updated; /** - * @var \DateTime + * Sessions collection */ - private $updated; - - /** - * @var ArrayCollection - */ - private $sessions; + private Collection $sessions; /** * Constructor */ - public function __construct() { + public function __construct(private string $title) { //Set defaults $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); + + //Set collections $this->sessions = new ArrayCollection(); } @@ -58,7 +56,7 @@ class Slot { * * @return integer */ - public function getId(): int { + public function getId(): ?int { return $this->id; } -- 2.41.1 From dca2abfc031c68f180052f935cc72ff3308f2111 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:18:54 +0100 Subject: [PATCH 06/16] Fix header comment Add default values to class member variables Strict types Cleanup --- Entity/Snippet.php | 77 +++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 49 deletions(-) diff --git a/Entity/Snippet.php b/Entity/Snippet.php index fa5fe99..dea8897 100644 --- a/Entity/Snippet.php +++ b/Entity/Snippet.php @@ -1,11 +1,11 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -18,95 +18,74 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class Snippet { /** - * @var integer - */ - private $id; - - /** - * @var string + * Primary key */ - protected $locale; + private ?int $id = null; /** * @var string */ - protected $description; + private ?string $description = null; /** * @var string */ - protected $class; + private ?string $class = null; /** * @var string */ - protected $short; + private ?string $short = null; /** * @var integer */ - protected $rate; + private ?int $rate = null; /** * @var bool */ - protected $hat; + private ?bool $hat = null; /** * @var string */ - protected $contact; + private ?string $contact = null; /** * @var string */ - protected $donate; + private ?string $donate = null; /** * @var string */ - protected $link; + private ?string $link = null; /** * @var string */ - protected $profile; - - /** - * @var \DateTime - */ - protected $created; - - /** - * @var \DateTime - */ - protected $updated; + private ?string $profile = null; /** - * @var Location + * Create datetime */ - protected $location; + private \DateTime $created; /** - * @var User + * Update datetime */ - protected $user; + private \DateTime $updated; /** * Constructor + * + * @param string $locale The locale + * @param Location $location The location instance + * @param User $user The user instance */ - public function __construct() { + public function __construct(private string $locale, private Location $location, private User $user) { //Set defaults - $this->description = null; - $this->class = null; - $this->short = null; - $this->rate = null; - $this->hat = null; - $this->contact = null; - $this->donate = null; - $this->link = null; - $this->profile = null; - $this->location = null; $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); } @@ -116,7 +95,7 @@ class Snippet { * * @return integer */ - public function getId(): int { + public function getId(): ?int { return $this->id; } @@ -390,7 +369,7 @@ class Snippet { * * @return Snippet */ - public function setLocation(Location $location) { + public function setLocation(Location $location): Snippet { $this->location = $location; return $this; @@ -401,7 +380,7 @@ class Snippet { * * @return Location */ - public function getLocation() { + public function getLocation(): Location { return $this->location; } @@ -412,7 +391,7 @@ class Snippet { * * @return Snippet */ - public function setUser(User $user) { + public function setUser(User $user): Snippet { $this->user = $user; return $this; @@ -423,7 +402,7 @@ class Snippet { * * @return User */ - public function getUser() { + public function getUser(): User { return $this->user; } -- 2.41.1 From 8f802c1a7fcaf4efe6822ecee3e19f1cededf2c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:19:39 +0100 Subject: [PATCH 07/16] Fix header comment Cleanup --- Entity/Session.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Entity/Session.php b/Entity/Session.php index 3532309..f74963c 100644 --- a/Entity/Session.php +++ b/Entity/Session.php @@ -1,11 +1,11 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -97,7 +97,7 @@ class Session { private ?\DateTime $locked = null; /** - * Creation datetime + * Create datetime */ private \DateTime $created; -- 2.41.1 From aa392e7390d8c6abd217d09b8a646f41625a91c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:20:49 +0100 Subject: [PATCH 08/16] Fix header comment Add default values to class member variables Strict types Cleanup --- Entity/Location.php | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Entity/Location.php b/Entity/Location.php index 85283df..75f6f45 100644 --- a/Entity/Location.php +++ b/Entity/Location.php @@ -1,16 +1,17 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Rapsys\AirBundle\Entity; +use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\PreUpdateEventArgs; @@ -19,9 +20,9 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class Location { /** - * @var integer + * Primary key */ - private $id; + private ?int $id = null; /** * @var string @@ -31,7 +32,7 @@ class Location { /** * @var string */ - protected $description; + private ?string $description = null; /** * @var string @@ -69,38 +70,39 @@ class Location { private $hotspot; /** - * @var \DateTime + * Create datetime */ - private $created; + private \DateTime $created; /** - * @var \DateTime + * Update datetime */ - private $updated; + private \DateTime $updated; /** - * @var ArrayCollection + * Sessions collection */ - private $sessions; + private Collection $sessions; /** - * @var ArrayCollection + * Snippets collection */ - private $snippets; + private Collection $snippets; /** - * @var ArrayCollection + * Users collection */ - private $users; + private Collection $users; /** * Constructor */ public function __construct() { //Set defaults - $this->description = null; $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); + + //Set collections $this->sessions = new ArrayCollection(); $this->snippets = new ArrayCollection(); $this->users = new ArrayCollection(); @@ -111,7 +113,7 @@ class Location { * * @return integer */ - public function getId(): int { + public function getId(): ?int { return $this->id; } -- 2.41.1 From b22cd3b27e98582db6c04c5bfe8b5e3272fdf717 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:21:24 +0100 Subject: [PATCH 09/16] Fix header comment Add default values to class member variables Strict types Cleanup --- Entity/Application.php | 44 +++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/Entity/Application.php b/Entity/Application.php index 4e94f20..b2672a1 100644 --- a/Entity/Application.php +++ b/Entity/Application.php @@ -1,11 +1,11 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -18,56 +18,52 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class Application { /** - * @var integer + * Primary key */ - private $id; + private ?int $id = null; /** - * @var Dance + * Dance instance */ - private $dance; + private Dance $dance; /** - * @var float + * Score */ - private $score; + private ?float $score = null; /** - * @var \DateTime + * Cancel datetime */ - private $canceled; + private ?\DateTime $canceled = null; /** - * @var \DateTime + * Create datetime */ - private $created; + private \DateTime $created; /** - * @var \DateTime + * Update datetime */ - private $updated; + private \DateTime $updated; /** - * @var \Rapsys\AirBundle\Entity\Session + * Session instance */ - private $session; + private $session = null; /** - * @var \Rapsys\AirBundle\Entity\User + * User instance */ - private $user; + private $user = null; /** * Constructor */ public function __construct() { //Set defaults - $this->score = null; - $this->canceled = null; $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); - $this->session = null; - $this->user = null; } /** @@ -75,7 +71,7 @@ class Application { * * @return integer */ - public function getId(): int { + public function getId(): ?int { return $this->id; } -- 2.41.1 From 7fecee5709e8e1d27656b87c279a12f65632b429 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:22:01 +0100 Subject: [PATCH 10/16] Add default values to class member variables Strict types Cleanup --- Entity/Country.php | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/Entity/Country.php b/Entity/Country.php index 5674007..48a3037 100644 --- a/Entity/Country.php +++ b/Entity/Country.php @@ -11,6 +11,7 @@ namespace Rapsys\AirBundle\Entity; +use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\PreUpdateEventArgs; @@ -19,39 +20,24 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class Country { /** - * @var integer + * Primary key */ - private $id; + private ?int $id = null; /** - * @var string + * Create datetime */ - protected $code; + private \DateTime $created; /** - * @var string + * Update datetime */ - protected $alpha; + private \DateTime $updated; /** - * @var string + * Users collection */ - protected $title; - - /** - * @var \DateTime - */ - protected $created; - - /** - * @var \DateTime - */ - protected $updated; - - /** - * @var ArrayCollection - */ - protected $users; + private Collection $users; /** * Constructor @@ -60,11 +46,8 @@ class Country { * @param string $alpha The country alpha * @param string $title The country title */ - public function __construct(string $code, string $alpha, string $title) { + public function __construct(private string $code, private string $alpha, private string $title) { //Set defaults - $this->code = $code; - $this->alpha = $alpha; - $this->title = $title; $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); @@ -77,7 +60,7 @@ class Country { * * @return integer */ - public function getId(): int { + public function getId(): ?int { return $this->id; } -- 2.41.1 From aecd79b0af016492323465e0526dbbbd94178976 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:23:04 +0100 Subject: [PATCH 11/16] Fix header comment Add default values to class member variables Strict types Cleanup --- Entity/Dance.php | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/Entity/Dance.php b/Entity/Dance.php index 0b132c8..6ae5f1b 100644 --- a/Entity/Dance.php +++ b/Entity/Dance.php @@ -1,16 +1,17 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Rapsys\AirBundle\Entity; +use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\PreUpdateEventArgs; @@ -19,39 +20,29 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class Dance { /** - * @var integer + * Primary key */ - private $id; + private ?int $id = null; /** - * @var string + * Create datetime */ - protected $name; + private \DateTime $created; /** - * @var string + * Update datetime */ - protected $type; + private \DateTime $updated; /** - * @var \DateTime + * Applications collection */ - private $created; + private Collection $applications; /** - * @var \DateTime + * Users collection */ - private $updated; - - /** - * @var ArrayCollection - */ - private $applications; - - /** - * @var ArrayCollection - */ - private $users; + private Collection $users; /** * Constructor @@ -59,10 +50,8 @@ class Dance { * @param string $name The dance name * @param string $type The dance type */ - public function __construct(string $name, string $type) { + public function __construct(private string $name, private string $type) { //Set defaults - $this->name = $name; - $this->type = $type; $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); @@ -76,7 +65,7 @@ class Dance { * * @return integer */ - public function getId(): int { + public function getId(): ?int { return $this->id; } -- 2.41.1 From e83f85c13afccface76993878f36f581b055a2fb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:26:57 +0100 Subject: [PATCH 12/16] Add default values to class member variables Strict types Cleanup --- Entity/GoogleCalendar.php | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/Entity/GoogleCalendar.php b/Entity/GoogleCalendar.php index ff4f455..f4ef2ce 100644 --- a/Entity/GoogleCalendar.php +++ b/Entity/GoogleCalendar.php @@ -11,8 +11,6 @@ namespace Rapsys\AirBundle\Entity; -use Doctrine\Common\Collections\Collection; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\PreUpdateEventArgs; /** @@ -20,54 +18,30 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class GoogleCalendar { /** - * @var int + * Primary key */ - private ?int $id; + private ?int $id = null; /** - * @var string - */ - private $mail; - - /** - * @var string - */ - private $summary; - - /** - * @var \DateTime - */ - private \DateTime $synchronized; - - /** - * @var \DateTime + * Create datetime */ private \DateTime $created; /** - * @var \DateTime + * Update datetime */ private \DateTime $updated; - /** - * @var \Rapsys\AirBundle\Entity\GoogleToken - */ - private GoogleToken $googleToken; - /** * Constructor * - * @param \Rapsys\AirBundle\Entity\GoogleToken $googleToken The google token + * @param GoogleToken $googleToken The google token * @param string $mail The google calendar id * @param string $summary The google calendar summary * @param \DateTime $synchronized The google calendar last synchronization */ - public function __construct(GoogleToken $googleToken, string $mail, string $summary, \DateTime $synchronized = new \DateTime('now')) { + public function __construct(private GoogleToken $googleToken, private string $mail, private string $summary, private \DateTime $synchronized = new \DateTime('now')) { //Set defaults - $this->googleToken = $googleToken; - $this->mail = $mail; - $this->summary = $summary; - $this->synchronized = $synchronized; $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); } -- 2.41.1 From 90b9c0d611ea9971ff324726816bd08bc2a783c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:27:27 +0100 Subject: [PATCH 13/16] Add default values to class member variables Strict types Cleanup --- Entity/GoogleToken.php | 46 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/Entity/GoogleToken.php b/Entity/GoogleToken.php index 3da7279..e44b176 100644 --- a/Entity/GoogleToken.php +++ b/Entity/GoogleToken.php @@ -20,68 +20,40 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class GoogleToken { /** - * @var int + * Primary key */ - private ?int $id; + private ?int $id = null; /** - * @var string - */ - private string $mail; - - /** - * @var string - */ - private string $access; - - /** - * @var ?string - */ - private ?string $refresh; - - /** - * @var \DateTime - */ - private \DateTime $expired; - - /** - * @var \DateTime + * Create datetime */ private \DateTime $created; /** - * @var \DateTime + * Update datetime */ private \DateTime $updated; /** - * @var \Doctrine\Common\Collections\Collection + * Google calendars collection */ private Collection $googleCalendars; - /** - * @var \Rapsys\AirBundle\Entity\User - */ - private User $user; - /** * Constructor * - * @param \Rapsys\AirBundle\Entity\User $user The user + * @param User $user The user instance * @param string The token user mail * @param string The access token identifier * @param \DateTime The access token expires * @param ?string The refresh token identifier */ - public function __construct(User $user, string $mail, string $access, \DateTime $expired, ?string $refresh = null) { + public function __construct(private User $user, private string $mail, private string $access, private \DateTime $expired, private ?string $refresh = null) { //Set defaults - $this->user = $user; - $this->mail = $mail; - $this->access = $access; - $this->refresh = $refresh; - $this->expired = $expired; $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); + + //Set collections $this->googleCalendars = new ArrayCollection(); } -- 2.41.1 From 2780e5afd00aab04544a788a89afdb22784acb98 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:28:47 +0100 Subject: [PATCH 14/16] Fix header comment Add arguments on new entity instance Strict types Cleanup --- DataFixtures/AirFixtures.php | 85 +++++++++++++++++------------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/DataFixtures/AirFixtures.php b/DataFixtures/AirFixtures.php index 18fda1b..92f4b55 100644 --- a/DataFixtures/AirFixtures.php +++ b/DataFixtures/AirFixtures.php @@ -1,4 +1,13 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Rapsys\AirBundle\DataFixtures; @@ -13,6 +22,9 @@ use Rapsys\AirBundle\Entity\User; use Rapsys\AirBundle\Entity\Location; use Rapsys\AirBundle\Entity\Slot; +/** + * {@inheritdoc} + */ class AirFixtures extends Fixture { /** * Air fixtures constructor @@ -25,19 +37,16 @@ class AirFixtures extends Fixture { */ public function load(ObjectManager $manager) { //Civility tree - $civilityTree = array( + $civilityTree = [ 'Mister', 'Madam', 'Miss' - ); + ]; //Create titles - $civilitys = array(); + $civilitys = []; foreach($civilityTree as $civilityData) { - $civility = new Civility(); - $civility->setTitle($civilityData); - $civility->setCreated(new \DateTime('now')); - $civility->setUpdated(new \DateTime('now')); + $civility = new Civility($civilityData); $manager->persist($civility); $civilitys[$civilityData] = $civility; unset($civility); @@ -48,19 +57,17 @@ class AirFixtures extends Fixture { #insert into countries (code, alpha, title, created, updated) select countryCode, isoAlpha3, countryName, NOW(), NOW() FROM apps_countries_detailed ORDER BY countryCode ASC, isoAlpha3 ASC; //Dance tree - $danceTree = array( + $danceTree = [ 'Argentine Tango' => [ 'Milonga', 'Class and milonga', 'Public class', 'Private class' ] - ); + ]; //Create titles - $dances = array(); + $dances = []; foreach($danceTree as $danceTitle => $danceData) { foreach($danceData as $danceType) { $dance = new Dance($danceTitle, $danceType); - $dance->setCreated(new \DateTime('now')); - $dance->setUpdated(new \DateTime('now')); $manager->persist($dance); unset($dance); } @@ -68,20 +75,18 @@ class AirFixtures extends Fixture { //Group tree //XXX: ROLE_XXX is required by - $groupTree = array( + $groupTree = [ 'User', 'Guest', 'Regular', 'Senior', 'Admin' - ); + ]; //Create groups - $groups = array(); + $groups = []; foreach($groupTree as $groupData) { $group = new Group($groupData); - $group->setCreated(new \DateTime('now')); - $group->setUpdated(new \DateTime('now')); $manager->persist($group); $groups[$groupData] = $group; unset($group); @@ -91,8 +96,8 @@ class AirFixtures extends Fixture { $manager->flush(); //User tree - $userTree = array( - array( + $userTree = [ + [ 'short' => 'Mr.', 'group' => 'Admin', 'mail' => 'tango@rapsys.eu', @@ -101,8 +106,8 @@ class AirFixtures extends Fixture { 'surname' => 'Gertz', 'phone' => '+33677952829', 'password' => 'test' - ), - /*array( + ], + /*[ 'short' => 'Mr.', 'group' => 'Senior', 'mail' => 'denis.courvoisier@wanadoo.fr', @@ -111,8 +116,8 @@ class AirFixtures extends Fixture { 'surname' => 'Courvoisier', 'phone' => '+33600000000', 'password' => 'test' - ),*/ - array( + ],*/ + [ 'short' => 'Mr.', 'group' => 'Senior', 'mail' => 'rannou402@orange.fr', @@ -121,8 +126,8 @@ class AirFixtures extends Fixture { 'surname' => 'Rannou', 'phone' => '+33600000000', 'password' => 'test' - ), - /*array( + ], + /*[ 'short' => 'Ms.', 'group' => 'Regular', 'mail' => 'roxmaps@gmail.com', @@ -131,22 +136,18 @@ class AirFixtures extends Fixture { 'surname' => 'Prado', 'phone' => '+33600000000', 'password' => 'test' - ),*/ - ); + ],*/ + ]; //Create users - $users = array(); + $users = []; foreach($userTree as $userData) { - $user = new User($userData['mail']); + $user = new User($userData['mail'], $userData['password'], $civilitys[$userData['short']], $userData['forename'], $userData['surname']); + #TODO: check that password is hashed correctly !!! + #$user->setPassword($this->hasher->hashPassword($user, $userData['password'])); $user->setPseudonym($userData['pseudonym']); - $user->setForename($userData['forename']); - $user->setSurname($userData['surname']); $user->setPhone($userData['phone']); - $user->setPassword($this->hasher->hashPassword($user, $userData['password'])); - $user->setCivility($civilitys[$userData['short']]); $user->addGroup($groups[$userData['group']]); - $user->setCreated(new \DateTime('now')); - $user->setUpdated(new \DateTime('now')); $manager->persist($user); $users[] = $user; unset($user); @@ -157,6 +158,7 @@ class AirFixtures extends Fixture { //Location tree //XXX: adding a new zipcode here requires matching accuweather uris in Command/WeatherCommand.php + //TODO: add descriptions as well $locationTree = [ [ 'title' => 'Garnier opera', @@ -302,7 +304,7 @@ class AirFixtures extends Fixture { ]; //Create locations - $locations = array(); + $locations = []; foreach($locationTree as $locationData) { $location = new Location(); $location->setTitle($locationData['title']); @@ -313,8 +315,6 @@ class AirFixtures extends Fixture { $location->setLatitude($locationData['latitude']); $location->setLongitude($locationData['longitude']); $location->setHotspot($locationData['hotspot']); - $location->setCreated(new \DateTime('now')); - $location->setUpdated(new \DateTime('now')); $manager->persist($location); $locations[$locationData['title']] = $location; unset($location); @@ -332,12 +332,9 @@ class AirFixtures extends Fixture { ]; //Create slots - $slots = array(); + $slots = []; foreach($slotTree as $slotData) { - $slot = new Slot(); - $slot->setTitle($slotData); - $slot->setCreated(new \DateTime('now')); - $slot->setUpdated(new \DateTime('now')); + $slot = new Slot($slotData); $manager->persist($slot); $slots[$slot->getId()] = $slot; unset($slot); -- 2.41.1 From f972044e64e3c1f79f86b1b44c2f821a35e39e62 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:31:08 +0100 Subject: [PATCH 15/16] Shorten air bundle route alias --- Controller/UserController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/UserController.php b/Controller/UserController.php index bd28a54..13c1bec 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -160,7 +160,7 @@ class UserController extends BaseUserController { 'application_name' => $request->server->get('GOOGLE_PROJECT'), 'client_id' => $request->server->get('GOOGLE_CLIENT'), 'client_secret' => $request->server->get('GOOGLE_SECRET'), - 'redirect_uri' => $this->generateUrl('rapsys_air_google_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), + 'redirect_uri' => $this->generateUrl('rapsysair_google_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), 'scopes' => self::googleScopes, 'access_type' => 'offline', 'login_hint' => $user->getMail(), @@ -546,7 +546,7 @@ class UserController extends BaseUserController { 'application_name' => $request->server->get('GOOGLE_PROJECT'), 'client_id' => $request->server->get('GOOGLE_CLIENT'), 'client_secret' => $request->server->get('GOOGLE_SECRET'), - 'redirect_uri' => $this->generateUrl('rapsys_air_google_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), + 'redirect_uri' => $this->generateUrl('rapsysair_google_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), 'scopes' => self::googleScopes, 'access_type' => 'offline', 'login_hint' => $user->getMail(), -- 2.41.1 From c31b21bb5ae6a3c8509ebd7b253067c04b1d87cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 8 Mar 2024 01:31:19 +0100 Subject: [PATCH 16/16] Shorten air bundle route alias --- Controller/SnippetController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Controller/SnippetController.php b/Controller/SnippetController.php index 0c9bc3d..7182021 100644 --- a/Controller/SnippetController.php +++ b/Controller/SnippetController.php @@ -45,7 +45,7 @@ class SnippetController extends DefaultController { //Set options [ //Set the action - 'action' => $this->generateUrl('rapsys_air_snippet_add', ['location' => $request->get('location')]), + 'action' => $this->generateUrl('rapsysair_snippet_add', ['location' => $request->get('location')]), //Set the form attribute 'attr' => [] ] @@ -138,7 +138,7 @@ class SnippetController extends DefaultController { unset($route['_route'], $route['_controller']); //Check if snippet view route - if ($name == 'rapsys_air_user_view' && !empty($route['id'])) { + if ($name == 'rapsysair_user_view' && !empty($route['id'])) { //Replace id $route['id'] = $snippet->getUser()->getId(); //Other routes @@ -157,7 +157,7 @@ class SnippetController extends DefaultController { } //Redirect to cleanup the form - return $this->redirectToRoute('rapsys_air', ['snippet' => $snippet->getId()]); + return $this->redirectToRoute('rapsysair', ['snippet' => $snippet->getId()]); } /** @@ -197,7 +197,7 @@ class SnippetController extends DefaultController { //Set options [ //Set the action - 'action' => $this->generateUrl('rapsys_air_snippet_edit', ['id' => $id]), + 'action' => $this->generateUrl('rapsysair_snippet_edit', ['id' => $id]), //Set the form attribute 'attr' => [] ] @@ -322,7 +322,7 @@ class SnippetController extends DefaultController { unset($route['_route'], $route['_controller']); //Check if snippet view route - if ($name == 'rapsys_air_user_view' && !empty($route['id'])) { + if ($name == 'rapsysair_user_view' && !empty($route['id'])) { //Replace id $route['id'] = $snippet->getUser()->getId(); //Other routes @@ -341,6 +341,6 @@ class SnippetController extends DefaultController { } //Redirect to cleanup the form - return $this->redirectToRoute('rapsys_air', ['snippet' => $snippet->getId()]); + return $this->redirectToRoute('rapsysair', ['snippet' => $snippet->getId()]); } } -- 2.41.1