diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d20c5bf6..754d4f04 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -270,18 +270,6 @@ parameters: count: 1 path: examples/subscriptions/update-subscription.php - - - message: '#^Unsafe access to private property Mollie\\Api\\Fake\\MockMollieHttpAdapter\:\:\$factories through static\:\:\.$#' - identifier: staticClassAccess.privateProperty - count: 3 - path: src/Fake/MockMollieHttpAdapter.php - - - - message: '#^Unsafe access to private property Mollie\\Api\\Fake\\MockResponse\:\:\$factories through static\:\:\.$#' - identifier: staticClassAccess.privateProperty - count: 3 - path: src/Fake/MockResponse.php - - message: '#^Unsafe usage of new static\(\)\.$#' identifier: new.static diff --git a/src/Exceptions/CurlInitializationException.php b/src/Exceptions/CurlInitializationException.php index c3184f78..bfbcb441 100644 --- a/src/Exceptions/CurlInitializationException.php +++ b/src/Exceptions/CurlInitializationException.php @@ -2,6 +2,7 @@ namespace Mollie\Api\Http\Adapter; +use Mollie\Api\Exceptions\MollieException; use Mollie\Api\Http\PendingRequest; use Throwable; diff --git a/src/Exceptions/ValidationException.php b/src/Exceptions/ValidationException.php index 74807f8d..66dca401 100644 --- a/src/Exceptions/ValidationException.php +++ b/src/Exceptions/ValidationException.php @@ -8,7 +8,7 @@ class ValidationException extends ApiException { - private ?string $field; + private string $field; public function __construct( Response $response, diff --git a/src/Http/Adapter/PSR18MollieHttpAdapter.php b/src/Http/Adapter/PSR18MollieHttpAdapter.php index 5124c28a..4dfee103 100644 --- a/src/Http/Adapter/PSR18MollieHttpAdapter.php +++ b/src/Http/Adapter/PSR18MollieHttpAdapter.php @@ -75,7 +75,6 @@ public function sendRequest(PendingRequest $pendingRequest): Response 'Network error: ' . $e->getMessage() ); } catch (RequestExceptionInterface $e) { - /** @phpstan-ignore-next-line */ if (method_exists($e, 'getResponse') && $response = $e->getResponse()) { return $this->createResponse($response, $request, $pendingRequest, $e); } diff --git a/src/Http/Middleware/ConvertResponseToException.php b/src/Http/Middleware/ConvertResponseToException.php index b2be71c7..cc06eb34 100644 --- a/src/Http/Middleware/ConvertResponseToException.php +++ b/src/Http/Middleware/ConvertResponseToException.php @@ -48,8 +48,8 @@ public function __invoke(Response $response): void sprintf( 'Error executing API call (%d: %s): %s', $status, - $response->json()?->title ?? 'Unknown', - $response->json()?->detail ?? 'Unknown' + $response->json()->title ?? 'Unknown', + $response->json()->detail ?? 'Unknown' ), $status, null diff --git a/src/Traits/ManagesPsrRequests.php b/src/Traits/ManagesPsrRequests.php index ebb118fc..d000655b 100644 --- a/src/Traits/ManagesPsrRequests.php +++ b/src/Traits/ManagesPsrRequests.php @@ -29,8 +29,8 @@ public function createPsrRequest(): RequestInterface $request = $request->withHeader($headerName, $headerValue); } - /** @var PayloadRepository|null */ - if (($payload = $this->payload()) instanceof PayloadRepository) { + $payload = $this->payload(); + if ($payload instanceof PayloadRepository) { $request = $request->withBody($payload->toStream($factories->streamFactory)); } diff --git a/src/Utils/Debugger.php b/src/Utils/Debugger.php index c4a7560e..388d6aa3 100644 --- a/src/Utils/Debugger.php +++ b/src/Utils/Debugger.php @@ -35,7 +35,7 @@ public static function symfonyRequestDebugger(PendingRequest $pendingRequest, Re 'uri' => (string) $psrRequest->getUri(), 'headers' => $headers, 'body' => (string) $psrRequest->getBody(), - ], 'Mollie Request (' . self::getLabel($pendingRequest->getRequest()) . ') ->'); + ]); } /** @@ -53,7 +53,7 @@ public static function symfonyResponseDebugger(Response $response, ResponseInter 'status' => $response->status(), 'headers' => $headers, 'body' => json_decode((string) $psrResponse->getBody(), true), - ], 'Mollie Response (' . self::getLabel($response) . ') ->'); + ]); } /** @@ -67,11 +67,4 @@ public static function die(): void $handler(); } - - private static function getLabel(object $object): string - { - $className = explode('\\', get_class($object)); - - return end($className); - } }