Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Jan 15, 2025
1 parent 79f7edf commit 5a32195
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 27 deletions.
12 changes: 0 additions & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Exceptions/CurlInitializationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Mollie\Api\Http\Adapter;

use Mollie\Api\Exceptions\MollieException;
use Mollie\Api\Http\PendingRequest;
use Throwable;

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ValidationException extends ApiException
{
private ?string $field;
private string $field;

public function __construct(
Response $response,
Expand Down
1 change: 0 additions & 1 deletion src/Http/Adapter/PSR18MollieHttpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Middleware/ConvertResponseToException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/ManagesPsrRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
11 changes: 2 additions & 9 deletions src/Utils/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) . ') ->');
]);
}

/**
Expand All @@ -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) . ') ->');
]);
}

/**
Expand All @@ -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);
}
}

0 comments on commit 5a32195

Please sign in to comment.