浏览代码

phpstan fixes

Olivier Massot 1 年之前
父节点
当前提交
d652a821cb

+ 0 - 1
src/ApiResources/Organization/OrganizationCreationRequest.php

@@ -27,7 +27,6 @@ use Symfony\Component\Validator\Constraints as Assert;
 class OrganizationCreationRequest
 {
     private const FRANCE_COUNTRY_INTERNAL_ID = 72;
-    private const OPENTALENT_ID = 1;
 
     /**
      * Id 'bidon' ajouté par défaut pour permettre la construction

+ 10 - 0
src/Entity/Person/Person.php

@@ -39,6 +39,9 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
     #[ORM\Column(length: 180, unique: true, nullable: true)]
     private ?string $username = null;
 
+    /**
+     * @var array<mixed>|null
+     */
     #[ORM\Column(type: "array", nullable: true)]
     private ?array $roles = [];
 
@@ -593,11 +596,18 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
         return $this;
     }
 
+    /**
+     * @return array<string, string>
+     */
     public function getConfidentiality(): array
     {
         return $this->confidentiality;
     }
 
+    /**
+     * @param array<string, string> $confidentiality
+     * @return $this
+     */
     public function setConfidentiality(array $confidentiality): self
     {
         $this->confidentiality = $confidentiality;

+ 2 - 2
src/Entity/Public/PublicEvent.php

@@ -472,13 +472,13 @@ class PublicEvent
     }
 
 
-    public function getStructureName()
+    public function getStructureName(): string
     {
         return $this->structureName;
     }
 
 
-    public function setStructureName($structureName)
+    public function setStructureName(string $structureName): self
     {
         $this->structureName = $structureName;
 

+ 14 - 6
src/Message/Handler/OrganizationCreationHandler.php

@@ -10,6 +10,8 @@ use Symfony\Component\Mailer\MailerInterface;
 use Symfony\Component\Messenger\Attribute\AsMessageHandler;
 use Symfony\Component\Mime\Address;
 use Symfony\Component\Mime\Email as SymfonyEmail;
+use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
+use Throwable;
 
 #[AsMessageHandler(priority: 1)]
 class OrganizationCreationHandler
@@ -19,19 +21,25 @@ class OrganizationCreationHandler
         private readonly MailerInterface $symfonyMailer,
     ) {}
 
+    /**
+     * @throws Throwable
+     * @throws TransportExceptionInterface
+     * @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
+     */
     public function __invoke(OrganizationCreationCommand $organizationCreationCommand): void
     {
         $organizationCreationRequest = $organizationCreationCommand->getOrganizationCreationRequest();
+        $mail = ['subject' => '', 'content' => ''];
 
         try {
             $organization = $this->organizationFactory->create($organizationCreationRequest);
 
-            $subject = 'New organization created';
-            $message = 'The organization "' . $organization->getName() . '" has been created successfully.';
+            $mail['subject'] = 'New organization created';
+            $mail['content'] = 'The organization "' . $organization->getName() . '" has been created successfully.';
 
         } catch (\Exception $e) {
-            $subject = 'Organization creation : an error occured';
-            $message = 'An error occured while creating the new organization : \n' . $e->getMessage();
+            $mail['subject'] = 'Organization creation : an error occured';
+            $mail['content'] = 'An error occured while creating the new organization : \n' . $e->getMessage();
             throw $e;
 
         } finally {
@@ -41,8 +49,8 @@ class OrganizationCreationHandler
                     ->replyTo('mail.report@opentalent.fr')
                     ->returnPath(Address::create('mail.report@opentalent.fr'))
                     ->to($organizationCreationRequest->getSendConfirmationEmailAt())
-                    ->subject($subject)
-                    ->text($message);
+                    ->subject($mail['subject'])
+                    ->text($mail['content']);
                 $this->symfonyMailer->send($symfonyMail);
             }
         }

+ 3 - 3
src/Service/Rest/ApiRequestService.php

@@ -72,9 +72,9 @@ class ApiRequestService implements ApiRequestInterface
     }
 
     /**
-     * @param array $options
-     * @param array|string $body
-     * @return array
+     * @param array<mixed> $options
+     * @param array<mixed>|string $body
+     * @return array<mixed>
      */
     protected function addBodyOption(array $options, array | string $body): array
     {