Skip to content

Commit

Permalink
fix all phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Dec 4, 2024
1 parent d5a2150 commit 4c472c9
Show file tree
Hide file tree
Showing 63 changed files with 222 additions and 412 deletions.
40 changes: 40 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,43 @@ parameters:
message: "#^Variable \\$mollie might not be defined\\.$#"
count: 1
path: examples/subscriptions/update-subscription.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/CompatibilityChecker.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Http/Payload/CreateRefundPaymentPayload.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 5
path: src/Http/Payload/DataCollection.php

-
message: "#^Access to an undefined property Mollie\\\\Api\\\\Resources\\\\Issuer\\:\\:\\$_links\\.$#"
count: 1
path: tests/EndpointCollection/MethodIssuerEndpointCollectionTest.php

-
message: "#^Access to an undefined property Mollie\\\\Api\\\\Resources\\\\Issuer\\:\\:\\$description\\.$#"
count: 1
path: tests/EndpointCollection/MethodIssuerEndpointCollectionTest.php

-
message: "#^Access to an undefined property Mollie\\\\Api\\\\Resources\\\\Issuer\\:\\:\\$status\\.$#"
count: 1
path: tests/EndpointCollection/MethodIssuerEndpointCollectionTest.php

-
message: "#^Unsafe access to private property Tests\\\\Fixtures\\\\MockResponse\\:\\:\\$factories through static\\:\\:\\.$#"
count: 4
path: tests/Fixtures/MockResponse.php

-
message: "#^Unsafe access to private property Tests\\\\Http\\\\Adapter\\\\MockMollieHttpAdapter\\:\\:\\$factories through static\\:\\:\\.$#"
count: 4
path: tests/Http/Adapter/MockMollieHttpAdapter.php
4 changes: 2 additions & 2 deletions src/Contracts/SupportsDebuggingContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ interface SupportsDebuggingContract
/**
* Enable debugging for the current request.
*
* @return $this
* @return HttpAdapterContract|Connector
*/
public function enableDebugging();

/**
* Disable debugging for the current request.
*
* @return $this
* @return HttpAdapterContract|Connector
*/
public function disableDebugging();
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function iteratorForPrimary($query = [], bool $iterateBackwards = false,
* List the transactions for a specific Balance ID.
*
* @param array|PaginatedQuery $query
* @param bool|null $testmode
* @param bool $testmode
*
* @throws \Mollie\Api\Exceptions\ApiException
*/
Expand Down
10 changes: 5 additions & 5 deletions src/EndpointCollection/ClientLinkEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ class ClientLinkEndpointCollection extends EndpointCollection
/**
* Creates a client link in Mollie.
*
* @param array $data An array containing details on the client link.
* @param array|CreateClientLinkPayload $payload An array containing details on the client link.
*
* @throws ApiException
*/
public function create($data = []): ClientLink
public function create($payload = []): ClientLink
{
if (! $data instanceof CreateClientLinkPayload) {
$data = CreateClientLinkPayloadFactory::new($data)
if (! $payload instanceof CreateClientLinkPayload) {
$payload = CreateClientLinkPayloadFactory::new($payload)
->create();
}

/** @var ClientLink */
return $this->send(new CreateClientLinkRequest($data));
return $this->send(new CreateClientLinkRequest($payload));
}
}
2 changes: 1 addition & 1 deletion src/EndpointCollection/PaymentLinkEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function page(?string $from = null, ?int $limit = null, $testmode = []):
public function iterator(
?string $from = null,
?int $limit = null,
$testmode = [],
bool $testmode = false,
bool $iterateBackwards = false
): LazyCollection {
$testmode = Helpers::extractBool($testmode, 'testmode', false);
Expand Down
2 changes: 1 addition & 1 deletion src/EndpointCollection/PaymentRouteEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function updateReleaseDateFor(Payment $payment, string $routeId, string $
/**
* Update the release date for a payment route using payment ID.
*
* @param DateTimeInterface $releaseDate UTC datetime when the funds will become available
* @param string $releaseDate UTC datetime when the funds will become available
*
* @throws ApiException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/EndpointCollection/ProfileEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getCurrent($testmode = []): CurrentProfile
*
* Will throw an ApiException if the profile id is invalid or the resource cannot be found.
*
* @param array|UpdateProfilePayload $data
* @param array|UpdateProfilePayload $payload
*
* @throws ApiException
*/
Expand Down
5 changes: 2 additions & 3 deletions src/EndpointCollection/SessionEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,9 @@ public function update(string $id, $payload = []): Session
*
* @throws ApiException
*/
public function cancel(string $id): ?Session
public function cancel(string $id): void
{
/** @var Session|null */
return $this->send(new CancelSessionRequest($id));
$this->send(new CancelSessionRequest($id));
}

/**
Expand Down
61 changes: 18 additions & 43 deletions src/EndpointCollection/SettlementEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace Mollie\Api\EndpointCollection;

use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Factories\PaginatedQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Http\Requests\GetPaginatedSettlementRequest;
use Mollie\Api\Factories\GetPaginatedSettlementsQueryFactory;
use Mollie\Api\Http\Requests\GetPaginatedSettlementsRequest;
use Mollie\Api\Http\Requests\GetSettlementRequest;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Settlement;
Expand All @@ -16,90 +15,66 @@ class SettlementEndpointCollection extends EndpointCollection
/**
* Retrieve a single settlement from Mollie.
*
* Will throw an ApiException if the settlement id is invalid or the resource cannot be found.
*
* @param array|bool $testmode
* Will throw a ApiException if the settlement id is invalid or the resource cannot be found.
*
* @throws ApiException
*/
public function get(string $settlementId, $testmode = []): Settlement
public function get(string $settlementId): Settlement
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);

/** @var Settlement */
return $this->send((new GetSettlementRequest($settlementId))->test($testmode));
return $this->send(new GetSettlementRequest($settlementId));
}

/**
* Retrieve the next settlement from Mollie.
*
* @param array|bool $testmode
* Retrieve the details of the current settlement that has not yet been paid out.
*
* @throws ApiException
*/
public function next($testmode = []): ?Settlement
public function next(): Settlement
{
return $this->get('next', $testmode);
return $this->send(new GetSettlementRequest('next'));
}

/**
* Retrieve the open balance from Mollie.
*
* @param array|bool $testmode
* Retrieve the details of the open balance of the organization.
*
* @throws ApiException
*/
public function open($testmode = []): ?Settlement
public function open(): Settlement
{
return $this->get('open', $testmode);
return $this->send(new GetSettlementRequest('open'));
}

/**
* Retrieve a collection of settlements from Mollie.
*
* @param string|null $from The first settlement ID you want to include in your list.
* Retrieves a collection of Settlements from Mollie.
*
* @throws ApiException
*/
public function page(?string $from = null, ?int $limit = null, array $filters = []): SettlementCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);

$query = PaginatedQueryFactory::new([
$query = GetPaginatedSettlementsQueryFactory::new([
'from' => $from,
'limit' => $limit,
'filters' => $filters,
])->create();

/** @var SettlementCollection */
return $this->send((new GetPaginatedSettlementRequest($query))->test($testmode));
return $this->send(new GetPaginatedSettlementsRequest($query));
}

/**
* Create an iterator for iterating over settlements retrieved from Mollie.
*
* @param string|null $from The first settlement ID you want to include in your list.
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*/
public function iterator(
?string $from = null,
?int $limit = null,
array $filters = [],
bool $iterateBackwards = false
): LazyCollection {
$testmode = Helpers::extractBool($filters, 'testmode', false);

$query = PaginatedQueryFactory::new([
public function iterator(?string $from = null, ?int $limit = null, array $filters = [], bool $iterateBackwards = false): LazyCollection
{
$query = GetPaginatedSettlementsQueryFactory::new([
'from' => $from,
'limit' => $limit,
'filters' => $filters,
])->create();

return $this->send(
(new GetPaginatedSettlementRequest($query))
(new GetPaginatedSettlementsRequest($query))
->useIterator()
->setIterationDirection($iterateBackwards)
->test($testmode)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Factories\SortablePaginatedQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Http\Query\GetPaginatedSettlementPaymentsQuery;
use Mollie\Api\Http\Query\SortablePaginatedQuery;
use Mollie\Api\Http\Requests\GetPaginatedSettlementPaymentsRequest;
use Mollie\Api\Resources\LazyCollection;
Expand All @@ -17,7 +16,7 @@ class SettlementPaymentEndpointCollection extends EndpointCollection
/**
* Retrieves a collection of Settlement Payments from Mollie.
*
* @param array|GetPaginatedSettlementPaymentsQuery $query
* @param array|SortablePaginatedQuery $query
*
* @throws ApiException
*/
Expand All @@ -29,7 +28,7 @@ public function pageFor(Settlement $settlement, $query = [], bool $testmode = fa
/**
* Retrieves a collection of Settlement Payments from Mollie.
*
* @param array|GetPaginatedSettlementPaymentsQuery $query
* @param array|SortablePaginatedQuery $query
*
* @throws ApiException
*/
Expand Down
80 changes: 0 additions & 80 deletions src/EndpointCollection/SettlementsEndpointCollection.php

This file was deleted.

Loading

0 comments on commit 4c472c9

Please sign in to comment.