diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d2ecb11..5fc51d0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,15 @@ parameters: ignoreErrors: + - + message: "#^Method InnoGE\\\\LaravelMsGraphMail\\\\MicrosoftGraphTransport\\:\\:transformEmailAddress\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/MicrosoftGraphTransport.php + + - + message: "#^Method InnoGE\\\\LaravelMsGraphMail\\\\MicrosoftGraphTransport\\:\\:transformEmailAddresses\\(\\) should return array\\\\>\\> but returns array\\.$#" + count: 1 + path: src/MicrosoftGraphTransport.php + - message: "#^Parameter \\#1 \\$message of static method Symfony\\\\Component\\\\Mime\\\\MessageConverter\\:\\:toEmail\\(\\) expects Symfony\\\\Component\\\\Mime\\\\Message, Symfony\\\\Component\\\\Mime\\\\RawMessage given\\.$#" count: 1 @@ -9,3 +19,13 @@ parameters: message: "#^Parameter \\#2 \\$html of method InnoGE\\\\LaravelMsGraphMail\\\\MicrosoftGraphTransport\\:\\:prepareAttachments\\(\\) expects string\\|null, resource\\|string\\|null given\\.$#" count: 1 path: src/MicrosoftGraphTransport.php + + - + message: "#^Method InnoGE\\\\LaravelMsGraphMail\\\\Services\\\\MicrosoftGraphApiService\\:\\:getAccessToken\\(\\) should return string but returns mixed\\.$#" + count: 1 + path: src/Services/MicrosoftGraphApiService.php + + - + message: "#^Method InnoGE\\\\LaravelMsGraphMail\\\\Services\\\\MicrosoftGraphApiService\\:\\:sendMail\\(\\) has parameter \\$payload with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Services/MicrosoftGraphApiService.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9aa5399..40e24a1 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -8,5 +8,3 @@ parameters: tmpDir: build/phpstan checkOctaneCompatibility: true checkModelProperties: true - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false diff --git a/src/MicrosoftGraphTransport.php b/src/MicrosoftGraphTransport.php index 9264699..517100c 100644 --- a/src/MicrosoftGraphTransport.php +++ b/src/MicrosoftGraphTransport.php @@ -61,6 +61,9 @@ protected function doSend(SentMessage $message): void $this->microsoftGraphApiService->sendMail($envelope->getSender()->getAddress(), $payload); } + /** + * @return array, array>|string|null> + */ protected function prepareAttachments(Email $email, ?string $html): array { $attachments = []; @@ -83,6 +86,7 @@ protected function prepareAttachments(Email $email, ?string $html): array /** * @param Collection $recipients + * @return array>> */ protected function transformEmailAddresses(Collection $recipients): array { diff --git a/src/Services/MicrosoftGraphApiService.php b/src/Services/MicrosoftGraphApiService.php index 462144a..c11cf49 100644 --- a/src/Services/MicrosoftGraphApiService.php +++ b/src/Services/MicrosoftGraphApiService.php @@ -3,7 +3,6 @@ namespace InnoGE\LaravelMsGraphMail\Services; use Illuminate\Http\Client\PendingRequest; -use Illuminate\Http\Client\RequestException; use Illuminate\Http\Client\Response; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Http; @@ -18,9 +17,6 @@ public function __construct( protected readonly int $accessTokenTtl ) {} - /** - * @throws RequestException - */ public function sendMail(string $from, array $payload): Response { return $this->getBaseRequest() @@ -49,10 +45,7 @@ protected function getAccessToken(): string $response->throw(); $accessToken = $response->json('access_token'); - if (! is_string($accessToken)) { - $notString = var_export($accessToken, true); - throw new InvalidResponse("Expected response to contain key access_token of type string, got: {$notString}."); - } + throw_unless(is_string($accessToken), new InvalidResponse('Expected response to contain key access_token of type string, got: {'.var_export($accessToken, true).' }.')); return $accessToken; });