Browse Source

PhpStan Level 0

Vincent 2 years ago
parent
commit
9301f5d021

+ 1 - 1
src/ApiResources/Export/ExportRequest.php

@@ -3,7 +3,7 @@ declare(strict_types=1);
 
 namespace App\ApiResources\Export;
 
-use ApiPlatform\Core\Annotation\ApiProperty;
+use ApiPlatform\Metadata\ApiProperty;
 use Symfony\Component\Validator\Constraints as Assert;
 use App\Enum\Export\ExportFormatEnum;
 

+ 8 - 0
src/Attribute/ActivityYearConstraintAware.php

@@ -11,4 +11,12 @@ final class ActivityYearConstraintAware
 {
     public string $startYearFieldName;
     public string $endYearFieldName;
+
+    public function __construct(
+         string $startYearFieldName,
+         string $endYearFieldName
+    ){
+        $this->startYearFieldName = $startYearFieldName;
+        $this->endYearFieldName = $endYearFieldName;
+    }
 }

+ 5 - 0
src/Attribute/BillingSettingDefaultValue.php

@@ -10,4 +10,9 @@ namespace App\Attribute;
 final class BillingSettingDefaultValue
 {
     public string $fieldName;
+
+    public function __construct(string $fieldName)
+    {
+        $this->fieldName = $fieldName;
+    }
 }

+ 8 - 0
src/Attribute/DateTimeConstraintAware.php

@@ -11,4 +11,12 @@ final class DateTimeConstraintAware
 {
     public string $startDateFieldName;
     public string $endDateFieldName;
+
+    public function __construct(
+        string $startDateFieldName,
+        string $endDateFieldName
+    ){
+        $this->startDateFieldName = $startDateFieldName;
+        $this->endDateFieldName = $endDateFieldName;
+    }
 }

+ 3 - 0
src/Attribute/OrganizationDefaultValue.php

@@ -10,4 +10,7 @@ namespace App\Attribute;
 final class OrganizationDefaultValue
 {
     public string $fieldName;
+    public function __construct(string $fieldName){
+        $this->fieldName = $fieldName;
+    }
 }

+ 1 - 3
src/Commands/CronCommand.php

@@ -2,7 +2,7 @@
 
 namespace App\Commands;
 
-use App\Service\Cron\CronJobInterface;
+use App\Service\Cron\CronjobInterface;
 use App\Service\Cron\UI\ConsoleUI;
 use App\Service\ServiceIterator\CronjobIterator;
 use Psr\Log\LoggerInterface;
@@ -10,8 +10,6 @@ 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\Helper\ProgressBar;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;

+ 0 - 2
src/Entity/Access/Access.php

@@ -111,11 +111,9 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
     private AccessBilling $accessBilling;
 
     #[ORM\OneToMany(mappedBy: 'access', targetEntity: PersonActivity::class, cascade: ['persist'], orphanRemoval: true)]
-    #[ApiResource]
     private Collection $personActivity;
 
     #[ORM\OneToMany(mappedBy: 'access', targetEntity: OrganizationFunction::class, cascade: ['persist'], orphanRemoval: true)]
-    #[ApiResource]
     private Collection $organizationFunction;
 
     #[ORM\OneToMany(mappedBy: 'licensee', targetEntity: OrganizationLicence::class, cascade: ['persist'], orphanRemoval: true)]

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

@@ -92,7 +92,6 @@ class Organization
     private Collection $accesses;
 
     #[ORM\OneToMany(mappedBy: 'organization', targetEntity: NetworkOrganization::class, orphanRemoval: true)]
-    #[ApiResource]
     private Collection $networkOrganizations;
 
     #[ORM\OneToMany(mappedBy: 'parent', targetEntity: NetworkOrganization::class, orphanRemoval: true)]
@@ -106,7 +105,6 @@ class Organization
     private Parameters $parameters;
 
     #[ORM\OneToOne(mappedBy: 'organization', cascade: ['persist', 'remove'], orphanRemoval: true)]
-    #[ApiResource]
     private BillingSetting $billingSetting;
 
     #[ORM\Column(type: 'text', nullable: true)]
@@ -224,31 +222,26 @@ class Organization
     private ?File $image = null;
 
     #[ORM\ManyToMany(targetEntity: TypeOfPractice::class, mappedBy: 'organizations')]
-    #[ApiResource]
     private Collection $typeOfPractices;
 
     #[ORM\Column(nullable: true)]
     private ?string $otherPractice = null;
 
     #[ORM\ManyToMany(targetEntity: ContactPoint::class, mappedBy: 'organization')]
-    #[ApiResource]
     private Collection $contactPoints;
 
     #[ORM\ManyToMany(targetEntity: BankAccount::class, inversedBy: 'organization')]
     #[ORM\JoinColumn(name: 'organization_id', referencedColumnName: 'id', unique: true)]
     #[ORM\InverseJoinColumn(name: 'bankAccount_id', referencedColumnName: 'id')]
-    #[ApiResource]
     private Collection $bankAccounts;
 
     #[ORM\OneToMany(mappedBy: 'organization', targetEntity: OrganizationAddressPostal::class, orphanRemoval: true)]
-    #[ApiResource]
     private Collection $organizationAddressPostals;
 
     #[ORM\OneToMany(mappedBy: 'organization', targetEntity: OrganizationLicence::class, orphanRemoval: true)]
     private Collection $organizationLicences;
 
     #[ORM\OneToMany(mappedBy: 'organization', targetEntity: OrganizationArticle::class, orphanRemoval: true)]
-    #[ApiResource]
     private Collection $organizationArticles;
 
     #[ORM\OneToMany(mappedBy: 'organization', targetEntity: Cycle::class, orphanRemoval: true)]
@@ -258,7 +251,6 @@ class Organization
     private Collection $educationTimings;
 
     #[ORM\OneToMany(mappedBy: 'organization', targetEntity: Subdomain::class)]
-    #[ApiResource]
     private Collection $subdomains;
 
     #[ORM\ManyToOne(inversedBy: 'organizationContacts')]

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

@@ -86,7 +86,6 @@ class Parameters
     private bool $desactivateOpentalentSiteWeb = false;
 
     #[ORM\OneToMany(mappedBy: 'publicationDirector', targetEntity: Access::class)]
-    #[ApiResource]
     private Collection $publicationDirectors;
 
     #[ORM\Column(length: 255, nullable: true)]

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

@@ -26,13 +26,13 @@ final class DistanceFilter extends AbstractFilter
 {
     /**
      * API docs
-     * @param string|ResourceInterface $resource
+     * @param string $resourceClass
      * @return array[]
      */
     #[ArrayShape(['search' => "array"])]
-    public function getDescription(string|ResourceInterface $resource): array
+    public function getDescription(string $resourceClass): array
     {
-        if (!property_exists($resource, 'latitude') || !property_exists($resource, 'longitude')) {
+        if (!property_exists($resourceClass, 'latitude') || !property_exists($resourceClass, 'longitude')) {
             throw new \RuntimeException('DistanceFilter can only used with resources having both latitude and longitude properties');
         }
         return [

+ 1 - 2
src/Service/Cron/UI/ConsoleUI.php

@@ -2,7 +2,6 @@
 
 namespace App\Service\Cron\UI;
 
-use App\Tests\Service\Cron\UI\MockableProgressBar;
 use Symfony\Component\Console\Helper\ProgressBar;
 use Symfony\Component\Console\Output\OutputInterface;
 
@@ -13,7 +12,7 @@ use Symfony\Component\Console\Output\OutputInterface;
  */
 class ConsoleUI implements CronUIInterface
 {
-    protected ProgressBar | MockableProgressBar $progressBar;
+    protected ProgressBar $progressBar;
 
     public function __construct(
         private OutputInterface $output

+ 0 - 1
src/Service/Mailer/Builder/OnSubdomainChangeMailBuilder.php

@@ -15,7 +15,6 @@ use App\Service\Mailer\Model\SubdomainChangeModel;
 use App\Tests\Service\Mailer\Builder\OnSubdomainChangeMailBuilderTest;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\ORM\EntityManagerInterface;
-use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
 
 /**
  * Classe SubDomainChangeBuilder qui est chargé de construire l'Email qui sera envoyé

+ 1 - 1
src/Validator/Organization/Parameters/MobytCredentialsValidator.php

@@ -29,7 +29,7 @@ class MobytCredentialsValidator extends ConstraintValidator
         try{
             $this->mobytService->hasCredentialsCorrect($userNameSms, $passwordSms);
         }catch (\Exception $exception){
-            $this->context->buildViolation($constraint->message)
+            $this->context->buildViolation($constraint->payload)
                 ->atPath('passwordSMS')
                 ->addViolation();
         }