Browse Source

PhpStan Level 1 to 6

Vincent 2 years ago
parent
commit
e1204afd43
100 changed files with 305 additions and 468 deletions
  1. 7 1
      phpstan.neon.dist
  2. 18 0
      readme.md
  3. 1 1
      src/ApiResources/Profile/AccessProfile.php
  4. 4 0
      src/Commands/CronCommand.php
  5. 1 1
      src/Commands/DolibarrSyncCommand.php
  6. 3 3
      src/Commands/PostUpgrade/V0_2/PostUpgradeCommand.php
  7. 2 2
      src/Doctrine/Access/AccessExtensionInterface.php
  8. 1 1
      src/Doctrine/Access/Extensions/DateTimeConstraintExtension.php
  9. 1 2
      src/Doctrine/Access/Extensions/StudentsExtension.php
  10. 3 4
      src/Entity/Access/Access.php
  11. 2 1
      src/Entity/Access/AccessFamily.php
  12. 0 113
      src/Entity/Access/AccessFictionalIntangible.php
  13. 1 1
      src/Entity/Access/PersonalizedList.php
  14. 2 1
      src/Entity/Billing/AccessIntangible.php
  15. 1 1
      src/Entity/Billing/BergerLevrault.php
  16. 5 0
      src/Entity/Billing/BillAccessDetail.php
  17. 1 1
      src/Entity/Billing/BillAccounting.php
  18. 1 1
      src/Entity/Billing/BillPayment.php
  19. 4 4
      src/Entity/Billing/ResidenceArea.php
  20. 0 36
      src/Entity/Billing/SddBank.php
  21. 0 36
      src/Entity/Billing/SddRegie.php
  22. 2 2
      src/Entity/Booking/Work.php
  23. 1 1
      src/Entity/Core/ContactPoint.php
  24. 1 1
      src/Entity/Core/Notification.php
  25. 1 1
      src/Entity/Education/Cycle.php
  26. 1 1
      src/Entity/Education/Education.php
  27. 1 1
      src/Entity/Education/EducationNotationConfig.php
  28. 1 1
      src/Entity/Education/EducationTiming.php
  29. 3 3
      src/Entity/Message/AbstractMessage.php
  30. 23 1
      src/Entity/Message/ReportSms.php
  31. 1 1
      src/Entity/Network/Network.php
  32. 2 76
      src/Entity/Organization/Organization.php
  33. 1 1
      src/Entity/Organization/OrganizationAddressPostal.php
  34. 2 2
      src/Entity/Organization/OrganizationLicence.php
  35. 1 1
      src/Entity/Organization/Parameters.php
  36. 1 1
      src/Entity/Person/Person.php
  37. 1 1
      src/Entity/Person/PersonAddressPostal.php
  38. 1 1
      src/Entity/Place/Room.php
  39. 1 1
      src/Enum/Access/FunctionEnum.php
  40. 21 9
      src/EventListener/DoctrineFilter/DoctrineFilterListener.php
  41. 3 3
      src/EventSubscriber/ElasticaPostTransformSubscriber.php
  42. 2 2
      src/Filter/DoctrineFilter/AbstractTimeFilter.php
  43. 1 1
      src/Filter/DoctrineFilter/ActivityYearFilter.php
  44. 1 1
      src/Filter/DoctrineFilter/DateTimeFilter.php
  45. 1 1
      src/Filter/Person/FullNameFilter.php
  46. 1 1
      src/Filter/Utils/DistanceFilter.php
  47. 1 1
      src/Filter/Utils/FindInSetFilter.php
  48. 1 1
      src/Filter/Utils/InFilter.php
  49. 1 1
      src/Message/Command/Parameters/AverageChange.php
  50. 1 1
      src/Message/Handler/ExportHandler.php
  51. 1 1
      src/Message/Handler/MailerHandler.php
  52. 1 1
      src/Message/Handler/Parameters/AverageChangeHandler.php
  53. 1 1
      src/Message/Handler/Typo3/Typo3DeleteCommandHandler.php
  54. 1 1
      src/Message/Handler/Typo3/Typo3UndeleteCommandHandler.php
  55. 1 1
      src/Message/Handler/Typo3/Typo3UpdateCommandHandler.php
  56. 1 1
      src/OpenApi/OpenApiFactory.php
  57. 15 6
      src/Repository/Access/AccessRepository.php
  58. 1 1
      src/Security/Voter/BankAccountVoter.php
  59. 1 1
      src/Security/Voter/ContactPointVoter.php
  60. 1 1
      src/Security/Voter/CotisationVoter.php
  61. 2 1
      src/Security/Voter/ModuleVoter.php
  62. 3 1
      src/Security/Voter/SwitchUserVoter.php
  63. 3 1
      src/Serializer/AccessContextBuilder.php
  64. 3 1
      src/Serializer/DefaultNormalizer.php
  65. 9 3
      src/Service/ApiLegacy/ApiLegacyRequestService.php
  66. 2 2
      src/Service/Constraint/AbstractTimeConstraintUtils.php
  67. 7 7
      src/Service/Constraint/ActivityYearConstraint.php
  68. 4 4
      src/Service/Constraint/DateTimeConstraint.php
  69. 0 1
      src/Service/Cotisation/Utils.php
  70. 5 5
      src/Service/Cron/Job/CleanTempFiles.php
  71. 11 11
      src/Service/Dolibarr/DolibarrSyncService.php
  72. 1 1
      src/Service/Elasticsearch/EducationNotationUpdater.php
  73. 1 1
      src/Service/Export/Encoder/EncoderInterface.php
  74. 1 1
      src/Service/Export/LicenceCmfExporter.php
  75. 1 1
      src/Service/Export/Model/LicenceCmf.php
  76. 6 1
      src/Service/File/FileManager.php
  77. 1 1
      src/Service/File/Storage/ApiLegacyStorage.php
  78. 2 2
      src/Service/File/Storage/LocalStorage.php
  79. 7 11
      src/Service/Mailer/Builder/AbstractBuilder.php
  80. 4 3
      src/Service/Mailer/Builder/AbstractBuilderInterface.php
  81. 2 1
      src/Service/Mailer/Builder/BuilderInterface.php
  82. 1 1
      src/Service/Mailer/Email.php
  83. 0 7
      src/Service/Mailer/EmailInterface.php
  84. 8 5
      src/Service/Mailer/Mailer.php
  85. 1 1
      src/Service/Mailer/Model/AbstractMailerModel.php
  86. 4 4
      src/Service/Mailer/Model/MailerModelInterface.php
  87. 9 9
      src/Service/MercureHub.php
  88. 1 1
      src/Service/Network/Utils.php
  89. 2 2
      src/Service/OnChange/OnChangeContext.php
  90. 4 4
      src/Service/OnChange/OnChangeDefault.php
  91. 8 8
      src/Service/OnChange/OnChangeInterface.php
  92. 1 1
      src/Service/OnChange/Organization/OnOrganizationChange.php
  93. 1 1
      src/Service/OnChange/Organization/OnParametersChange.php
  94. 13 6
      src/Service/OnChange/Organization/OnSubdomainChange.php
  95. 1 1
      src/Service/Organization/Utils.php
  96. 6 4
      src/Service/Security/SwitchUser.php
  97. 1 1
      src/Service/ServiceIterator/CurrentAccessExtensionIterator.php
  98. 2 2
      src/Service/ServiceIterator/Mailer/BuilderIterator.php
  99. 1 1
      src/Service/Utils/DatesUtils.php
  100. 5 5
      src/Service/Utils/EntityUtils.php

+ 7 - 1
phpstan.neon.dist

@@ -1,7 +1,13 @@
 # https://phpstan.org/config-reference
 parameters:
-	level: 0
+	level: 6
+	treatPhpDocTypesAsCertain: false
+	checkGenericClassInNonGenericObjectType: false
+
+# on ignore les erreurs qui proviennent d'un importe d'un attribut PhpStorm
+# on ignore les erreurs qui imposent d'indiquer le type d'un iterable dans la phpDoc (cf: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type)
 	ignoreErrors :
 	    - '#Attribute class JetBrains\\PhpStorm\\[a-zA-Z]+ does not exist.#'
+	    - '#no value type specified in iterable type [a-zA-Z]+.#'
 	paths:
 		- src

+ 18 - 0
readme.md

@@ -24,3 +24,21 @@ Pour exécuter une analyse du code :
 
 > Voir : https://phpstan.org/user-guide/getting-started
 
+# PHPStan
+
+Le fichier comportant la configuration pour chacun est phpstan.neon.dist
+Le fichier phpstan.neon n'est pas versionné et surcharge les valeurs du .dist
+
+## Principales commandes 
+
+Pour lancer l'analyse
+
+    vendor/bin/phpstan analyse
+
+Pour vider le cache (utiles entre chaque analyse si les modifications ne sont pas prises en compte)
+
+    vendor/bin/phpstan clear-result-cache
+
+> Voir : https://phpstan.org/
+
+

+ 1 - 1
src/ApiResources/Profile/AccessProfile.php

@@ -24,7 +24,7 @@ use Doctrine\Common\Collections\Collection;
         new Get(
             uriTemplate: '/my_profile/{id}',
             defaults: ['id' => 0],
-            normalizationContext: ['groups' => ['access_profile_read:output']],
+            normalizationContext: ['groups' => ['access_profile_read']],
             provider: AccessProfileProvider::class
         )
     ]

+ 4 - 0
src/Commands/CronCommand.php

@@ -10,6 +10,7 @@ use RuntimeException;
 use Symfony\Component\Console\Attribute\AsCommand;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Command\LockableTrait;
+use Symfony\Component\Console\Helper\FormatterHelper;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
@@ -96,6 +97,8 @@ class CronCommand extends Command
     final protected function execute(InputInterface $input, OutputInterface $output): int
     {
         $this->output = $output;
+
+        /** @var FormatterHelper $formatter */
         $formatter = $this->getHelper('formatter');
 
         $action = $input->getArgument('action');
@@ -170,6 +173,7 @@ class CronCommand extends Command
      */
     private function runJob(CronjobInterface $job, bool $preview = false): int
     {
+        /** @var FormatterHelper $formatter */
         $formatter = $this->getHelper('formatter');
 
         if (!$this->lock($job->name())) {

+ 1 - 1
src/Commands/DolibarrSyncCommand.php

@@ -30,7 +30,7 @@ class DolibarrSyncCommand extends Command
         parent::__construct();
     }
 
-    protected function configure()
+    protected function configure(): void
     {
         $this->addOption(
             'preview',

+ 3 - 3
src/Commands/PostUpgrade/V0_2/PostUpgradeCommand.php

@@ -39,7 +39,7 @@ class PostUpgradeCommand extends Command
         return Command::SUCCESS;
     }
 
-    private function getOpentalentConnexion() {
+    private function getOpentalentConnexion(): PDO {
         $dbUrl = $_ENV['DATABASE_URL'];
         $matches = [];
         preg_match(
@@ -154,7 +154,7 @@ class PostUpgradeCommand extends Command
         }
     }
 
-    private function genEventsUuid() {
+    private function genEventsUuid(): void {
         $opentalentCnn = $this->getOpentalentConnexion();
 
         $opentalentCnn->beginTransaction();
@@ -178,7 +178,7 @@ class PostUpgradeCommand extends Command
         }
     }
 
-    private function updateFilesStatuses() {
+    private function updateFilesStatuses():void  {
         $opentalentCnn = $this->getOpentalentConnexion();
 
         $opentalentCnn->beginTransaction();

+ 2 - 2
src/Doctrine/Access/AccessExtensionInterface.php

@@ -6,6 +6,6 @@ namespace App\Doctrine\Access;
 use Doctrine\ORM\QueryBuilder;
 
 interface AccessExtensionInterface{
-    public function support(string $name);
-    public function addWhere(QueryBuilder $queryBuilder);
+    public function support(string $name): bool;
+    public function addWhere(QueryBuilder $queryBuilder): void;
 }

+ 1 - 1
src/Doctrine/Access/Extensions/DateTimeConstraintExtension.php

@@ -21,7 +21,7 @@ class DateTimeConstraintExtension implements AccessExtensionInterface {
             );
     }
 
-    public function addWhere(QueryBuilder $queryBuilder)
+    public function addWhere(QueryBuilder $queryBuilder): void
     {
         $rootAlias = $queryBuilder->getRootAliases()[0];
         $queryBuilder->innerJoin(sprintf('%s.organizationFunction', $rootAlias), 'organization_function');

+ 1 - 2
src/Doctrine/Access/Extensions/StudentsExtension.php

@@ -13,8 +13,7 @@ class StudentsExtension implements AccessExtensionInterface {
         return $name === 'cget_students';
     }
 
-    public function addWhere(QueryBuilder $queryBuilder)
+    public function addWhere(QueryBuilder $queryBuilder): void
     {
-        dd('ok');
     }
 }

+ 3 - 4
src/Entity/Access/Access.php

@@ -8,6 +8,7 @@ use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
 use ApiPlatform\Metadata\ApiFilter;
 use App\Entity\AccessWish\AccessWish;
 use App\Entity\Billing\AccessBilling;
+use App\Entity\Billing\AccessFictionalIntangible;
 use App\Entity\Billing\Bill;
 use App\Entity\Billing\BillCredit;
 use App\Entity\Billing\BillLine;
@@ -104,9 +105,6 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
     #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
     private ?array $setting = [];
 
-    #[Groups(['my_access:input'])]
-    private array $historical = [];
-
     #[ORM\OneToOne(mappedBy: 'access', cascade: ['persist'], orphanRemoval: true)]
     private AccessBilling $accessBilling;
 
@@ -410,6 +408,7 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
         return array_key_exists('historical', $this->setting) && $this->setting['historical'] ? $this->setting['historical'] : ['present' => true];
     }
 
+    #[Groups(['my_access:input'])]
     public function setHistorical(array $historical): self
     {
         if (!$historical['past'] && !$historical['present'] && !$historical['future']) {
@@ -743,7 +742,7 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
         return null;
     }
 
-    public function eraseCredentials()
+    public function eraseCredentials(): void
     {
         // TODO: Implement eraseCredentials() method.
     }

+ 2 - 1
src/Entity/Access/AccessFamily.php

@@ -6,6 +6,7 @@ namespace App\Entity\Access;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\ApiResource;
 //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
+use App\Entity\Billing\AccessFictionalIntangible;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
@@ -33,7 +34,7 @@ class AccessFamily
     private Collection $accesses;
 
     #[ORM\OneToMany(mappedBy: 'accessFamily', targetEntity: AccessFictionalIntangible::class, cascade: ['persist'], orphanRemoval: true)]
-    private $accessFictionalIntangibles;
+    private Collection $accessFictionalIntangibles;
 
     public function __construct()
     {

+ 0 - 113
src/Entity/Access/AccessFictionalIntangible.php

@@ -1,113 +0,0 @@
-<?php
-declare(strict_types=1);
-
-namespace App\Entity\Access;
-
-use App\Entity\Billing\BillingIntangibleExcludeDate;
-use App\Entity\Product\FictionalIntangible;
-//use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
-use Doctrine\Common\Collections\ArrayCollection;
-use Doctrine\ORM\Mapping as ORM;
-use Doctrine\Common\Collections\Collection;
-
-/**
- * Classe ... qui ...
- */
-//#[Auditable]
-#[ORM\Entity]
-class AccessFictionalIntangible
-{
-    #[ORM\Id]
-    #[ORM\Column]
-    #[ORM\GeneratedValue]
-    private ?int $id = null;
-
-    #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'accessFictionalIntangibles')]
-    private Access $access;
-
-    #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'accessFictionalIntangibles')]
-    private AccessFamily $accessFamily;
-
-    #[ORM\ManyToOne]
-    #[ORM\JoinColumn(nullable: false)]
-    private FictionalIntangible $fictionalIntangible;
-
-    #[ORM\OneToMany(mappedBy: 'accessFictionalIntangible', targetEntity: BillingIntangibleExcludeDate::class, cascade: ['persist'], orphanRemoval: true)]
-    private Collection $billingIntangibleExcludeDates;
-
-    public function __construct()
-    {
-        $this->billingIntangibleExcludeDates = new ArrayCollection();
-    }
-
-    public function getId(): ?int
-    {
-        return $this->id;
-    }
-
-    public function getAccess(): ?Access
-    {
-        return $this->access;
-    }
-
-    public function setAccess(?Access $access): self
-    {
-        $this->access = $access;
-
-        return $this;
-    }
-
-    public function getAccessFamily(): ?AccessFamily
-    {
-        return $this->accessFamily;
-    }
-
-    public function setAccessFamily(?AccessFamily $accessFamily): self
-    {
-        $this->accessFamily = $accessFamily;
-
-        return $this;
-    }
-
-    public function getFictionalIntangible(): ?FictionalIntangible
-    {
-        return $this->fictionalIntangible;
-    }
-
-    public function setFictionalIntangible(?FictionalIntangible $fictionalIntangible): self
-    {
-        $this->fictionalIntangible = $fictionalIntangible;
-
-        return $this;
-    }
-
-    /**
-     * @return Collection<int, BillingIntangibleExcludeDate>
-     */
-    public function getBillingIntangibleExcludeDates(): Collection
-    {
-        return $this->billingIntangibleExcludeDates;
-    }
-
-    public function addBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
-    {
-        if (!$this->billingIntangibleExcludeDates->contains($billingIntangibleExcludeDate)) {
-            $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
-            $billingIntangibleExcludeDate->setAccessFictionalIntangible($this);
-        }
-
-        return $this;
-    }
-
-    public function removeBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
-    {
-        if ($this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate)) {
-            // set the owning side to null (unless already changed)
-            if ($billingIntangibleExcludeDate->getAccessFictionalIntangible() === $this) {
-                $billingIntangibleExcludeDate->setAccessFictionalIntangible(null);
-            }
-        }
-
-        return $this;
-    }
-}

+ 1 - 1
src/Entity/Access/PersonalizedList.php

@@ -89,7 +89,7 @@ class PersonalizedList
         return $this->columns;
     }
 
-    public function setAccess(Access $access): self
+    public function setAccess(?Access $access): self
     {
         $this->access = $access;
         return $this;

+ 2 - 1
src/Entity/Billing/AccessIntangible.php

@@ -6,6 +6,7 @@ namespace App\Entity\Billing;
 use ApiPlatform\Metadata\ApiResource;
 use App\Entity\Access\Access;
 //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
+use App\Repository\Billing\AccessIntangibleRepository;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\ORM\Mapping as ORM;
 use Doctrine\Common\Collections\Collection;
@@ -15,7 +16,7 @@ use Doctrine\Common\Collections\Collection;
  */
 #[ApiResource]
 //#[Auditable]
-#[ORM\Entity(repositoryClass: AccessIntangible::class)]
+#[ORM\Entity(repositoryClass: AccessIntangibleRepository::class)]
 class AccessIntangible extends AbstractBillingIntangible
 {
     #[ORM\ManyToOne(inversedBy: 'accessIntangibles')]

+ 1 - 1
src/Entity/Billing/BergerLevrault.php

@@ -20,7 +20,7 @@ class BergerLevrault
     #[ORM\GeneratedValue]
     private ?int $id = null;
 
-    #[ORM\OneToMany(mappedBy: 'bergerLevrault', targetEntity: 'Bill', cascade: ['persist'], orphanRemoval: true)]
+    #[ORM\OneToMany(mappedBy: 'bergerLevrault', targetEntity: Bill::class, cascade: ['persist'], orphanRemoval: true)]
     private Collection $bills;
 
     public function __construct()

+ 5 - 0
src/Entity/Billing/BillAccessDetail.php

@@ -16,4 +16,9 @@ class BillAccessDetail
     #[ORM\Column]
     #[ORM\GeneratedValue]
     private ?int $id = null;
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
 }

+ 1 - 1
src/Entity/Billing/BillAccounting.php

@@ -75,7 +75,7 @@ class BillAccounting
     #[ORM\JoinTable(name: 'tag_billAccounting')]
     #[ORM\JoinColumn(name: 'billAccounting_id', referencedColumnName: 'id')]
     #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
-    protected $tags;
+    protected Collection $tags;
 
     public function __construct()
     {

+ 1 - 1
src/Entity/Billing/BillPayment.php

@@ -40,7 +40,7 @@ class BillPayment
     #[ORM\JoinTable(name: 'tag_billPayment')]
     #[ORM\JoinColumn(name: 'billPayment_id', referencedColumnName: 'id')]
     #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
-    private $tags;
+    private Collection $tags;
 
     public function __construct()
     {

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

@@ -48,7 +48,7 @@ class ResidenceArea
     #[ORM\GeneratedValue]
     private ?int $id = null;
 
-    #[ORM\ManyToOne(targetEntity: 'BillingSetting', inversedBy: 'residenceAreas')]
+    #[ORM\ManyToOne(targetEntity: BillingSetting::class, inversedBy: 'residenceAreas')]
     #[ORM\JoinColumn(nullable: false)]
     private BillingSetting $billingSetting;
 
@@ -77,18 +77,18 @@ class ResidenceArea
         return $this->label;
     }
 
-    public function setLabel(string $label)
+    public function setLabel(string $label): self
     {
         $this->label = $label;
         return $this;
     }
 
-    public function getBillingSetting(): BillingSetting
+    public function getBillingSetting(): ?BillingSetting
     {
         return $this->billingSetting;
     }
 
-    public function setBillingSetting(BillingSetting $billingSetting): self
+    public function setBillingSetting(?BillingSetting $billingSetting): self
     {
         $this->billingSetting = $billingSetting;
         return $this;

+ 0 - 36
src/Entity/Billing/SddBank.php

@@ -4,8 +4,6 @@ declare(strict_types=1);
 namespace App\Entity\Billing;
 
 //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
-use Doctrine\Common\Collections\ArrayCollection;
-use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
 
 /**
@@ -20,46 +18,12 @@ class SddBank
     #[ORM\GeneratedValue]
     private ?int $id = null;
 
-    #[ORM\OneToMany(mappedBy: 'sddBank',targetEntity: Bill::class,  orphanRemoval: true)]
-    private Collection $bills;
-
     public function __construct()
     {
-        $this->bills = new ArrayCollection();
     }
 
     public function getId(): ?int
     {
         return $this->id;
     }
-
-    /**
-     * @return Collection<int, Bill>
-     */
-    public function getBills(): Collection
-    {
-        return $this->bills;
-    }
-
-    public function addBill(Bill $bill): self
-    {
-        if (!$this->bills->contains($bill)) {
-            $this->bills[] = $bill;
-            $bill->setSddBank($this);
-        }
-
-        return $this;
-    }
-
-    public function removeBill(Bill $bill): self
-    {
-        if ($this->bills->removeElement($bill)) {
-            // set the owning side to null (unless already changed)
-            if ($bill->getSddBank() === $this) {
-                $bill->setSddBank(null);
-            }
-        }
-
-        return $this;
-    }
 }

+ 0 - 36
src/Entity/Billing/SddRegie.php

@@ -4,8 +4,6 @@ declare(strict_types=1);
 namespace App\Entity\Billing;
 
 //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
-use Doctrine\Common\Collections\ArrayCollection;
-use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
 
 /**
@@ -20,46 +18,12 @@ class SddRegie
     #[ORM\GeneratedValue]
     private ?int $id = null;
 
-    #[ORM\OneToMany(mappedBy: 'sddRegie',targetEntity: Bill::class,  orphanRemoval: true)]
-    private Collection $bills;
-
     public function __construct()
     {
-        $this->bills = new ArrayCollection();
     }
 
     public function getId(): ?int
     {
         return $this->id;
     }
-
-    /**
-     * @return Collection<int, Bill>
-     */
-    public function getBills(): Collection
-    {
-        return $this->bills;
-    }
-
-    public function addBill(Bill $bill): self
-    {
-        if (!$this->bills->contains($bill)) {
-            $this->bills[] = $bill;
-            $bill->setSddRegie($this);
-        }
-
-        return $this;
-    }
-
-    public function removeBill(Bill $bill): self
-    {
-        if ($this->bills->removeElement($bill)) {
-            // set the owning side to null (unless already changed)
-            if ($bill->getSddRegie() === $this) {
-                $bill->setSddRegie(null);
-            }
-        }
-
-        return $this;
-    }
 }

+ 2 - 2
src/Entity/Booking/Work.php

@@ -25,10 +25,10 @@ class Work
     private Course $course;
 
     #[ORM\OneToMany(mappedBy: 'work',targetEntity: WorkByUser::class,  cascade: ['persist'], orphanRemoval: true)]
-    private $workByUsers;
+    private Collection $workByUsers;
 
     #[ORM\OneToMany(mappedBy: 'work',targetEntity: File::class,  orphanRemoval: true)]
-    private $files;
+    private Collection $files;
 
     public function __construct()
     {

+ 1 - 1
src/Entity/Core/ContactPoint.php

@@ -96,7 +96,7 @@ class ContactPoint
     #[ORM\JoinTable(name: 'place_contactpoint')]
     #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
     #[ORM\InverseJoinColumn(name: 'place_id', referencedColumnName: 'id')]
-    private $place;
+    private Collection $place;
 
     #[Pure]
     public function __construct()

+ 1 - 1
src/Entity/Core/Notification.php

@@ -204,7 +204,7 @@ class Notification
         return $this->link;
     }
 
-    public function getAvailabilityDate(): ?string
+    public function getAvailabilityDate(): ?\DateTimeInterface
     {
         return $this->availabilityDate;
     }

+ 1 - 1
src/Entity/Education/Cycle.php

@@ -73,7 +73,7 @@ class Cycle
         return $this->id;
     }
 
-    public function setOrganization(Organization $organization): self
+    public function setOrganization(?Organization $organization): self
     {
         $this->organization = $organization;
         return $this;

+ 1 - 1
src/Entity/Education/Education.php

@@ -60,7 +60,7 @@ class Education
     #[ORM\JoinTable(name: 'tag_education')]
     #[ORM\JoinColumn(name: 'education_id', referencedColumnName: 'id')]
     #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
-    private $tags;
+    private Collection $tags;
 
     #[ORM\ManyToOne]
     #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]

+ 1 - 1
src/Entity/Education/EducationNotationConfig.php

@@ -85,7 +85,7 @@ class EducationNotationConfig
         return $this->id;
     }
 
-    public function setOrganization(Organization $organization): self
+    public function setOrganization(?Organization $organization): self
     {
         $this->organization = $organization;
         return $this;

+ 1 - 1
src/Entity/Education/EducationTiming.php

@@ -73,7 +73,7 @@ class EducationTiming
         return $this->id;
     }
 
-    public function setOrganization(Organization $organization): self
+    public function setOrganization(?Organization $organization): self
     {
         $this->organization = $organization;
         return $this;

+ 3 - 3
src/Entity/Message/AbstractMessage.php

@@ -23,7 +23,7 @@ abstract class AbstractMessage
     protected ?int $id = null;
 
     #[ORM\Column(type: 'string', unique: true)]
-    protected $uuid = null;
+    protected ?UuidInterface $uuid = null;
 
     #[ORM\ManyToOne]
     #[ORM\JoinColumn(nullable: true)]
@@ -86,7 +86,7 @@ abstract class AbstractMessage
         return html_entity_decode($this->text);
     }
 
-    public function setStatus(string $status)
+    public function setStatus(string $status): self
     {
         $this->status = $status;
 
@@ -99,7 +99,7 @@ abstract class AbstractMessage
     }
 
 
-    public function setDateSent(\DateTimeInterface $dateSent)
+    public function setDateSent(\DateTimeInterface $dateSent): self
     {
         $this->dateSent = $dateSent;
 

+ 23 - 1
src/Entity/Message/ReportSms.php

@@ -27,7 +27,7 @@ class ReportSms extends AbstractReport
     private string $mobile;
 
     #[ORM\Column(nullable: true)]
-    private $smsId;
+    private ?string $smsId;
 
     public function getId(): ?int
     {
@@ -45,4 +45,26 @@ class ReportSms extends AbstractReport
 
         return $this;
     }
+
+    public function setMobile(string $mobile): self
+    {
+        $this->mobile = $mobile;
+        return $this;
+    }
+
+    public function getMobile(): string
+    {
+        return $this->mobile;
+    }
+
+    public function setSmsId(string $smsId): self
+    {
+        $this->smsId = $smsId;
+        return $this;
+    }
+
+    public function getSmsId(): ?string
+    {
+        return $this->smsId;
+    }
 }

+ 1 - 1
src/Entity/Network/Network.php

@@ -54,7 +54,7 @@ class Network
         $this->organizations = new ArrayCollection();
     }
 
-    public function setId($id): self
+    public function setId(int $id): self
     {
         $this->id = $id;
         return $this;

+ 2 - 76
src/Entity/Organization/Organization.php

@@ -499,7 +499,7 @@ class Organization
     /**
      * @return File
      */
-    public function getLogo(): File
+    public function getLogo(): ?File
     {
         return $this->logo;
     }
@@ -507,7 +507,7 @@ class Organization
     /**
      * @param File $logo
      */
-    public function setLogo(File $logo): void
+    public function setLogo(?File $logo): void
     {
         $this->logo = $logo;
     }
@@ -1140,20 +1140,6 @@ class Organization
         return $this->subdomains;
     }
 
-    public function addSubdomain($subdomain): self
-    {
-        $subdomain->setOrganization($this);
-        $this->subdomains[] = $subdomain;
-        return $this;
-    }
-
-    public function removeSubdomain($subdomain): self
-    {
-        $subdomain->setOrganization(null);
-        $this->subdomains->removeElement($subdomain);
-        return $this;
-    }
-
     public function addAccess(Access $access): self
     {
         if (!$this->accesses->contains($access)) {
@@ -1473,26 +1459,6 @@ class Organization
         return $this->emails;
     }
 
-    public function addEmail(Email $email): self
-    {
-        if (!$this->emails->contains($email)) {
-            $this->emails[] = $email;
-            $email->setAuthor($this);
-        }
-        return $this;
-    }
-
-    public function removeEmail(Email $email): self
-    {
-        if ($this->emails->removeElement($email)) {
-            // set the owning side to null (unless already changed)
-            if ($email->getAuthor() === $this) {
-                $email->setAuthor(null);
-            }
-        }
-        return $this;
-    }
-
     /**
      * @return Collection<int, Mail>
      */
@@ -1501,26 +1467,6 @@ class Organization
         return $this->mails;
     }
 
-    public function addMail(Mail $mail): self
-    {
-        if (!$this->mails->contains($mail)) {
-            $this->mails[] = $mail;
-            $mail->setAuthor($this);
-        }
-        return $this;
-    }
-
-    public function removeMail(Mail $mail): self
-    {
-        if ($this->mails->removeElement($mail)) {
-            // set the owning side to null (unless already changed)
-            if ($mail->getAuthor() === $this) {
-                $mail->setAuthor(null);
-            }
-        }
-        return $this;
-    }
-
     /**
      * @return Collection<int, Sms>
      */
@@ -1529,26 +1475,6 @@ class Organization
         return $this->sms;
     }
 
-    public function addSms(Sms $sms): self
-    {
-        if (!$this->sms->contains($sms)) {
-            $this->sms[] = $sms;
-            $sms->setAuthor($this);
-        }
-        return $this;
-    }
-
-    public function removeSms(Sms $sms): self
-    {
-        if ($this->sms->removeElement($sms)) {
-            // set the owning side to null (unless already changed)
-            if ($sms->getAuthor() === $this) {
-                $sms->setAuthor(null);
-            }
-        }
-        return $this;
-    }
-
     /**
      * @return Collection<int, Activity>
      */

+ 1 - 1
src/Entity/Organization/OrganizationAddressPostal.php

@@ -76,7 +76,7 @@ class OrganizationAddressPostal
         return $this->organization;
     }
 
-    public function setOrganization(Organization $organization): self
+    public function setOrganization(?Organization $organization): self
     {
         $this->organization = $organization;
         return $this;

+ 2 - 2
src/Entity/Organization/OrganizationLicence.php

@@ -45,7 +45,7 @@ class OrganizationLicence
     {
         return $this->organization;
     }
-    public function setOrganization(Organization $organization) : self
+    public function setOrganization(?Organization $organization) : self
     {
         $this->organization = $organization;
         return $this;
@@ -54,7 +54,7 @@ class OrganizationLicence
     {
         return $this->licensee;
     }
-    public function setLicensee(Access $licensee) : self
+    public function setLicensee(?Access $licensee) : self
     {
         $this->licensee = $licensee;
         return $this;

+ 1 - 1
src/Entity/Organization/Parameters.php

@@ -232,7 +232,7 @@ class Parameters
         return $this->average;
     }
 
-    public function setAverage(int $average)
+    public function setAverage(int $average): self
     {
         $this->average = $average;
         return $this;

+ 1 - 1
src/Entity/Person/Person.php

@@ -175,7 +175,7 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
         // not needed when using the "bcrypt" algorithm in security.yaml
     }
 
-    public function eraseCredentials()
+    public function eraseCredentials(): void
     {
         // If you store any temporary, sensitive data on the user, clear it here
         // $this->plainPassword = null;

+ 1 - 1
src/Entity/Person/PersonAddressPostal.php

@@ -56,7 +56,7 @@ class PersonAddressPostal
         return $this->person;
     }
 
-    public function setPerson(Person $person): self
+    public function setPerson(?Person $person): self
     {
         $this->person = $person;
         return $this;

+ 1 - 1
src/Entity/Place/Room.php

@@ -37,7 +37,7 @@ class Room
     private ?int $id = null;
 
     #[ORM\ManyToOne(targetEntity: Place::class, inversedBy: 'rooms')]
-    private $place;
+    private Place $place;
 
     #[ORM\ManyToMany(targetEntity: ContactPoint::class)]
     private Collection $contactpoint;

+ 1 - 1
src/Enum/Access/FunctionEnum.php

@@ -68,7 +68,7 @@ class FunctionEnum extends Enum
 
     private const OTHER = 'OTHER';
 
-    public static function getOrganizationStaffAndBoardOfDirectorsMission(){
+    public static function getOrganizationStaffAndBoardOfDirectorsMission(): array{
         return [
             self::ACTIVE_MEMBER_OF_THE_CA,
             self::HONORARY_PRESIDENT,

+ 21 - 9
src/EventListener/DoctrineFilter/DoctrineFilterListener.php

@@ -3,12 +3,16 @@ declare(strict_types=1);
 
 namespace App\EventListener\DoctrineFilter;
 
+use App\Entity\Access\Access;
+use App\Filter\DoctrineFilter\ActivityYearFilter;
+use App\Filter\DoctrineFilter\DateTimeFilter;
 use App\Service\Constraint\ActivityYearConstraint;
 use App\Service\Constraint\DateTimeConstraint;
 use Doctrine\ORM\EntityManagerInterface;
 use Symfony\Component\HttpFoundation\RequestStack;
 use Symfony\Component\HttpKernel\Event\RequestEvent;
 use Symfony\Bundle\SecurityBundle\Security;
+use Symfony\Component\Security\Core\User\UserInterface;
 
 /**
  * Classe DoctrineFilterListener qui permet d'assurer l'injection de dépendance pour le SQL Filter
@@ -25,20 +29,28 @@ class DoctrineFilterListener
     {
     }
 
-    public function onKernelRequest(RequestEvent $event)
+    public function onKernelRequest(RequestEvent $event): void
     {
         if (!$event->isMainRequest()) {
             // don't do anything if it's not the main request
             return;
         }
-        $dateTimeFilter = $this->entityManager->getFilters()->getFilter('date_time_filter');
-        $dateTimeFilter->setParameter('accessId', $this->security->getUser()?->getId() ?? null);
-        $dateTimeFilter->setParameter('_time_constraint', $this->requestStack->getMainRequest()->get('_time_constraint', true));
-        $dateTimeFilter->setDateTimeConstraint($this->dateTimeConstraint);
 
-        $activityYearFilter = $this->entityManager->getFilters()->getFilter('activity_year_filter');
-        $activityYearFilter->setParameter('accessId', $this->security->getUser()?->getId() ?? null);
-        $activityYearFilter->setParameter('_time_constraint', $this->requestStack->getMainRequest()->get('_time_constraint', true));
-        $activityYearFilter->setActivityYearConstraint($this->activityYearConstraint);
+        /** @var Access $access */
+        $access = $this->security->getUser();
+
+        if($access){
+            /** @var DateTimeFilter $dateTimeFilter */
+            $dateTimeFilter = $this->entityManager->getFilters()->getFilter('date_time_filter');
+            $dateTimeFilter->setParameter('accessId', $access->getId());
+            $dateTimeFilter->setParameter('_time_constraint', $this->requestStack->getMainRequest()->get('_time_constraint', true));
+            $dateTimeFilter->setDateTimeConstraint($this->dateTimeConstraint);
+
+            /** @var ActivityYearFilter $activityYearFilter */
+            $activityYearFilter = $this->entityManager->getFilters()->getFilter('activity_year_filter');
+            $activityYearFilter->setParameter('accessId', $access->getId());
+            $activityYearFilter->setParameter('_time_constraint', $this->requestStack->getMainRequest()->get('_time_constraint', true));
+            $activityYearFilter->setActivityYearConstraint($this->activityYearConstraint);
+        }
     }
 }

+ 3 - 3
src/EventSubscriber/ElasticaPostTransformSubscriber.php

@@ -37,7 +37,7 @@ final class ElasticaPostTransformSubscriber implements EventSubscriberInterface
      * Evénement se passant avant l'update d'un index ES
      * @param TransformEvent $event
      */
-    public function doPreTransform(TransformEvent $event)
+    public function doPreTransform(TransformEvent $event): void
     {
 
     }
@@ -46,7 +46,7 @@ final class ElasticaPostTransformSubscriber implements EventSubscriberInterface
      * Evénement se passant après l'update d'un index ES
      * @param TransformEvent $event
      */
-    public function doPostTransform(TransformEvent $event)
+    public function doPostTransform(TransformEvent $event): void
     {
         $document = $event->getDocument();
         $object = $event->getObject();
@@ -61,7 +61,7 @@ final class ElasticaPostTransformSubscriber implements EventSubscriberInterface
      * @param $document
      * @param $object
      */
-    private function educationNotationTransform($document, EducationNotation $educationNotation){
+    private function educationNotationTransform(mixed $document, EducationNotation $educationNotation): void{
         $document->set('note_origine', $this->educationNotationUtils->getNotationOriginal($educationNotation));
         $document->set('note_recalcul', $this->educationNotationUtils->getNotationTransformed($educationNotation));
     }

+ 2 - 2
src/Filter/DoctrineFilter/AbstractTimeFilter.php

@@ -43,11 +43,11 @@ abstract class AbstractTimeFilter extends SQLFilter
 
     /**
      * Fonction retournant la valeur arithmétique correspondant à la condition de la contrainte
-     * @param $condition
+     * @param DateTimeConstraint $condition
      * @return string|null
      * @see DateTimeFilterTest::testGetArithmeticValue()
      */
-    protected function getArithmeticValue($condition): ?string
+    protected function getArithmeticValue(DateTimeConstraint $condition): ?string
     {
         switch ($condition){
             case DateTimeConstraint::INF : return '<';

+ 1 - 1
src/Filter/DoctrineFilter/ActivityYearFilter.php

@@ -54,7 +54,7 @@ final class ActivityYearFilter extends AbstractTimeFilter
      * @param ActivityYearConstraint $activityYearConstraint
      *
      */
-    public function setActivityYearConstraint(ActivityYearConstraint $activityYearConstraint){
+    public function setActivityYearConstraint(ActivityYearConstraint $activityYearConstraint): void{
         $this->activityYearConstraint = $activityYearConstraint;
     }
 }

+ 1 - 1
src/Filter/DoctrineFilter/DateTimeFilter.php

@@ -52,7 +52,7 @@ final class DateTimeFilter extends AbstractTimeFilter
      * Permets d'assurer l'injection de dépendance du service DateTimeConstraint
      * @param DateTimeConstraint $dateTimeConstraint
      */
-    public function setDateTimeConstraint(DateTimeConstraint $dateTimeConstraint){
+    public function setDateTimeConstraint(DateTimeConstraint $dateTimeConstraint): void{
         $this->dateTimeConstraint = $dateTimeConstraint;
     }
 }

+ 1 - 1
src/Filter/Person/FullNameFilter.php

@@ -10,7 +10,7 @@ use Doctrine\ORM\QueryBuilder;
 
 class FullNameFilter extends AbstractFilter {
     protected function filterProperty(string $property,
-                                             $value,
+                                      mixed $value,
                                       QueryBuilder $queryBuilder,
                                       QueryNameGeneratorInterface $queryNameGenerator,
                                       string $resourceClass,

+ 1 - 1
src/Filter/Utils/DistanceFilter.php

@@ -53,7 +53,7 @@ final class DistanceFilter extends AbstractFilter
     }
 
     protected function filterProperty(string $property,
-                                      $value,
+                                      mixed $value,
                                       QueryBuilder $queryBuilder,
                                       QueryNameGeneratorInterface $queryNameGenerator,
                                       string $resourceClass,

+ 1 - 1
src/Filter/Utils/FindInSetFilter.php

@@ -11,7 +11,7 @@ use Symfony\Component\PropertyInfo\Type;
 
 final class FindInSetFilter extends AbstractFilter {
     protected function filterProperty(string $property,
-                                             $value,
+                                      mixed $value,
                                       QueryBuilder $queryBuilder,
                                       QueryNameGeneratorInterface $queryNameGenerator,
                                       string $resourceClass,

+ 1 - 1
src/Filter/Utils/InFilter.php

@@ -14,7 +14,7 @@ use Symfony\Component\PropertyInfo\Type;
  */
 final class InFilter extends AbstractFilter {
     protected function filterProperty(string $property,
-                                             $value,
+                                      mixed $value,
                                       QueryBuilder $queryBuilder,
                                       QueryNameGeneratorInterface $queryNameGenerator,
                                       string $resourceClass,

+ 1 - 1
src/Message/Command/Parameters/AverageChange.php

@@ -11,7 +11,7 @@ class AverageChange
     public function __construct(private int $parametersId)
     { }
 
-    public function getParametersId(){
+    public function getParametersId(): int{
         // Todo: penser à ajouter cette commande à la section routing du fichier config/packages/messenger.yaml
         return $this->parametersId;
     }

+ 1 - 1
src/Message/Handler/ExportHandler.php

@@ -20,7 +20,7 @@ class ExportHandler
         private Notifier $notifier
     ) {}
 
-    public function __invoke(Export $export)
+    public function __invoke(Export $export): void
     {
         $exportRequest = $export->getExportRequest();
         $exportService = $this->handler->getExporterFor($exportRequest);

+ 1 - 1
src/Message/Handler/MailerHandler.php

@@ -22,7 +22,7 @@ class MailerHandler
     {
     }
 
-    public function __invoke(MailerCommand $mailerCommand)
+    public function __invoke(MailerCommand $mailerCommand): void
     {
         $mailerModel = $mailerCommand->getMailerModel();
         $emails = $this->mailer->main($mailerModel);

+ 1 - 1
src/Message/Handler/Parameters/AverageChangeHandler.php

@@ -25,7 +25,7 @@ class AverageChangeHandler
      * Fonction permettant de remettre à jour les notes dans elasticsearch par rapport à la note maximale changée
      * @param AverageChange $averageChange
      */
-    public function __invoke(AverageChange $averageChange)
+    public function __invoke(AverageChange $averageChange): void
     {
         $parameter = $this->parametersRepository->find($averageChange->getParametersId());
         if($parameter){

+ 1 - 1
src/Message/Handler/Typo3/Typo3DeleteCommandHandler.php

@@ -16,7 +16,7 @@ class Typo3DeleteCommandHandler
     /**
      * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
      */
-    public function __invoke(Typo3DeleteCommand $command) {
+    public function __invoke(Typo3DeleteCommand $command): void {
         $this->typo3Service->deleteSite($command->getOrganizationId());
     }
 }

+ 1 - 1
src/Message/Handler/Typo3/Typo3UndeleteCommandHandler.php

@@ -16,7 +16,7 @@ class Typo3UndeleteCommandHandler
     /**
      * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
      */
-    public function __invoke(Typo3UndeleteCommand $command) {
+    public function __invoke(Typo3UndeleteCommand $command): void {
         $this->typo3Service->undeleteSite($command->getOrganizationId());
     }
 }

+ 1 - 1
src/Message/Handler/Typo3/Typo3UpdateCommandHandler.php

@@ -16,7 +16,7 @@ class Typo3UpdateCommandHandler
     /**
      * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
      */
-    public function __invoke(Typo3UpdateCommand $command) {
+    public function __invoke(Typo3UpdateCommand $command): void {
         $this->typo3Service->updateSite($command->getOrganizationId());
     }
 }

+ 1 - 1
src/OpenApi/OpenApiFactory.php

@@ -18,7 +18,7 @@ final class OpenApiFactory implements OpenApiFactoryInterface
         '/api/dolibarr_contracts/{ref}',
     ];
 
-    private $decorated;
+    private mixed $decorated;
 
     public function __construct(OpenApiFactoryInterface $decorated)
     {

+ 15 - 6
src/Repository/Access/AccessRepository.php

@@ -6,6 +6,7 @@ namespace App\Repository\Access;
 use App\DQL\DateConditions;
 use App\Entity\Access\Access;
 use App\Entity\Organization\Organization;
+use App\Enum\Access\FunctionEnum;
 use DateTime;
 use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
 use Doctrine\Persistence\ManagerRegistry;
@@ -40,17 +41,17 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
         if($this->requestStack->getMainRequest()->headers->get(self::HTTP_X_SWITCH_USER) === $identifier)
             return $this->getEntityManager()->find(Access::class, $identifier);
 
-        return $this->findAccessByUsernameAndAccessId($identifier, $this->requestStack->getMainRequest()->headers->get(self::ACCESS_NAME_HEADER));
+        return $this->findAccessByUsernameAndAccessId($identifier, (int) $this->requestStack->getMainRequest()->headers->get(self::ACCESS_NAME_HEADER));
     }
 
     /**
      * Récupère un access grâce à son username et son ID
      * @param string $username
-     * @param $id
+     * @param int $id
      * @return mixed
      * @throws \Doctrine\ORM\NonUniqueResultException
      */
-    private function findAccessByUsernameAndAccessId(string $username, $id): mixed
+    private function findAccessByUsernameAndAccessId(string $username, int $id): mixed
     {
         $entityManager = $this->getEntityManager();
         return $entityManager->createQuery(
@@ -65,6 +66,7 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
     }
 
     /**
+     * Retourne tous les access qui appartiennent à une organisation qui est active dans un réseau
      * @param Access $access
      * @return mixed
      * @throws \Exception
@@ -86,7 +88,14 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
       ;
     }
 
-    public function hasGotFunctionAtThisDate(Access $access, $function, \DateTime $date): bool
+    /**
+     * Retoune si oui ou non un access possède une fonction F active à une date précise
+     * @param Access $access
+     * @param FunctionEnum $function
+     * @param DateTime $date
+     * @return bool
+     */
+    public function hasGotFunctionAtThisDate(Access $access, FunctionEnum $function, \DateTime $date): bool
     {
         $this->_em->getFilters()->disable('date_time_filter');
 
@@ -112,11 +121,11 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
      * Retourne tous les accesses de l'organization ayant la fonction donnée à la date donnée
      *
      * @param Organization $organization
-     * @param $function
+     * @param FunctionEnum $function
      * @param DateTime|null $date
      * @return array
      */
-    public function findByOrganizationAndMission(Organization $organization, $function, \DateTime $date = null): array
+    public function findByOrganizationAndMission(Organization $organization, FunctionEnum $function, \DateTime $date = null): array
     {
         if ($date === null)
             $date = new DateTime();

+ 1 - 1
src/Security/Voter/BankAccountVoter.php

@@ -15,7 +15,7 @@ class BankAccountVoter extends Voter
     public function __construct(private Security $security)
     { }
 
-    protected function supports($attribute, $subject): bool
+    protected function supports(string $attribute, $subject): bool
     {
         return in_array($attribute, ['BANK_ACCOUNT_READ', 'BANK_ACCOUNT_EDIT', 'BANK_ACCOUNT_DELETE'])
             && $subject instanceof BankAccount;

+ 1 - 1
src/Security/Voter/ContactPointVoter.php

@@ -15,7 +15,7 @@ class ContactPointVoter extends Voter
     public function __construct(private Security $security)
     { }
 
-    protected function supports($attribute, $subject): bool
+    protected function supports(string $attribute, $subject): bool
     {
         return in_array($attribute, ['CONTACT_POINT_READ', 'CONTACT_POINT_EDIT', 'CONTACT_POINT_DELETE'])
             && $subject instanceof ContactPoint;

+ 1 - 1
src/Security/Voter/CotisationVoter.php

@@ -18,7 +18,7 @@ class CotisationVoter extends Voter
         private NetworkUtils $networkUtils)
     { }
 
-    protected function supports($attribute, $subject): bool
+    protected function supports(string $attribute, $subject): bool
     {
         return in_array($attribute, ['COTISATION_CALL']) && $subject instanceof Cotisation;
     }

+ 2 - 1
src/Security/Voter/ModuleVoter.php

@@ -40,13 +40,14 @@ class ModuleVoter extends Voter
      */
     protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
     {
-        if (!$subject->attributes->get('_api_resource_class') || !$resourceMetadata = $this->resourceMetadataFactory->create($subject->attributes->get('_api_resource_class'))) {
+        if (!$subject->attributes->get('_api_resource_class')) {
             throw new AccessDeniedHttpException(sprintf('Missing resource class'));
         }
         if ($token instanceof NullToken) {
             return false;
         }
 
+        $resourceMetadata = $this->resourceMetadataFactory->create($subject->attributes->get('_api_resource_class'));
         $module = $this->module->getModuleByResourceName($resourceMetadata->getOperation()->getShortName());
 
         //Check if there is a module for this entity : eq configuration problem

+ 3 - 1
src/Security/Voter/SwitchUserVoter.php

@@ -3,6 +3,7 @@ declare(strict_types=1);
 
 namespace App\Security\Voter;
 
+use App\Entity\Access\Access;
 use App\Service\Security\SwitchUser;
 use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
 use Symfony\Component\Security\Core\Authorization\Voter\Voter;
@@ -14,7 +15,7 @@ class SwitchUserVoter extends Voter
     public function __construct(private Security $security, private SwitchUser $switchUser)
     { }
 
-    protected function supports($attribute, $subject): bool
+    protected function supports(string $attribute, $subject): bool
     {
         return in_array($attribute, ['CAN_SWITCH_USER'])
             && $subject instanceof UserInterface;
@@ -28,6 +29,7 @@ class SwitchUserVoter extends Voter
      */
     protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
     {
+        /** @var Access $user */
         $user = $token->getUser();
 
         // if the user is anonymous or if the subject is not a user, do not grant access

+ 3 - 1
src/Serializer/AccessContextBuilder.php

@@ -29,11 +29,13 @@ final class AccessContextBuilder implements SerializerContextBuilderInterface
 
         //On ajoute un nouveau groupe seulement si : la ressource est Access, on est en denormalization, l'utilisateur n'a pas le ROLE_USERS
         //et la denormalization est faite sur l'Access de l'utilisateur connecté
+        /** @var Access $access */
+        $access = $this->security->getUser();
         if (
             $resourceClass === Access::class &&
             false === $normalization &&
             !$this->authorizationChecker->isGranted('ROLE_USERS') &&
-            $request->get('id') == $this->security->getUser()->getId()
+            (int) $request->get('id') === $access->getId()
         ){
             $context['groups'] = $context['groups'] ?? [];
             $context['groups'][] = 'my_access:input';

+ 3 - 1
src/Serializer/DefaultNormalizer.php

@@ -39,11 +39,13 @@ final class DefaultNormalizer implements NormalizerInterface, DenormalizerInterf
 
     public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
     {
+        /** @phpstan-ignore-next-line */
         return $this->decorated->supportsDenormalization($data, $type, $format);
     }
 
     public function denormalize($data, $class, $format = null, array $context = []): mixed
     {
+        /** @phpstan-ignore-next-line */
         $entity = $this->decorated->denormalize($data, $class, $format, $context);
 
         /** @var Access $access */
@@ -53,7 +55,7 @@ final class DefaultNormalizer implements NormalizerInterface, DenormalizerInterf
         return $entity;
     }
 
-    public function setSerializer(SerializerInterface $serializer)
+    public function setSerializer(SerializerInterface $serializer): void
     {
         if($this->decorated instanceof SerializerAwareInterface) {
             $this->decorated->setSerializer($serializer);

+ 9 - 3
src/Service/ApiLegacy/ApiLegacyRequestService.php

@@ -2,6 +2,7 @@
 
 namespace App\Service\ApiLegacy;
 
+use App\Entity\Access\Access;
 use App\Service\Rest\ApiRequestService;
 use JetBrains\PhpStorm\Pure;
 use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
@@ -51,18 +52,23 @@ class ApiLegacyRequestService extends ApiRequestService
             'Content-Type' => 'application/ld+json',
         ];
 
+        /** @var Access $activeUser */
+        $activeUser = $token->getUser();
+
         if ($token instanceof SwitchUserToken) {
+            /** @var Access|null $originalUser */
             $originalUser = $token->getOriginalToken()->getUser();
+
             if ($originalUser === null) {
                 throw new HttpException(500, 'Request error : Switch original user missing');
             }
 
             $jwt = $this->jwtManager->create($originalUser->getPerson());
             $headers['x-accessid'] = $originalUser->getId();
-            $headers['x-switch-access'] = $token->getUser()->getId();
+            $headers['x-switch-access'] = $activeUser->getId();
         } else {
-            $jwt = $this->jwtManager->create($token->getUser()->getPerson());
-            $headers['x-accessid'] = $token->getUser()->getId();
+            $jwt = $this->jwtManager->create($activeUser->getPerson());
+            $headers['x-accessid'] = $activeUser->getId();
         }
 
         $headers['authorization'] = 'BEARER ' . $jwt;

+ 2 - 2
src/Service/Constraint/AbstractTimeConstraintUtils.php

@@ -19,11 +19,11 @@ abstract class AbstractTimeConstraintUtils
 
     /**
      * Retourne true si l'utilisateur veux une période précise
-     * @param $historical
+     * @param array<string> $historical
      * @return bool
      * @see DateTimeConstraintTest::testHasCustomPeriods()
      */
-    protected function hasCustomPeriods($historical): bool
+    protected function hasCustomPeriods(array $historical): bool
     {
         return array_key_exists('dateStart', $historical) && $historical['dateStart'] && array_key_exists('dateEnd', $historical) && $historical['dateEnd'];
     }

+ 7 - 7
src/Service/Constraint/ActivityYearConstraint.php

@@ -53,7 +53,7 @@ class ActivityYearConstraint extends AbstractTimeConstraintUtils
      * @param Access $access
      * @param string $dateStart
      * @param string $dateEnd
-     * @return string[]
+     * @return int[]
      */
     protected function getRangeYear(Access $access, string $dateStart, string $dateEnd): array
     {
@@ -82,10 +82,10 @@ class ActivityYearConstraint extends AbstractTimeConstraintUtils
     /**
      * Une période est dans le passée si :
      * - l'année de début est plus petite (<) à l'année à afficher
-     * @param $year
+     * @param int $year
      * @return array
      */
-    protected function pastConstraint($year): array
+    protected function pastConstraint(int $year): array
     {
         return [
             self::END_KEY => [
@@ -97,10 +97,10 @@ class ActivityYearConstraint extends AbstractTimeConstraintUtils
     /**
      * Une période est dans le futur si :
      * - l'année de début est plus grande (>) à l'année à afficher
-     * @param $year
+     * @param int $year
      * @return array
      */
-    protected function futureConstraint($year): array
+    protected function futureConstraint(int $year): array
     {
         return [
             self::START_KEY => [
@@ -115,10 +115,10 @@ class ActivityYearConstraint extends AbstractTimeConstraintUtils
      * - l'année de début est plus grande ou égale (>=) à l'année de départ
      * - l'année de début est plus petite ou égale (<=) à l'année de fin
      *
-     * @param $years
+     * @param array<int> $years
      * @return array
      */
-    protected function customConstraint($years): array
+    protected function customConstraint(array $years): array
     {
         return [
             self::START_KEY => [

+ 4 - 4
src/Service/Constraint/DateTimeConstraint.php

@@ -117,11 +117,11 @@ class DateTimeConstraint extends AbstractTimeConstraintUtils
     /**
      * Une période est dans le passé si :
      * - la date de fin est plus petite (<) que la date de début de période à afficher
-     * @param $periods
+     * @param array<string> $periods
      * @return array
      * @see DateTimeConstraintTest::testPastConstrain()
      */
-    protected function pastConstraint($periods): array
+    protected function pastConstraint(array $periods): array
     {
         return [
             self::END_KEY => [
@@ -133,11 +133,11 @@ class DateTimeConstraint extends AbstractTimeConstraintUtils
     /**
      * Une période est dans le futur si :
      * - la date de début est plus grande (>) que la date de fin de période à afficher
-     * @param $periods
+     * @param array<string> $periods
      * @return array
      * @see DateTimeConstraintTest::testFuturConstrain()
      */
-    protected function futureConstraint($periods): array
+    protected function futureConstraint(array $periods): array
     {
         return [
             self::START_KEY => [

+ 0 - 1
src/Service/Cotisation/Utils.php

@@ -114,7 +114,6 @@ class Utils
 
     /**
      * Retourne dans quelle année de cotisation on est aujourd'hui
-     * @param \DateTime|null $date
      * @return int
      * @throws \Exception
      * @see UtilsTest::testGetCurrentCotisationYear()

+ 5 - 5
src/Service/Cron/Job/CleanTempFiles.php

@@ -105,11 +105,11 @@ class CleanTempFiles extends BaseCronJob implements CronjobInterface
 
         $criteria = new Criteria();
         $criteria->where(
-            Criteria::expr()?->andX(
-                Criteria::expr()?->eq('isTemporaryFile', true),
-                Criteria::expr()?->orX(
-                    Criteria::expr()?->lt('createDate', $maxDate),
-                    Criteria::expr()?->isNull('createDate')
+            Criteria::expr()->andX(
+                Criteria::expr()->eq('isTemporaryFile', true),
+                Criteria::expr()->orX(
+                    Criteria::expr()->lt('createDate', $maxDate),
+                    Criteria::expr()->isNull('createDate')
                 )
             )
         );

+ 11 - 11
src/Service/Dolibarr/DolibarrSyncService.php

@@ -71,10 +71,10 @@ class DolibarrSyncService
      *
      * Returns an array of DolibarrSyncOperations
      *
+     * @param callable | null $progressionCallback A callback method for indicating the current progression of the process;
+     *                                           Shall accept two integer arguments: current progression, and total.
      * @return array<BaseRestOperation>
      * @throws Exception
-     * @var callable | null $progressionCallback A callback method for indicating the current progression of the process;
-     *                                           Shall accept two integer arguments: current progression, and total.
      *
      * @noinspection NullPointerExceptionInspection
      */
@@ -233,8 +233,8 @@ class DolibarrSyncService
                     'lastname' => trim($person->getName()),
                     'firstname' => trim($person->getGivenName()),
                     'email' => $contact?->getEmail(),
-                    'phone_pro' => $contact?->getTelphone() ? $this->formatPhoneNumber($contact?->getTelphone()) : null,
-                    'phone_mobile' => $contact?->getMobilPhone() ? $this->formatPhoneNumber($contact?->getMobilPhone()): null,
+                    'phone_pro' => $contact?->getTelphone() ? $this->formatPhoneNumber($contact->getTelphone()) : null,
+                    'phone_mobile' => $contact?->getMobilPhone() ? $this->formatPhoneNumber($contact->getMobilPhone()): null,
                     'poste' => $this->formatContactPosition($missions, $person->getGender()),
                     'statut' => '1'
                 ];
@@ -318,10 +318,10 @@ class DolibarrSyncService
      * Returns an array of DolibarrSyncOperations
      *
      * @param array<BaseRestOperation> $operations
+     * @param callable | null $progressionCallback A callback method for indicating the current progression of the process;
+     *                                           Shall accept two integer arguments: current progression, and total.
      * @return array<BaseRestOperation>
      * @throws Exception
-     *@var callable | null $progressionCallback A callback method for indicating the current progression of the process;
-     *                                           Shall accept two integer arguments: current progression, and total.
      */
     public function execute(array $operations, ?callable $progressionCallback = null): array
     {
@@ -361,7 +361,7 @@ class DolibarrSyncService
                     try {
                         $this->validateResponse($response, $operation);
                     } catch (RuntimeException $e) {
-                        $this->logger->warning($e);
+                        $this->logger->warning($e->getMessage());
                     }
                 }
 
@@ -369,7 +369,7 @@ class DolibarrSyncService
             } catch (RuntimeException $e) {
                 $this->logger->error('Error while executing operation : ' . $operation);
                 $this->logger->error(implode("\n", $operation->getChangeLog()));
-                $this->logger->error($e);
+                $this->logger->error($e->getMessage());
                 $errors++;
             }
 
@@ -488,8 +488,8 @@ class DolibarrSyncService
                 !($contactData["array_options"]["options_2iopen_person_id"] ?? null) &&
                 $person->getName() !== null &&
                 $person->getGivenName() !== null &&
-                strtolower($person->getName() ?? '') === strtolower($contactData["lastname"] ?? '') &&
-                strtolower($person->getGivenName() ?? '') === strtolower($contactData["firstname"] ?? '')
+                strtolower($person->getName()) === strtolower($contactData["lastname"] ?? '') &&
+                strtolower($person->getGivenName()) === strtolower($contactData["firstname"] ?? '')
             ) {
                 return $contactData;
             }
@@ -733,7 +733,7 @@ class DolibarrSyncService
      * In the case of a validation error, throw an HttpException
      *
      * @param ResponseInterface $response
-     * @param BaseRestOperation $operation
+     * @param UpdateOperation | CreateOperation  $operation
      * @throws RuntimeException
      */
     protected function validateResponse(ResponseInterface $response, UpdateOperation | CreateOperation $operation): void

+ 1 - 1
src/Service/Elasticsearch/EducationNotationUpdater.php

@@ -18,7 +18,7 @@ class EducationNotationUpdater
      * Effectue le replace many des educations notations
      * @param $educationNotations
      */
-    public function update(array $educationNotations){
+    public function update(array $educationNotations): void{
         $this->objectPersisterEducationNotation->replaceMany($educationNotations);
     }
 }

+ 1 - 1
src/Service/Export/Encoder/EncoderInterface.php

@@ -7,5 +7,5 @@ interface EncoderInterface
 {
     public function support(string $format): bool;
 
-    public function encode(string $html, array $options = []);
+    public function encode(string $html, array $options = []): string;
 }

+ 1 - 1
src/Service/Export/LicenceCmfExporter.php

@@ -75,7 +75,7 @@ class LicenceCmfExporter extends BaseExporter
 
         $cmf = $this->organizationRepository->find(self::CMF_ID);
         /** @noinspection NullPointerExceptionInspection */
-        $qrCode = $cmf->getParameters()?->getQrCode();
+        $qrCode = $cmf->getParameters()->getQrCode();
         if ($qrCode) {
             $licenceCmf->setQrCode($qrCode);
         }

+ 1 - 1
src/Service/Export/Model/LicenceCmf.php

@@ -42,7 +42,7 @@ class LicenceCmf implements ExportModelInterface
 
     /**
      * Name of the federation
-     * @var string|null
+     * @var string
      */
     private string $federationName;
 

+ 6 - 1
src/Service/File/FileManager.php

@@ -7,6 +7,7 @@ use ApiPlatform\Api\IriConverterInterface;
 use ApiPlatform\Api\UrlGeneratorInterface;
 use ApiPlatform\Metadata\Get;
 use App\ApiResources\DownloadRequest;
+use App\Entity\Access\Access;
 use App\Entity\Core\File;
 use App\Enum\Core\FileHostEnum;
 use App\Service\File\Exception\FileNotFoundException;
@@ -60,7 +61,11 @@ class FileManager
     {
         $storage = $this->getStorageFor($file);
         if ($storage instanceof ApiLegacyStorage && $token instanceof SwitchUserToken) {
-            $storage->setSwitchAccount($token->getOriginalToken()->getUser()->getId(), $token->getUser()->getId());
+            /** @var Access $originalAccess */
+            $originalAccess = $token->getOriginalToken()->getUser();
+            /** @var Access $activeAccess */
+            $activeAccess = $token->getUser();
+            $storage->setSwitchAccount($originalAccess->getId(), $activeAccess->getId());
         }
         return $storage->read($file);
     }

+ 1 - 1
src/Service/File/Storage/ApiLegacyStorage.php

@@ -27,7 +27,7 @@ class ApiLegacyStorage implements FileStorageInterface
     {
     }
 
-    public function setSwitchAccount(int $originalAccessId, int $asAccessId) {
+    public function setSwitchAccount(int $originalAccessId, int $asAccessId): void {
         $this->originalAccessId = $originalAccessId;
         $this->asAccessId = $asAccessId;
     }

+ 2 - 2
src/Service/File/Storage/LocalStorage.php

@@ -15,7 +15,7 @@ use App\Service\Utils\Path;
 use App\Service\Utils\Uuid;
 use DateTime;
 use Doctrine\ORM\EntityManagerInterface;
-use Gaufrette\Filesystem;
+use Gaufrette\FilesystemInterface;
 use JetBrains\PhpStorm\Pure;
 use Knp\Bundle\GaufretteBundle\FilesystemMap;
 use RuntimeException;
@@ -30,7 +30,7 @@ class LocalStorage implements FileStorageInterface
      */
     protected const FS_KEY = 'storage';
 
-    protected Filesystem $filesystem;
+    protected FilesystemInterface $filesystem;
 
     public function __construct(
         protected FilesystemMap $filesystemMap,

+ 7 - 11
src/Service/Mailer/Builder/AbstractBuilder.php

@@ -41,25 +41,21 @@ class AbstractBuilder implements AbstractBuilderInterface
      */
     public function buildEmailEntity(string $subject, Access $author, string $content): EmailEntity
     {
-        return (new EmailEntity())
+        $emailEntity = new EmailEntity();
+        $emailEntity
             ->setAuthor($author)
-            ->setAbout($subject)
             ->setIsSystem(true)
+            ->setAbout($subject)
             ->setDateSent(new \DateTime('now'))
             ->setText($content)
             ;
+        return $emailEntity;
     }
 
     /**
      * @param string $template
      * @param array $context
      * @return string
-     * @throws \Twig\Error\LoaderError
-     * @throws \Twig\Error\RuntimeError
-     * @throws \Twig\Error\SyntaxError
-     * @throws \Twig_Error_Loader
-     * @throws \Twig_Error_Runtime
-     * @throws \Twig_Error_Syntax
      *
      * @see AbstractBuilderTest::testRender()
      */
@@ -112,12 +108,12 @@ class AbstractBuilder implements AbstractBuilderInterface
     }
 
     /**
-     * @param $contactPoints
-     * @return mixed
+     * @param array<ContactPoint> $contactPoints
+     * @return ContactPoint|null
      *
      * @see AbstractBuilderTest::testGetFirstContactPointWithEmail()
      */
-    public function getFirstContactPointWithEmail($contactPoints): mixed
+    public function getFirstContactPointWithEmail(array $contactPoints): ?ContactPoint
     {
         $find = false;
         $cmpt = 0;

+ 4 - 3
src/Service/Mailer/Builder/AbstractBuilderInterface.php

@@ -4,14 +4,15 @@ declare(strict_types=1);
 namespace App\Service\Mailer\Builder;
 
 use App\Entity\Access\Access;
+use App\Entity\Message\Email as EmailEntity;
 use App\Entity\Organization\Organization;
 use App\Service\Mailer\Email;
 
 interface AbstractBuilderInterface {
 
-    public function render(string $template, array $context);
+    public function render(string $template, array $context): string;
 
-    public function buildEmailEntity(string $subject, Access $author, string $content);
+    public function buildEmailEntity(string $subject, Access $author, string $content): EmailEntity;
 
-    public function addRecipient(Email $email, Access|Organization|string $target, string $sendType, string $contactPointType = null);
+    public function addRecipient(Email $email, Access|Organization|string $target, string $sendType, string $contactPointType = null): void;
 }

+ 2 - 1
src/Service/Mailer/Builder/BuilderInterface.php

@@ -4,9 +4,10 @@ declare(strict_types=1);
 namespace App\Service\Mailer\Builder;
 
 use App\Service\Mailer\Model\MailerModelInterface;
+use Doctrine\Common\Collections\ArrayCollection;
 
 interface BuilderInterface extends AbstractBuilderInterface {
     public function support(MailerModelInterface $mailerModel): bool;
 
-    public function build(MailerModelInterface $mailerModel);
+    public function build(MailerModelInterface $mailerModel): ArrayCollection;
 }

+ 1 - 1
src/Service/Mailer/Email.php

@@ -9,7 +9,7 @@ use Doctrine\Common\Collections\ArrayCollection;
 /**
  * Classe Email qui contient les informations nécessaire pour assurer l'envoie d'un mail
  */
-class Email implements EmailInterface
+class Email
 {
     private string $from;
     private string $fromName;

+ 0 - 7
src/Service/Mailer/EmailInterface.php

@@ -1,7 +0,0 @@
-<?php
-declare(strict_types=1);
-
-namespace App\Service\Mailer;
-
-interface EmailInterface{
-}

+ 8 - 5
src/Service/Mailer/Mailer.php

@@ -85,12 +85,12 @@ class Mailer
     /**
      * Fonction d'envoi
      *
-     * @param EmailInterface $email
+     * @param Email $email
      *
      * @throws TransportExceptionInterface
      * @see MailerTest::testSend()
      */
-    public function send(EmailInterface $email): void{
+    public function send(Email $email): void{
         //On créé le mail
         $symfonyMail = $this->createSymfonyEmail($email);
 
@@ -112,7 +112,7 @@ class Mailer
             $email->getEmailEntity()->setDateSent(new \DateTime('now'));
         } catch (\Exception $e) {
             $this->logger->error('Error while sending email');
-            $this->logger->error($e);
+            $this->logger->error($e->getMessage());
 
             $email->getEmailEntity()->setStatus(MessageStatusEnum::FAILED()->getValue());
         }
@@ -130,7 +130,7 @@ class Mailer
             $this->symfonyMailer->send($reportEmail);
         } catch (TransportExceptionInterface $e) {
             $this->logger->error('Error while sending report');
-            $this->logger->error($e);
+            $this->logger->error($e->getMessage());
         }
     }
 
@@ -245,13 +245,16 @@ class Mailer
      */
     public function createReport(EmailRecipient $emailRecipient): ReportEmail
     {
-        return (new ReportEmail())
+        $reportEmail = new ReportEmail();
+        $reportEmail
             ->setAddressEmail($emailRecipient->getEmailAddress())
             ->setAccess($emailRecipient->getAccess())
             ->setOrganization($emailRecipient->getOrganization())
             ->setDateSend(new \DateTime('now'))
             ->setStatus($emailRecipient->getSendStatus())
         ;
+        //Return en deux temps car setStatus renvoi un AbstractReport et non un ReportEmail
+        return $reportEmail;
     }
 
     /**

+ 1 - 1
src/Service/Mailer/Model/AbstractMailerModel.php

@@ -3,7 +3,7 @@ declare(strict_types=1);
 
 namespace App\Service\Mailer\Model;
 
-abstract  class AbstractMailerModel
+abstract class AbstractMailerModel
 {
     protected int $senderId;
     protected bool $notify = true;

+ 4 - 4
src/Service/Mailer/Model/MailerModelInterface.php

@@ -4,8 +4,8 @@ declare(strict_types=1);
 namespace App\Service\Mailer\Model;
 
 interface MailerModelInterface {
-    public function setSenderId(int $accessId);
-    public function getSenderId();
-    public function setNotify(bool $notify);
-    public function getNotify();
+    public function setSenderId(int $accessId): AbstractMailerModel;
+    public function getSenderId(): int;
+    public function setNotify(bool $notify): AbstractMailerModel;
+    public function getNotify(): bool;
 }

+ 9 - 9
src/Service/MercureHub.php

@@ -30,7 +30,7 @@ class MercureHub
         private IriConverterInterface $iriConverter
     ) {}
 
-    protected function createUpdate($accessId, string $data): Update
+    protected function createUpdate(int $accessId, string $data): Update
     {
         return new Update(
             "access/{$accessId}",
@@ -42,11 +42,11 @@ class MercureHub
     /**
      * Send an update to the
      *
-     * @param $entity
+     * @param mixed $entity
      * @param int $accessId
      * @param string $operationType
      */
-    public function publish(int $accessId, $entity, string $operationType = self::UPDATE): void
+    public function publish(int $accessId, mixed $entity, string $operationType = self::UPDATE): void
     {
         if (!in_array($operationType, [self::UPDATE, self::CREATE, self::DELETE], true)) {
             throw new \InvalidArgumentException('Invalid operation type');
@@ -64,26 +64,26 @@ class MercureHub
     }
 
     /**
-     * @param $entity
+     * @param mixed $entity
      * @param int $accessId
      */
-    public function publishUpdate(int $accessId, $entity): void {
+    public function publishUpdate(int $accessId, mixed $entity): void {
         $this->publish($accessId, $entity, self::UPDATE);
     }
 
     /**
-     * @param $entity
+     * @param mixed $entity
      * @param int $accessId
      */
-    public function publishCreate(int $accessId, $entity): void {
+    public function publishCreate(int $accessId, mixed $entity): void {
         $this->publish($accessId, $entity, self::CREATE);
     }
 
     /**
-     * @param $entity
+     * @param mixed $entity
      * @param int $accessId
      */
-    public function publishDelete(int $accessId, $entity): void {
+    public function publishDelete(int $accessId, mixed $entity): void {
         $this->publish($accessId, $entity, self::DELETE);
     }
 }

+ 1 - 1
src/Service/Network/Utils.php

@@ -66,6 +66,6 @@ class Utils
      */
     public function isNetworkOrganizationActiveNow(NetworkOrganization $networksOrganization): bool
     {
-        return DatesUtils::isIntervalIsValidNow($networksOrganization->getStartDate(), $networksOrganization->getEndDate());
+        return $networksOrganization->getStartDate() && DatesUtils::isIntervalIsValidNow($networksOrganization->getStartDate(), $networksOrganization->getEndDate());
     }
 }

+ 2 - 2
src/Service/OnChange/OnChangeContext.php

@@ -15,7 +15,7 @@ class OnChangeContext
      */
     public function isPostRequest(): bool
     {
-        return $this->context['collection_operation_name'] ?? null === 'post';
+        return ($this->context['collection_operation_name'] ?? null) === 'post';
     }
 
     /**
@@ -25,7 +25,7 @@ class OnChangeContext
      */
     public function isPutRequest(): bool
     {
-        return $this->context['item_operation_name'] ?? null === 'put';
+        return ($this->context['item_operation_name'] ?? null) === 'put';
     }
 
     /**

+ 4 - 4
src/Service/OnChange/OnChangeDefault.php

@@ -4,13 +4,13 @@ namespace App\Service\OnChange;
 
 class OnChangeDefault implements OnChangeInterface
 {
-    public function validate($data, OnChangeContext $context): void {}
+    public function validate(mixed $data, OnChangeContext $context): void {}
 
-    public function preProcess($data, OnChangeContext $context): mixed {
+    public function preProcess(mixed $data, OnChangeContext $context): mixed {
         return $data;
     }
 
-    public function beforeChange($data, OnChangeContext $context): void {}
+    public function beforeChange(mixed $data, OnChangeContext $context): void {}
 
-    public function onChange($data, OnChangeContext $context): void {}
+    public function onChange(mixed $data, OnChangeContext $context): void {}
 }

+ 8 - 8
src/Service/OnChange/OnChangeInterface.php

@@ -7,33 +7,33 @@ interface OnChangeInterface
     /**
      * Validate the new data, throw a RuntimeException if data is not valid
      *
-     * @param $data
+     * @param mixed $data
      * @param OnChangeContext $context
      */
-    public function validate($data, OnChangeContext $context): void;
+    public function validate(mixed $data, OnChangeContext $context): void;
 
     /**
      * Apply transformations to the new data before it to be persisted
      *
-     * @param $data
+     * @param mixed $data
      * @param OnChangeContext $context
      * @return mixed
      */
-    public function preProcess($data, OnChangeContext $context): mixed;
+    public function preProcess(mixed $data, OnChangeContext $context): mixed;
 
     /**
      * Other operations to run before the data to be persisted
      *
-     * @param $data
+     * @param mixed $data
      * @param OnChangeContext $context
      */
-    public function beforeChange($data, OnChangeContext $context): void;
+    public function beforeChange(mixed $data, OnChangeContext $context): void;
 
     /**
      * Operations to run after the data has been persisted
      *
-     * @param $data
+     * @param mixed $data
      * @param OnChangeContext $context
      */
-    public function onChange($data, OnChangeContext $context): void;
+    public function onChange(mixed $data, OnChangeContext $context): void;
 }

+ 1 - 1
src/Service/OnChange/Organization/OnOrganizationChange.php

@@ -14,7 +14,7 @@ use App\Test\Service\OnChange\Organization\OnOrganizationChangeTest;
  */
 class OnOrganizationChange extends OnChangeDefault
 {
-    public function beforeChange($organization, OnChangeContext $context): void
+    public function beforeChange(mixed $organization, OnChangeContext $context): void
     {
         if($context->previousData() && $context->previousData()->getLegalStatus() !== $organization->getLegalStatus()) {
             $this->onLegalStatusChange($organization);

+ 1 - 1
src/Service/OnChange/Organization/OnParametersChange.php

@@ -33,7 +33,7 @@ class OnParametersChange extends OnChangeDefault
     ){ }
 
     /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
-    public function validate($parameters, OnChangeContext $context): void
+    public function validate(mixed $parameters, OnChangeContext $context): void
     {
         // Une structure CMF n'a pas le droit de désactiver son site typo3
         if (

+ 13 - 6
src/Service/OnChange/Organization/OnSubdomainChange.php

@@ -2,6 +2,7 @@
 
 namespace App\Service\OnChange\Organization;
 
+use App\Entity\Access\Access;
 use App\Entity\Organization\Organization;
 use App\Entity\Organization\Subdomain;
 use App\Message\Command\MailerCommand;
@@ -29,7 +30,7 @@ class OnSubdomainChange extends OnChangeDefault
     ) {}
 
     /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
-    public function validate($subdomain, OnChangeContext $context): void {
+    public function validate(mixed $subdomain, OnChangeContext $context): void {
         // Ensure we do not exceed the limit of 3 subdomains per organization
         if (
             $context->isPostRequest() &&
@@ -40,7 +41,7 @@ class OnSubdomainChange extends OnChangeDefault
     }
 
     /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
-    public function beforeChange($subdomain, OnChangeContext $context): void
+    public function beforeChange(mixed $subdomain, OnChangeContext $context): void
     {
         // Ensure it is the only active subdomain of this organization by disabling other organization subdomains
         if ($subdomain->isActive()) {
@@ -53,7 +54,7 @@ class OnSubdomainChange extends OnChangeDefault
     }
 
     /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
-    public function onChange($subdomain, OnChangeContext $context): void {
+    public function onChange(mixed $subdomain, OnChangeContext $context): void {
         // Register into the BindFile
         if ($context->isPostRequest()) {
             $this->bindFileService->registerSubdomain($subdomain->getSubdomain());
@@ -93,10 +94,16 @@ class OnSubdomainChange extends OnChangeDefault
      */
     public function getMailModel(Subdomain $subdomain): SubdomainChangeModel
     {
-        return (new SubdomainChangeModel())
-            ->setSenderId($this->security->getUser()->getId())
+        /** @var Access $access */
+        $access = $this->security->getUser();
+        $subdomainChangeModel = new SubdomainChangeModel();
+        $subdomainChangeModel
             ->setOrganizationId($subdomain->getOrganization()->getId())
             ->setSubdomainId($subdomain->getId())
-            ->setUrl($this->organizationUtils->getOrganizationWebsite($subdomain->getOrganization()));
+            ->setUrl($this->organizationUtils->getOrganizationWebsite($subdomain->getOrganization()))
+            ->setSenderId($access->getId())
+            ;
+        //Return en deux temps car setSenderId renvoi un AbstractMailerModel et non un SubdomainChangeModel
+        return $subdomainChangeModel;
     }
 }

+ 1 - 1
src/Service/Organization/Utils.php

@@ -106,7 +106,7 @@ class Utils
      * Fonction permettant de récupérer les dates de début et de fin d'activité d'une structure selon une année
      * @param Organization $organization
      * @param int $year
-     * @return \DateTime[]
+     * @return string[]
      * @throws \Exception
      * @see UtilsTest::testGetActivityPeriodsSwitchYear()
      */

+ 6 - 4
src/Service/Security/SwitchUser.php

@@ -3,7 +3,8 @@ declare(strict_types=1);
 
 namespace App\Service\Security;
 
-use App\Test\Service\Security\SwitchUserTest;
+use App\Entity\Access\Access;
+use App\Tests\Service\Security\SwitchUserTest;
 use Symfony\Component\Security\Core\User\UserInterface;
 
 /**
@@ -13,13 +14,14 @@ use Symfony\Component\Security\Core\User\UserInterface;
 class SwitchUser
 {
     /**
-     * @param UserInterface $user
+     * @param Access $access
      * @param UserInterface $user_to_switch
      * @return bool
      * @see SwitchUserTest::testIsAllowedToSwitch()
      */
-    public function isAllowedToSwitch(UserInterface $user, UserInterface $user_to_switch): bool
+    public function isAllowedToSwitch(Access $access, UserInterface $user_to_switch): bool
     {
-        return $user->getChildren()->contains($user_to_switch);
+
+        return $access->getChildren()->contains($user_to_switch);
     }
 }

+ 1 - 1
src/Service/ServiceIterator/CurrentAccessExtensionIterator.php

@@ -10,7 +10,7 @@ class CurrentAccessExtensionIterator {
     public function __construct(private iterable $extensions)
     { }
 
-    public function addWhere(QueryBuilder $queryBuilder, $operationName) {
+    public function addWhere(QueryBuilder $queryBuilder, string $operationName): void {
         /** @var AccessExtensionInterface $extension */
         foreach ($this->extensions as $extension){
             if($extension->support($operationName)) {

+ 2 - 2
src/Service/ServiceIterator/Mailer/BuilderIterator.php

@@ -25,13 +25,13 @@ class BuilderIterator
      * Itère sur les services de build disponibles et
      * retourne le premier qui supporte ce type de requête.
      *
-     * @param string $type
+     * @param MailerModelInterface $mailerModel
      * @return BuilderInterface
      * @throws Exception
      */
     public function getBuilderFor(MailerModelInterface $mailerModel): BuilderInterface
     {
-        /** @var BuilderInterface $builderServices */
+        /** @var BuilderInterface $builderService */
         foreach ($this->builderServices as $builderService){
             if($builderService->support($mailerModel))
                 return $builderService;

+ 1 - 1
src/Service/Utils/DatesUtils.php

@@ -44,7 +44,7 @@ class DatesUtils
 
     /**
      * Vérifie si la date du jour est comprise dans l'interval passé en paramètres
-     * @param \DateTime $dateStart
+     * @param \DateTimeInterface $dateStart
      * @param \DateTimeInterface|null $dateEnd
      * @return bool
      * @see DatesUtilsTest::testIsIntervalIsValidNow()

+ 5 - 5
src/Service/Utils/EntityUtils.php

@@ -13,18 +13,18 @@ use App\Entity\Access\Access;
  */
 class EntityUtils
 {
-    public function defaultValueSettersByAccess($entity, Access $access): void
+    public function defaultValueSettersByAccess(mixed $entity, Access $access): void
     {
         $this->organizationDefaultValue($entity, $access);
         $this->billingSettingDefaultValueDefaultValue($entity, $access);
     }
 
     /**
-     * @param $entity
+     * @param mixed $entity
      * @param Access $access
      * @throws \ReflectionException
      */
-    protected function organizationDefaultValue($entity, Access $access): void
+    protected function organizationDefaultValue(mixed $entity, Access $access): void
     {
         $reflection = new \ReflectionClass($entity::class);
         $organizationFaultValue = $reflection->getAttributes(OrganizationDefaultValue::class)[0] ?? null;
@@ -35,11 +35,11 @@ class EntityUtils
     }
 
     /**
-     * @param $entity
+     * @param mixed $entity
      * @param Access $access
      * @throws \ReflectionException
      */
-    protected function billingSettingDefaultValueDefaultValue($entity, Access $access): void
+    protected function billingSettingDefaultValueDefaultValue(mixed $entity, Access $access): void
     {
         $reflection = new \ReflectionClass($entity::class);
         $billingSettingDefaultValueDefault = $reflection->getAttributes(BillingSettingDefaultValue::class)[0] ?? null;

Some files were not shown because too many files changed in this diff