Skip to content

Commit 0d27fbb

Browse files
committed
chore: fix phpstan
1 parent b95cc21 commit 0d27fbb

19 files changed

+59
-51
lines changed

examples/captures/create-capture.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* How to prepare a new payment with the Mollie API.
55
*/
66

7-
use Mollie\Api\Http\Data\CreatePaymentCapturePayload;
87
use Mollie\Api\Http\Data\Money;
98
use Mollie\Api\Http\Requests\CreatePaymentCaptureRequest;
109

@@ -22,10 +21,11 @@
2221
* description Description of the capture.
2322
* metadata Custom metadata that is stored with the payment.
2423
*/
25-
$response = $mollie->send(new CreatePaymentCaptureRequest('tr_WDqYK6vllg', new CreatePaymentCapturePayload(
24+
$response = $mollie->send(new CreatePaymentCaptureRequest(
25+
'tr_WDqYK6vllg',
2626
'Order #12345',
2727
new Money('EUR', '5.00')
28-
)));
28+
));
2929

3030
$capture = $response->toResource();
3131

examples/client-links/create-client-link.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
/*
44
* How to create a new client link in the Mollie API.
55
*/
6-
76
use Mollie\Api\Http\Data\CreateClientLinkPayload;
87
use Mollie\Api\Http\Data\Owner;
98
use Mollie\Api\Http\Data\OwnerAddress;
@@ -29,13 +28,13 @@
2928
*/
3029
$response = $mollie
3130
->send(
32-
new CreateClientLinkRequest(new CreateClientLinkPayload(
31+
new CreateClientLinkRequest(
3332
new Owner('[email protected]', 'foo', 'bar', 'nl_NL'),
3433
'Foo Company',
3534
new OwnerAddress('NL', 'Keizersgracht 313', '1016 EE', 'Amsterdam'),
3635
'30204462',
3736
'NL123456789B01',
38-
))
37+
)
3938
);
4039

4140
$clientLink = $response->toResource();

examples/customers/create-customer-first-payment.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
* How to create a first payment to allow recurring payments later.
55
*/
66

7-
use Mollie\Api\Factories\CreatePaymentRequestFactory;
87
use Mollie\Api\Http\Data\Metadata;
98
use Mollie\Api\Http\Data\Money;
109
use Mollie\Api\Http\Requests\CreateCustomerPaymentRequest;
1110
use Mollie\Api\Http\Requests\GetPaginatedCustomerRequest;
12-
use Mollie\Api\Types\SequenceType;
1311

1412
try {
1513
/*
@@ -40,19 +38,17 @@
4038
*
4139
* @See: https://docs.mollie.com/reference/v2/customers-api/create-customer-payment
4240
*/
43-
$payload = CreatePaymentRequestFactory::new([
44-
'description' => "First payment - Order #{$orderId}",
45-
'amount' => new Money('EUR', '10.00'),
46-
'redirectUrl' => "{$protocol}://{$hostname}/payments/return.php?order_id={$orderId}",
47-
'webhookUrl' => "{$protocol}://{$hostname}/payments/webhook.php",
48-
'metadata' => new Metadata([
49-
'order_id' => $orderId,
50-
]),
51-
'sequenceType' => SequenceType::FIRST,
52-
])->create();
53-
5441
$payment = $mollie->send(
55-
new CreateCustomerPaymentRequest($customer->id, $payload)
42+
new CreateCustomerPaymentRequest(
43+
$customer->id,
44+
"First payment - Order #{$orderId}",
45+
new Money('EUR', '10.00'),
46+
"{$protocol}://{$hostname}/payments/return.php?order_id={$orderId}",
47+
"{$protocol}://{$hostname}/payments/webhook.php",
48+
new Metadata([
49+
'order_id' => $orderId,
50+
])
51+
)
5652
);
5753

5854
/*

phpstan-baseline.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ parameters:
270270
count: 1
271271
path: examples/subscriptions/update-subscription.php
272272

273+
-
274+
message: '#^Unsafe usage of new static\(\)\.$#'
275+
identifier: new.static
276+
count: 1
277+
path: src/Factories/Factory.php
278+
273279
-
274280
message: '#^Unsafe usage of new static\(\)\.$#'
275281
identifier: new.static

src/Contracts/Connector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
interface Connector extends Authenticatable, IdempotencyContract, SupportsDebuggingContract, Testable
99
{
10-
public function send(Request $request): ?object;
10+
/**
11+
* @return mixed
12+
*/
13+
public function send(Request $request);
1114

1215
public function resolveBaseUrl(): string;
1316

src/EndpointCollection/InvoiceEndpointCollection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public function iterator(?string $from = null, ?int $limit = null, array $filter
6161
])
6262
->create();
6363

64-
/** @var InvoiceCollection */
6564
return $this->send(
6665
$request
6766
->useIterator()

src/EndpointCollection/PaymentRefundEndpointCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function createFor(Payment $payment, array $data, $testmode = false): Ref
3535
*/
3636
public function createForId(string $paymentId, array $payload = [], $testmode = false): Refund
3737
{
38-
$testmode = Utility::extractBool($payload, 'testmode', false) ??
38+
$testmode = Utility::extractBool($payload, 'testmode', false) ?:
3939
Utility::extractBool($testmode, 'testmode', false);
4040

4141
$request = CreatePaymentRefundRequestFactory::new($paymentId)

src/EndpointCollection/SessionEndpointCollection.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Mollie\Api\Exceptions\RequestException;
66
use Mollie\Api\Factories\SortablePaginatedQueryFactory;
7-
use Mollie\Api\Http\Data\AnyData;
87
use Mollie\Api\Http\Requests\CancelSessionRequest;
98
use Mollie\Api\Http\Requests\CreateSessionRequest;
109
use Mollie\Api\Http\Requests\GetPaginatedSessionsRequest;
@@ -53,11 +52,11 @@ public function create(array $payload = [], array $query = []): Session
5352
*
5453
* Will throw a ApiException if the session id is invalid or the resource cannot be found.
5554
*
56-
* @param array|AnyData $payload
55+
* @param array $payload
5756
*
5857
* @throws RequestException
5958
*/
60-
public function update(string $id, $payload = []): Session
59+
public function update(string $id, array $payload = []): Session
6160
{
6261
$request = new UpdateSessionRequest($id);
6362

src/Factories/CreateCustomerPaymentRequestFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function create(): CreateCustomerPaymentRequest
5050
$this->payload('sequenceType'),
5151
$this->payload('mandateId'),
5252
$this->payload('profileId'),
53-
$this->payload('additional') ?? Utility::filterByProperties(CreateCustomerPaymentRequest::class, $this->payload()) ?? [],
53+
$this->payload('additional') ?: Utility::filterByProperties(CreateCustomerPaymentRequest::class, $this->payload()) ?: [],
5454
$this->query('includeQrCode', false)
5555
);
5656
}

src/Factories/CreatePaymentRequestFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function create(): CreatePaymentRequest
4343
$this->payload('mandateId'),
4444
$this->payload('customerId'),
4545
$this->payload('profileId'),
46-
$this->payload('additional') ?? Utility::filterByProperties(CreatePaymentRequest::class, $this->payload()) ?? [],
46+
$this->payload('additional') ?: Utility::filterByProperties(CreatePaymentRequest::class, $this->payload()) ?: [],
4747
$this->query('includeQrCode', false)
4848
);
4949
}

0 commit comments

Comments
 (0)