Skip to content

Commit 2c26c8b

Browse files
committed
[HttpClient] Add types to private properties
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent 31762b1 commit 2c26c8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+196
-184
lines changed

AmpHttpClient.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ final class AmpHttpClient implements HttpClientInterface, LoggerAwareInterface,
4242
use HttpClientTrait;
4343
use LoggerAwareTrait;
4444

45-
private $defaultOptions = self::OPTIONS_DEFAULTS;
46-
47-
/** @var AmpClientState */
48-
private $multi;
45+
private array $defaultOptions = self::OPTIONS_DEFAULTS;
46+
private AmpClientState $multi;
4947

5048
/**
5149
* @param array $defaultOptions Default requests' options

CachingHttpClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class CachingHttpClient implements HttpClientInterface
3434
{
3535
use HttpClientTrait;
3636

37-
private $client;
38-
private $cache;
39-
private $defaultOptions = self::OPTIONS_DEFAULTS;
37+
private HttpClientInterface $client;
38+
private HttpCache $cache;
39+
private array $defaultOptions = self::OPTIONS_DEFAULTS;
4040

4141
public function __construct(HttpClientInterface $client, StoreInterface $store, array $defaultOptions = [])
4242
{

Chunk/DataChunk.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
class DataChunk implements ChunkInterface
2222
{
23-
private $offset = 0;
24-
private $content = '';
23+
private int $offset = 0;
24+
private string $content = '';
2525

2626
public function __construct(int $offset = 0, string $content = '')
2727
{

Chunk/ErrorChunk.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
*/
2323
class ErrorChunk implements ChunkInterface
2424
{
25-
private $didThrow = false;
26-
private $offset;
27-
private $errorMessage;
28-
private $error;
25+
private bool $didThrow = false;
26+
private int $offset;
27+
private string $errorMessage;
28+
private ?\Throwable $error = null;
2929

3030
public function __construct(int $offset, \Throwable|string $error)
3131
{

Chunk/InformationalChunk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class InformationalChunk extends DataChunk
2020
{
21-
private $status;
21+
private array $status;
2222

2323
public function __construct(int $statusCode, array $headers)
2424
{

Chunk/ServerSentEvent.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
*/
2020
final class ServerSentEvent extends DataChunk implements ChunkInterface
2121
{
22-
private $data = '';
23-
private $id = '';
24-
private $type = 'message';
25-
private $retry = 0;
22+
private string $data = '';
23+
private string $id = '';
24+
private string $type = 'message';
25+
private float $retry = 0;
2626

2727
public function __construct(string $content)
2828
{

CurlHttpClient.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
3737
use HttpClientTrait;
3838
use LoggerAwareTrait;
3939

40-
private $defaultOptions = self::OPTIONS_DEFAULTS + [
40+
private array $defaultOptions = self::OPTIONS_DEFAULTS + [
4141
'auth_ntlm' => null, // array|string - an array containing the username as first value, and optionally the
4242
// password as the second one; or string like username:password - enabling NTLM auth
4343
'extra' => [
@@ -47,12 +47,10 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
4747

4848
/**
4949
* An internal object to share state between the client and its responses.
50-
*
51-
* @var CurlClientState
5250
*/
53-
private $multi;
51+
private CurlClientState $multi;
5452

55-
private static $curlVersion;
53+
private static array $curlVersion;
5654

5755
/**
5856
* @param array $defaultOptions Default request's options

DataCollector/HttpClientDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class HttpClientDataCollector extends DataCollector implements LateDataCol
2626
/**
2727
* @var TraceableHttpClient[]
2828
*/
29-
private $clients = [];
29+
private array $clients = [];
3030

3131
public function registerClient(string $name, TraceableHttpClient $client)
3232
{

DecoratorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
trait DecoratorTrait
2424
{
25-
private $client;
25+
private HttpClientInterface $client;
2626

2727
public function __construct(HttpClientInterface $client = null)
2828
{

EventSourceHttpClient.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class EventSourceHttpClient implements HttpClientInterface
3030
AsyncDecoratorTrait::withOptions insteadof HttpClientTrait;
3131
}
3232

33-
private $reconnectionTime;
33+
private float $reconnectionTime;
3434

3535
public function __construct(HttpClientInterface $client = null, float $reconnectionTime = 10.0)
3636
{
@@ -52,10 +52,10 @@ public function connect(string $url, array $options = []): ResponseInterface
5252
public function request(string $method, string $url, array $options = []): ResponseInterface
5353
{
5454
$state = new class() {
55-
public $buffer = null;
56-
public $lastEventId = null;
57-
public $reconnectionTime;
58-
public $lastError = null;
55+
public ?string $buffer = null;
56+
public ?string $lastEventId = null;
57+
public float $reconnectionTime;
58+
public ?float $lastError = null;
5959
};
6060
$state->reconnectionTime = $this->reconnectionTime;
6161

0 commit comments

Comments
 (0)