Browse Source

fix phpstan errors

Olivier Massot 6 months ago
parent
commit
890c8c20df

+ 7 - 8
src/Entity/Access/Access.php

@@ -429,18 +429,21 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
     #[ORM\OneToMany(targetEntity: AbstractReport::class, mappedBy: 'access', cascade: ['persist', 'remove'])]
     private Collection $reports;
 
+    /** @var Collection<int, SimulationSession> */
     #[ORM\OneToMany(targetEntity: SimulationSession::class, mappedBy: 'accessInitiator', cascade: ['persist', 'remove'])]
     protected Collection $simulationSessionAccessInitiators;
 
+    /** @var Collection<int, SimulationSession> */
     #[ORM\OneToMany(
         targetEntity: SimulationSession::class,
         mappedBy: 'accessSimulated',
         cascade: ['persist', 'remove'],
         orphanRemoval: false,
     )]
-    protected Collection $simulationSessionAccessesSimulated;
+    protected Collection $simulationSessionAccessSimulateds;
 
-    #[ORM\OneToMany(mappedBy: 'access', targetEntity: Orders::class, cascade: [], orphanRemoval: true)]
+    /** @var Collection<int, Orders> */
+    #[ORM\OneToMany(targetEntity: Orders::class, mappedBy: 'access', cascade: [], orphanRemoval: true)]
     protected Collection $orders;
 
     #[Pure]
@@ -2553,9 +2556,7 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
 
     function removeSimulationSessionAccessInitiator(SimulationSession $simulationSessionAccessInitiator): self
     {
-        if ($this->simulationSessionAccessInitiators->removeElement($simulationSessionAccessInitiator)) {
-            $simulationSessionAccessInitiator->setAccessInitiator(null);
-        }
+        $this->simulationSessionAccessInitiators->removeElement($simulationSessionAccessInitiator);
 
         return $this;
     }
@@ -2577,9 +2578,7 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
 
     function removeSimulationSessionAccessSimulated(SimulationSession $simulationSessionAccessSimulated): self
     {
-        if ($this->simulationSessionAccessSimulateds->removeElement($simulationSessionAccessSimulated)) {
-            $simulationSessionAccessSimulated->setAccessSimulated(null);
-        }
+        $this->simulationSessionAccessSimulateds->removeElement($simulationSessionAccessSimulated);
 
         return $this;
     }

+ 0 - 1
src/Entity/Billing/AbstractBillAccounting.php

@@ -148,7 +148,6 @@ class AbstractBillAccounting
     {
         if (!$this->billingIntangibleExcludeDates->contains($billingIntangibleExcludeDate)) {
             $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
-            /* @phpstan-ignore-next-line */
             $billingIntangibleExcludeDate->setBill($this);
         }
 

+ 4 - 4
src/Entity/Billing/BillingSettingRent.php

@@ -25,8 +25,8 @@ class BillingSettingRent
     protected ?BillingSetting $billingSetting;
 
     #[ORM\ManyToOne(targetEntity: FamilyQuotientModel::class, cascade: [], inversedBy: 'billingSettingRents')]
-    #[ORM\JoinColumn(onDelete: 'SET NULL')]
-    protected FamilyQuotientModel $familyQuotientModel;
+    #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
+    protected ?FamilyQuotientModel $familyQuotientModel;
 
     public function getBillingSetting(): ?BillingSetting
     {
@@ -45,12 +45,12 @@ class BillingSettingRent
         return $this->id;
     }
 
-    function getFamilyQuotientModel(): FamilyQuotientModel
+    function getFamilyQuotientModel(): ?FamilyQuotientModel
     {
         return $this->familyQuotientModel;
     }
 
-    function setFamilyQuotientModel(FamilyQuotientModel $familyQuotientModel): self
+    function setFamilyQuotientModel(?FamilyQuotientModel $familyQuotientModel): self
     {
         $this->familyQuotientModel = $familyQuotientModel;
         return $this;

+ 1 - 0
src/Entity/Billing/FamilyQuotientModel.php

@@ -35,6 +35,7 @@ class FamilyQuotientModel
     #[ORM\OneToMany(targetEntity: IntangiblePriceAndDiscount::class, mappedBy: 'familyQuotientModel', cascade: [], orphanRemoval: false)]
     protected Collection $intangiblePriceAndDiscounts;
 
+    /** @var Collection<int, BillingSettingRent> */
     #[ORM\OneToMany(targetEntity: BillingSettingRent::class, mappedBy: 'familyQuotientModel', cascade: [], orphanRemoval: false)]
     protected Collection $billingSettingRents;
 

+ 2 - 0
src/Entity/Core/Tips.php

@@ -7,6 +7,7 @@ namespace App\Entity\Core;
 // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
 use ApiPlatform\Metadata\ApiResource;
 use App\Entity\Organization\Organization;
+use App\Entity\Product\IntangiblePriceAndDiscount;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
@@ -20,6 +21,7 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class Tips extends AbstractInformation
 {
+    /** @var Collection<int, Organization> */
     #[ORM\ManyToMany(targetEntity: Organization::class, mappedBy: 'tips', cascade: [], orphanRemoval: false)]
     protected Collection $organizations;
 

+ 4 - 4
src/Entity/Education/EducationCurriculumPack.php

@@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiResource;
 use App\Entity\Core\Tagg;
 use App\Entity\Organization\Organization;
 use App\Entity\Product\Intangible;
+use App\Entity\Product\IntangiblePriceAndDiscount;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
@@ -59,6 +60,7 @@ class EducationCurriculumPack
     #[ORM\ManyToMany(targetEntity: Intangible::class, mappedBy: 'educationCurriculumPacks', cascade: [], orphanRemoval: false)]
     public Collection $intangibles;
 
+    /** @var Collection<int, RequiredChoicesBlock> */
     #[ORM\OneToMany(
         targetEntity: RequiredChoicesBlock::class,
         mappedBy: 'educationCurriculumPacks',
@@ -201,7 +203,7 @@ class EducationCurriculumPack
     {
         if (!$this->requiredChoicesBlocks->contains($requiredChoicesBlock)) {
             $this->requiredChoicesBlocks[] = $requiredChoicesBlock;
-            $requiredChoicesBlock->setEducationCurriculumPacks($this);
+            $requiredChoicesBlock->setEducationCurriculumPack($this);
         }
 
         return $this;
@@ -209,9 +211,7 @@ class EducationCurriculumPack
 
     function removeRequiredChoicesBlock(RequiredChoicesBlock $requiredChoicesBlock): self
     {
-        if ($this->requiredChoicesBlocks->removeElement($requiredChoicesBlock)) {
-            $requiredChoicesBlock->setEducationCurriculumPacks(null);
-        }
+        $this->requiredChoicesBlocks->removeElement($requiredChoicesBlock);
 
         return $this;
     }

+ 2 - 0
src/Entity/Education/RequiredChoicesBlock.php

@@ -10,6 +10,7 @@ namespace App\Entity\Education;
 
 use ApiPlatform\Metadata\ApiResource;
 use App\Entity\Education;
+use App\Entity\Product\IntangiblePriceAndDiscount;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
@@ -27,6 +28,7 @@ class RequiredChoicesBlock
     #[ORM\JoinColumn(nullable: false)]
     protected Education\EducationCurriculumPack $educationCurriculumPack;
 
+    /** @var Collection<int, EducationCurriculum> */
     #[ORM\ManyToMany(
         targetEntity: EducationCurriculum::class,
         inversedBy: 'requiredChoicesEducationCurriculumPacks',

+ 0 - 4
src/Entity/Organization/Organization.php

@@ -372,10 +372,6 @@ class Organization
     //    #[ORM\OneToOne()]
     //    private OnlineRegistrationSettings $onlineRegistrationSettings;
 
-    /** @var Collection<int, Tagg> */
-    #[ORM\OneToMany(targetEntity: Tagg::class, mappedBy: 'organization', cascade: ['persist', 'remove'])]
-    private Collection $ownedTags;
-
     /** @var Collection<int, Tagg> */
     #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'organizations', cascade: ['persist'])]
     #[ORM\JoinTable(name: 'tag_organization')]

+ 4 - 3
src/Entity/Shop/Orders.php

@@ -18,7 +18,8 @@ class Orders
     protected string $uuid;
 
     #[ORM\ManyToOne(targetEntity: Organization::class, cascade: [], inversedBy: 'orders')]
-    protected Organization $organization;
+    #[ORM\JoinColumn(nullable: true)]
+    protected ?Organization $organization;
 
     #[ORM\ManyToOne(targetEntity: Access::class, cascade: [], inversedBy: 'orders')]
     protected ?Access $access;
@@ -34,12 +35,12 @@ class Orders
         return $this;
     }
 
-     function getOrganization(): Organization
+     function getOrganization(): ?Organization
     {
         return $this->organization;
     }
 
-    function setOrganization(Organization $organization): self
+    function setOrganization(?Organization $organization): self
     {
         $this->organization = $organization;
         return $this;

+ 16 - 20
src/Entity/SimulationSession/SimulationSession.php

@@ -23,20 +23,16 @@ class SimulationSession
     #[ORM\Column]
     protected mixed $initiatorIp;
 
-    /** -- Warning : auto-generated property, checkup the attribute options -- */
-    #[ORM\Column(type: 'datetime', options: ['nullable' => true])]
+    #[ORM\Column(type: 'datetime', nullable: true)]
     protected ?\DateTimeInterface $expiryDate;
 
-    /** -- Warning : auto-generated property, checkup the attribute options -- */
     #[ORM\Column(options: ['default' => false])]
     protected bool $alreadyUsed;
 
-    /** -- Warning : auto-generated property, checkup the attribute options -- */
-    #[ORM\Column(type: 'datetime', options: ['nullable' => true])]
+    #[ORM\Column(type: 'datetime', nullable: true)]
     protected ?\DateTimeInterface $createDate;
 
-    /** -- Warning : auto-generated property, checkup the attribute options -- */
-    #[ORM\Column(type: 'datetime', options: ['nullable' => true])]
+    #[ORM\Column(type: 'datetime', nullable: true)]
     protected ?\DateTimeInterface $updateDate;
 
     /** -- Warning : auto-generated property, checkup the attribute options -- */
@@ -64,7 +60,7 @@ class SimulationSession
     protected Access $accessSimulated;
 
     #[ORM\OneToOne(mappedBy: 'simulationSession', targetEntity: Token::class, cascade: ['persist'])]
-    protected Token $token;
+    protected ?Token $token;
 
     function getId(): int
     {
@@ -88,12 +84,12 @@ class SimulationSession
         return $this;
     }
 
-    function getExpiryDate(): \DateTimeInterface
+    function getExpiryDate(): ?\DateTimeInterface
     {
         return $this->expiryDate;
     }
 
-    function setExpiryDate(\DateTimeInterface $expiryDate): self
+    function setExpiryDate(?\DateTimeInterface $expiryDate): self
     {
         $this->expiryDate = $expiryDate;
         return $this;
@@ -110,23 +106,23 @@ class SimulationSession
         return $this;
     }
 
-    function getCreateDate(): \DateTimeInterface
+    function getCreateDate(): ?\DateTimeInterface
     {
         return $this->createDate;
     }
 
-    function setCreateDate(\DateTimeInterface $createDate): self
+    function setCreateDate(?\DateTimeInterface $createDate): self
     {
         $this->createDate = $createDate;
         return $this;
     }
 
-    function getUpdateDate(): \DateTimeInterface
+    function getUpdateDate(): ?\DateTimeInterface
     {
         return $this->updateDate;
     }
 
-    function setUpdateDate(\DateTimeInterface $updateDate): self
+    function setUpdateDate(?\DateTimeInterface $updateDate): self
     {
         $this->updateDate = $updateDate;
         return $this;
@@ -176,34 +172,34 @@ class SimulationSession
         return $this;
     }
 
-    function getAccessInitiator(): Access\Access
+    function getAccessInitiator(): Access
     {
         return $this->accessInitiator;
     }
 
-    function setAccessInitiator(Access\Access $accessInitiator): self
+    function setAccessInitiator(Access $accessInitiator): self
     {
         $this->accessInitiator = $accessInitiator;
         return $this;
     }
 
-    function getAccessSimulated(): Access\Access
+    function getAccessSimulated(): Access
     {
         return $this->accessSimulated;
     }
 
-    function setAccessSimulated(Access\Access $accessSimulated): self
+    function setAccessSimulated(Access $accessSimulated): self
     {
         $this->accessSimulated = $accessSimulated;
         return $this;
     }
 
-    function getToken(): Token\Token
+    function getToken(): ?Token
     {
         return $this->token;
     }
 
-    function setToken(Token\Token $token): self
+    function setToken(?Token $token): self
     {
         $this->token = $token;
         return $this;

+ 4 - 4
src/Entity/Token/Token.php

@@ -26,8 +26,8 @@ class Token
     private ?Access $access;
 
     #[ORM\OneToOne(targetEntity: SimulationSession::class, inversedBy: 'token', cascade: ['persist'])]
-    #[ORM\JoinColumn(unique: true, onDelete: 'CASCADE')]
-    protected SimulationSession $simulationSession;
+    #[ORM\JoinColumn(unique: true, nullable: true, onDelete: 'CASCADE')]
+    protected ?SimulationSession $simulationSession;
 
     public function getId(): int
     {
@@ -53,12 +53,12 @@ class Token
         return $this;
     }
 
-    function getSimulationSession(): SimulationSession
+    function getSimulationSession(): ?SimulationSession
     {
         return $this->simulationSession;
     }
 
-    function setSimulationSession(SimulationSession $simulationSession): self
+    function setSimulationSession(?SimulationSession $simulationSession): self
     {
         $this->simulationSession = $simulationSession;
         return $this;