Skip to content

Commit 95c6c23

Browse files
Add types to private and internal properties
1 parent a698209 commit 95c6c23

File tree

5 files changed

+13
-23
lines changed

5 files changed

+13
-23
lines changed

Internal/PushedResponse.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,11 @@
2222
*/
2323
final class PushedResponse
2424
{
25-
public CurlResponse $response;
26-
27-
/** @var string[] */
28-
public array $requestHeaders;
29-
30-
public array $parentOptions = [];
31-
32-
public $handle;
33-
34-
public function __construct(CurlResponse $response, array $requestHeaders, array $parentOptions, $handle)
35-
{
36-
$this->response = $response;
37-
$this->requestHeaders = $requestHeaders;
38-
$this->parentOptions = $parentOptions;
39-
$this->handle = $handle;
25+
public function __construct(
26+
public CurlResponse $response,
27+
public array $requestHeaders,
28+
public array $parentOptions,
29+
public \CurlHandle $handle,
30+
) {
4031
}
4132
}

Response/AsyncResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class AsyncResponse implements ResponseInterface, StreamableInterface
3838
private ResponseInterface $response;
3939
private array $info = ['canceled' => false];
4040
private $passthru;
41-
private $stream;
42-
private $yieldedState;
41+
private ?\Iterator $stream = null;
42+
private ?int $yieldedState = null;
4343

4444
/**
4545
* @param ?callable(ChunkInterface, AsyncContext): ?\Iterator $passthru

Response/CurlResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public function __destruct()
242242

243243
$this->doDestruct();
244244
} finally {
245-
if (\is_resource($this->handle) || $this->handle instanceof \CurlHandle) {
245+
if ($this->handle instanceof \CurlHandle) {
246246
curl_setopt($this->handle, \CURLOPT_VERBOSE, false);
247247
}
248248
}

Response/StreamWrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class StreamWrapper
3030
private ResponseInterface $response;
3131

3232
/** @var resource|string|null */
33-
private $content;
33+
private $content = null;
3434

3535
/** @var resource|callable|null */
3636
private $handle;

RetryableHttpClient.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\HttpClient;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Psr\Log\NullLogger;
1615
use Symfony\Component\HttpClient\Response\AsyncContext;
1716
use Symfony\Component\HttpClient\Response\AsyncResponse;
1817
use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
@@ -34,7 +33,7 @@ class RetryableHttpClient implements HttpClientInterface, ResetInterface
3433

3534
private RetryStrategyInterface $strategy;
3635
private int $maxRetries;
37-
private LoggerInterface $logger;
36+
private ?LoggerInterface $logger;
3837
private array $baseUris = [];
3938

4039
/**
@@ -45,7 +44,7 @@ public function __construct(HttpClientInterface $client, RetryStrategyInterface
4544
$this->client = $client;
4645
$this->strategy = $strategy ?? new GenericRetryStrategy();
4746
$this->maxRetries = $maxRetries;
48-
$this->logger = $logger ?? new NullLogger();
47+
$this->logger = $logger;
4948
}
5049

5150
public function withOptions(array $options): static
@@ -149,7 +148,7 @@ public function request(string $method, string $url, array $options = []): Respo
149148
$content = '';
150149
$firstChunk = null;
151150

152-
$this->logger->info('Try #{count} after {delay}ms'.($exception ? ': '.$exception->getMessage() : ', status code: '.$context->getStatusCode()), [
151+
$this->logger?->info('Try #{count} after {delay}ms'.($exception ? ': '.$exception->getMessage() : ', status code: '.$context->getStatusCode()), [
153152
'count' => $retryCount,
154153
'delay' => $delay,
155154
]);

0 commit comments

Comments
 (0)