Olivier Massot 7 месяцев назад
Родитель
Сommit
516e3aa2d1

+ 3 - 2
phpstan.neon.dist

@@ -8,9 +8,10 @@ parameters:
     # 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.#'
+        - '#Attribute class JetBrains\\PhpStorm\\[a-zA-Z]+ does not exist\.#'
         - identifier: 'missingType.generics'
-        - '#Property .+::\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
+        - '#Class App\\Repository\\.+Repository has PHPDoc tag @method for method .+\(\) parameter .* with no value type specified in iterable type array\.$#'
+#        - '#Property .+::\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
 
     ergebnis:
         # TODO: simplify by using allRules: false (https://github.com/ergebnis/phpstan-rules?tab=readme-ov-file#enabling-rules-one-by-one)

+ 3 - 3
src/ApiResources/Profile/OrganizationProfile.php

@@ -71,7 +71,7 @@ class OrganizationProfile implements ApiResourcesInterface
     private ?PrincipalTypeEnum $principalType = null;
 
     #[Groups('access_profile_read')]
-    private ?bool $trialActive = false;
+    private bool $trialActive = false;
 
     #[Groups('access_profile_read')]
     private ?int $trialCountDown = null;
@@ -256,9 +256,9 @@ class OrganizationProfile implements ApiResourcesInterface
         return $this->trialActive;
     }
 
-    public function setTrialActive(?bool $trialActive): self
+    public function setTrialActive(bool $trialActive): self
     {
-        $this->trialActive = $trialActive ?? false;
+        $this->trialActive = $trialActive;
 
         return $this;
     }

+ 1 - 4
src/Commands/CronCommand.php

@@ -134,10 +134,7 @@ class CronCommand extends Command
         }
 
         if ($action === self::ACTION_RUN_ALL) {
-            $jobs = $this->cronjobIterator->getAll();
-            if (is_iterable($jobs)) {
-                $jobs = iterator_to_array($jobs);
-            }
+            $jobs = iterator_to_array($this->cronjobIterator->getAll());
         }
 
         if ($action === self::ACTION_RUN) {

+ 30 - 0
src/Entity/Core/AbstractControl.php

@@ -7,6 +7,7 @@ namespace App\Entity\Core;
 use App\Entity\Place\PlaceControl;
 use App\Entity\Place\RoomControl;
 use App\Entity\Product\EquipmentControl;
+use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
 
 /**
@@ -30,8 +31,37 @@ abstract class AbstractControl
     #[ORM\GeneratedValue]
     protected ?int $id = null;
 
+    /** @var Collection<int, Tagg> */
+    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'controls')]
+    #[ORM\JoinTable('tag_control')]
+    protected Collection $tags;
+
     public function getId(): ?int
     {
         return $this->id;
     }
+
+    public function getTags(): Collection
+    {
+        return $this->tags;
+    }
+
+    public function addTag(Tagg $tag): self
+    {
+        if (!$this->tags->contains($tag)) {
+            $this->tags[] = $tag;
+            $tag->addControl($this);
+        }
+
+        return $this;
+    }
+
+    public function removeTag(Tagg $tag): self
+    {
+        if ($this->tags->removeElement($tag)) {
+            $tag->removeControl($this);
+        }
+
+        return $this;
+    }
 }

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

@@ -56,7 +56,7 @@ class BankAccount
      * 0 => jamais facturé, 1 => facturé 1 fois, 2 => facturé plusieurs fois.
      */
     #[ORM\Column(columnDefinition: "TINYINT DEFAULT 0 NOT NULL")]
-    private ?int $countInvoiced = 0;
+    private int $countInvoiced = 0;
 
     #[ORM\Column(length: 255, nullable: true)]
     private ?string $holder = null;

+ 30 - 6
src/Entity/Core/Tagg.php

@@ -186,6 +186,11 @@ class Tagg
     #[ORM\ManyToMany(targetEntity: EducationCurriculumPack::class, mappedBy: 'tags', cascade: [], orphanRemoval: false)]
     protected Collection $educationCurriculumPacks;
 
+    /** @var Collection<int, AbstractControl> */
+    #[ORM\OneToMany(targetEntity: AbstractControl::class, mappedBy: 'tags', cascade: [], orphanRemoval: false)]
+    private Collection $controls;
+
+
     public function __construct()
     {
         $this->accesses = new ArrayCollection();
@@ -221,6 +226,7 @@ class Tagg
         $this->repairs = new ArrayCollection();
         $this->controls = new ArrayCollection();
         $this->educationCurriculumPacks = new ArrayCollection();
+        $this->controls = new ArrayCollection();
     }
 
     public function getId(): ?int
@@ -1062,12 +1068,6 @@ class Tagg
         return $this;
     }
 
-    public function getControls(): Collection
-    {
-        return $this->controls;
-    }
-
-
     public function getEducationCurriculumPacks(): Collection
     {
         return $this->educationCurriculumPacks;
@@ -1091,4 +1091,28 @@ class Tagg
 
         return $this;
     }
+
+    public function getControls(): Collection
+    {
+        return $this->controls;
+    }
+
+    public function addControl(AbstractControl $control): self
+    {
+        if (!$this->controls->contains($control)) {
+            $this->controls[] = $control;
+            $control->addTag($this);
+        }
+
+        return $this;
+    }
+
+    public function removeControl(AbstractControl $control): self
+    {
+        if ($this->controls->removeElement($control)) {
+            $control->removeTag($this);
+        }
+
+        return $this;
+    }
 }

+ 6 - 6
src/Entity/Custom/Search/UserSearchItem.php

@@ -45,22 +45,22 @@ class UserSearchItem
     #[ORM\Column]
     private int $id;
 
-    #[ORM\Column(type: 'integer')]
+    #[ORM\Column(type: 'integer', nullable: true)]
     private ?int $organizationId = null;
 
-    #[ORM\Column(type: 'integer')]
+    #[ORM\Column(type: 'integer', nullable: true)]
     private ?int $personId = null;
 
-    #[ORM\Column(type: 'string')]
+    #[ORM\Column(type: 'string', nullable: true)]
     private ?string $username = null;
 
-    #[ORM\Column(type: 'string')]
+    #[ORM\Column(type: 'string', nullable: true)]
     private ?string $name = null;
 
-    #[ORM\Column(type: 'string')]
+    #[ORM\Column(type: 'string', nullable: true)]
     private ?string $givenName = null;
 
-    #[ORM\Column(type: 'string')]
+    #[ORM\Column(type: 'string', nullable: true)]
     private ?string $fullName = null;
 
     public function getId(): int

+ 1 - 1
src/Service/Cron/Job/CleanDb.php

@@ -99,7 +99,7 @@ class CleanDb extends BaseCronJob
     {
         $this->logger->info('Purge Audit_* tables from the records created before the '.$maxDate->format('c'));
 
-        $tableNames = $this->connection->getSchemaManager()->listTableNames();
+        $tableNames = $this->connection->createSchemaManager()->listTableNames();
 
         $total = 0;
 

+ 1 - 1
src/Service/Dolibarr/DolibarrApiService.php

@@ -100,7 +100,7 @@ class DolibarrApiService extends ApiRequestService
      * Get the last order of the given society.
      *
      * @param int $socId
-     * @return array|null
+     * @return array<string, mixed>|null
      * @throws \JsonException
      */
     public function getLastOrder(int $socId): ?array {

+ 2 - 2
src/Service/ServiceIterator/CronjobIterator.php

@@ -5,7 +5,7 @@ declare(strict_types=1);
 namespace App\Service\ServiceIterator;
 
 use App\Service\Cron\CronjobInterface;
-use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
+use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
 
 /**
  * Permet d'itérer sur les cronjobs.
@@ -18,7 +18,7 @@ class CronjobIterator
      * @param iterable<CronjobInterface> $cronjobServices
      */
     public function __construct(
-        #[TaggedIterator('app.cronjob')]
+        #[AutowireIterator('app.cronjob')]
         readonly private iterable $cronjobServices,
     ) {
     }