Skip to content

Commit ec74c56

Browse files
committed
fix(PHP): Fix compability warnings for PHP 8.4
BREAKING CHANGE: some of the method signatures has changed with null added. Check the code change
1 parent bbf0d69 commit ec74c56

File tree

11 files changed

+24
-24
lines changed

11 files changed

+24
-24
lines changed

src/AbstractApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function shouldIgnoreLoggersOnException(): ?Closure
7777
*
7878
* @return T
7979
*/
80-
final protected function makeEndpoint(string $endpoint, string $implementation = null): EndpointInterface
80+
final protected function makeEndpoint(string $endpoint, ?string $implementation = null): EndpointInterface
8181
{
8282
if (array_key_exists($endpoint, $this->cachedEndpoints) === false) {
8383
$endpoint = $this->getOverrideEndpointClassIfCan($endpoint, $implementation ?? $endpoint);

src/Actions/MakeApiFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
/**
2828
* Builds API factory using http discovery package
2929
*/
30-
public function execute(LoggerConfigEntity $loggerConfig = null): ApiFactoryContract
30+
public function execute(?LoggerConfigEntity $loggerConfig = null): ApiFactoryContract
3131
{
3232
$request = $this->containerOr(
3333
interface: RequestFactoryInterface::class,

src/Actions/SendRequestAction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function execute(
4545
array $headers = [],
4646
?int $expectedResponseStatusCode = null,
4747
?ResponseInterface $fakedResponse = null,
48-
Closure $shouldIgnoreLoggersOnError = null,
48+
?Closure $shouldIgnoreLoggersOnError = null,
4949
): AbstractResponse {
5050
$timeStart = (float) microtime(true);
5151

@@ -168,7 +168,7 @@ private function getRequestDuration(float $timeStart): float
168168
* @param int|null $expectedResponseStatusCode Will raise and failed
169169
* exception if response
170170
* status code is different
171-
* @param IgnoreLoggersOnExceptionClosure $shouldIgnoreLoggersOnError
171+
* @param IgnoreLoggersOnExceptionClosure|null $shouldIgnoreLoggersOnError
172172
*
173173
* @return TResponse
174174
*/
@@ -183,7 +183,7 @@ private function handleResponse(
183183
string $id,
184184
RequestInterface $request,
185185
float $timeStart,
186-
Closure $shouldIgnoreLoggersOnError = null,
186+
?Closure $shouldIgnoreLoggersOnError = null,
187187
): mixed {
188188
try {
189189
$container = $api->factory()

src/Contracts/SendRequestActionContract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface SendRequestActionContract
2626
* @param int|null $expectedResponseStatusCode Will raise and failed
2727
* exception if response
2828
* status code is different
29-
* @param IgnoreLoggersOnExceptionClosure $shouldIgnoreLoggersOnError
29+
* @param IgnoreLoggersOnExceptionClosure|null $shouldIgnoreLoggersOnError
3030
* @return TResponse
3131
*/
3232
public function execute(
@@ -37,6 +37,6 @@ public function execute(
3737
array $headers = [],
3838
?int $expectedResponseStatusCode = null,
3939
?ResponseInterface $fakedResponse = null,
40-
Closure $shouldIgnoreLoggersOnError = null
40+
?Closure $shouldIgnoreLoggersOnError = null
4141
): AbstractResponse;
4242
}

src/Endpoints/AbstractEndpoint.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
abstract class AbstractEndpoint implements EndpointInterface
2828
{
2929
/**
30-
* @var IgnoreLoggersOnExceptionClosure
30+
* @var IgnoreLoggersOnExceptionClosure|null
3131
*/
3232
private Closure|null $shouldIgnoreLoggersOnException = null;
3333

@@ -142,7 +142,7 @@ final protected function sendGet(
142142
final protected function sendPost(
143143
string $responseClass,
144144
UriInterface $uri,
145-
OptionsInterface|StreamInterface|string $body = null,
145+
OptionsInterface|StreamInterface|string|null $body = null,
146146
array $headers = [],
147147
?int $expectedResponseStatusCode = null,
148148
): AbstractResponse {
@@ -177,10 +177,10 @@ final protected function sendPost(
177177
final protected function sendPut(
178178
string $responseClass,
179179
UriInterface $uri,
180-
OptionsInterface|StreamInterface|string $body = null,
180+
OptionsInterface|StreamInterface|string|null $body = null,
181181
array $headers = [],
182182
?int $expectedResponseStatusCode = null,
183-
Closure $shouldIgnoreLoggersOnError = null,
183+
?Closure $shouldIgnoreLoggersOnError = null,
184184
): AbstractResponse {
185185
$request = $this->factory()
186186
->request()
@@ -215,7 +215,7 @@ final protected function sendPut(
215215
final protected function sendDelete(
216216
string $responseClass,
217217
UriInterface $uri,
218-
OptionsInterface|StreamInterface|string $body = null,
218+
OptionsInterface|StreamInterface|string|null $body = null,
219219
array $headers = [],
220220
?int $expectedResponseStatusCode = null,
221221
): AbstractResponse {
@@ -255,7 +255,7 @@ final protected function sendFake(
255255
ResponseInterface $response,
256256
string $responseClass,
257257
UriInterface $uri,
258-
OptionsInterface|StreamInterface|string $body = null,
258+
OptionsInterface|StreamInterface|string|null $body = null,
259259
array $headers = [],
260260
?int $expectedResponseStatusCode = null,
261261
): AbstractResponse {

src/Endpoints/AbstractFakeEndpoint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function basePath(): string
4040
final protected function makeResponse(
4141
string $responseClass,
4242
GetValue|StreamInterface|null $responseBody = null,
43-
OptionsInterface|StreamInterface|string $requestBody = null,
43+
OptionsInterface|StreamInterface|string|null $requestBody = null,
4444
array $headers = [],
4545
?int $expectedResponseStatusCode = null
4646
): AbstractResponse {

src/Factories/ApiFactory.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@
1515

1616
class ApiFactory implements ApiFactoryContract
1717
{
18-
private readonly LoggerConfigEntity $loggerConfig;
19-
2018
public function __construct(
2119
private readonly RequestFactoryInterface $request,
2220
private readonly ClientInterface $client,
2321
private readonly StreamFactoryInterface $stream,
2422
private readonly SDKContainerFactoryContract $container,
2523
private readonly ResponseFactoryInterface $response,
2624
private readonly ?EventDispatcherInterface $eventDispatcher = null,
27-
LoggerConfigEntity $loggerConfig = null,
25+
private ?LoggerConfigEntity $loggerConfig = null
2826
) {
29-
// By, default no logging is used
30-
$this->loggerConfig = $loggerConfig ?? new LoggerConfigEntity();
3127
}
3228

3329
public function response(): ResponseFactoryInterface
@@ -62,6 +58,10 @@ public function eventDispatcher(): ?EventDispatcherInterface
6258

6359
public function loggerConfig(): LoggerConfigEntity
6460
{
61+
if (! $this->loggerConfig instanceof LoggerConfigEntity) {
62+
$this->loggerConfig = new LoggerConfigEntity();
63+
}
64+
6565
return $this->loggerConfig;
6666
}
6767
}

src/Testing/Assertions/SendTestRequestActionAssert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function execute(
4242
array $headers = [],
4343
?int $expectedResponseStatusCode = null,
4444
?ResponseInterface $fakedResponse = null,
45-
Closure $shouldIgnoreLoggersOnError = null,
45+
?Closure $shouldIgnoreLoggersOnError = null,
4646
): TResponse {
4747
Assert::assertEquals(
4848
expected: 'https://test.localhost' . $this->expectedUri,

src/Testing/Factories/ApiFactoryMock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class ApiFactoryMock implements ApiFactoryContract
2222

2323
public function __construct(
2424
public readonly Client $mockClient = new Client(),
25-
ResponseFactoryInterface $responseFactory = null,
26-
RequestFactoryInterface $requestFactory = null,
25+
?ResponseFactoryInterface $responseFactory = null,
26+
?RequestFactoryInterface $requestFactory = null,
2727
public readonly ?EventDispatcherInterface $eventDispatcher = null,
2828
public readonly TestSDKContainerFactory $testSDKContainerFactory = new TestSDKContainerFactory(),
2929
) {

tests/Endpoints/TestShouldIgnoreLoggersSendRequestActionAssert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function execute(
3636
array $headers = [],
3737
?int $expectedResponseStatusCode = null,
3838
?ResponseInterface $fakedResponse = null,
39-
Closure $shouldIgnoreLoggersOnError = null
39+
?Closure $shouldIgnoreLoggersOnError = null
4040
): AbstractResponse {
4141
Assert::assertNotNull($shouldIgnoreLoggersOnError, 'AbstractEndpoint always builds closure');
4242
Assert::assertEquals($this->expectedIgnoreLoggers, $shouldIgnoreLoggersOnError($this->testException));

0 commit comments

Comments
 (0)