Skip to content

Commit

Permalink
fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
geisi committed Sep 26, 2024
1 parent 9e23a04 commit f7b5274
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
20 changes: 20 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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\\<array\\<string, array\\<string, string\\>\\>\\> 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
Expand All @@ -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
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ parameters:
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
4 changes: 4 additions & 0 deletions src/MicrosoftGraphTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ protected function doSend(SentMessage $message): void
$this->microsoftGraphApiService->sendMail($envelope->getSender()->getAddress(), $payload);
}

/**
* @return array<int, array<int<0, max>, array<string, bool|string|null>>|string|null>
*/
protected function prepareAttachments(Email $email, ?string $html): array
{
$attachments = [];
Expand All @@ -83,6 +86,7 @@ protected function prepareAttachments(Email $email, ?string $html): array

/**
* @param Collection<array-key, Address> $recipients
* @return array<array-key, array<string, array<string, string>>>
*/
protected function transformEmailAddresses(Collection $recipients): array
{
Expand Down
9 changes: 1 addition & 8 deletions src/Services/MicrosoftGraphApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,9 +17,6 @@ public function __construct(
protected readonly int $accessTokenTtl
) {}

/**
* @throws RequestException
*/
public function sendMail(string $from, array $payload): Response
{
return $this->getBaseRequest()
Expand Down Expand Up @@ -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;
});
Expand Down

0 comments on commit f7b5274

Please sign in to comment.