|
38 | 38 | */ |
39 | 39 | final class Builder |
40 | 40 | { |
41 | | - /** |
42 | | - * The object that sends HTTP messages. |
43 | | - * |
44 | | - * @var ClientInterface |
45 | | - */ |
46 | | - private $httpClient; |
47 | | - |
48 | | - /** |
49 | | - * The HTTP request factory. |
50 | | - * |
51 | | - * @var RequestFactoryInterface |
52 | | - */ |
53 | | - private $requestFactory; |
54 | | - |
55 | | - /** |
56 | | - * The HTTP stream factory. |
57 | | - * |
58 | | - * @var StreamFactoryInterface |
59 | | - */ |
60 | | - private $streamFactory; |
61 | | - |
62 | | - /** |
63 | | - * The URI factory. |
64 | | - * |
65 | | - * @var UriFactoryInterface |
66 | | - */ |
67 | | - private $uriFactory; |
| 41 | + private readonly ClientInterface $httpClient; |
| 42 | + private readonly RequestFactoryInterface $requestFactory; |
| 43 | + private readonly StreamFactoryInterface $streamFactory; |
| 44 | + private readonly UriFactoryInterface $uriFactory; |
68 | 45 |
|
69 | 46 | /** |
70 | | - * The currently registered plugins. |
71 | | - * |
72 | 47 | * @var Plugin[] |
73 | 48 | */ |
74 | | - private $plugins = []; |
| 49 | + private array $plugins = []; |
75 | 50 |
|
76 | | - /** |
77 | | - * The cache plugin to use. |
78 | | - * |
79 | | - * This plugin is specially treated because it has to be the very last plugin. |
80 | | - * |
81 | | - * @var CachePlugin|null |
82 | | - */ |
83 | | - private $cachePlugin; |
| 51 | + private ?CachePlugin $cachePlugin; |
84 | 52 |
|
85 | | - /** |
86 | | - * A HTTP client with all our plugins. |
87 | | - * |
88 | | - * @var HttpMethodsClientInterface|null |
89 | | - */ |
90 | | - private $pluginClient; |
| 53 | + private ?HttpMethodsClientInterface $pluginClient; |
91 | 54 |
|
92 | | - /** |
93 | | - * Create a new http client builder instance. |
94 | | - * |
95 | | - * @param ClientInterface|null $httpClient |
96 | | - * @param RequestFactoryInterface|null $requestFactory |
97 | | - * @param StreamFactoryInterface|null $streamFactory |
98 | | - * @param UriFactoryInterface|null $uriFactory |
99 | | - * |
100 | | - * @return void |
101 | | - */ |
102 | 55 | public function __construct( |
103 | | - ClientInterface $httpClient = null, |
104 | | - RequestFactoryInterface $requestFactory = null, |
105 | | - StreamFactoryInterface $streamFactory = null, |
106 | | - UriFactoryInterface $uriFactory = null |
| 56 | + ?ClientInterface $httpClient = null, |
| 57 | + ?RequestFactoryInterface $requestFactory = null, |
| 58 | + ?StreamFactoryInterface $streamFactory = null, |
| 59 | + ?UriFactoryInterface $uriFactory = null |
107 | 60 | ) { |
108 | 61 | $this->httpClient = $httpClient ?? Psr18ClientDiscovery::find(); |
109 | 62 | $this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory(); |
110 | 63 | $this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory(); |
111 | 64 | $this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUriFactory(); |
| 65 | + |
| 66 | + $this->plugins = []; |
| 67 | + $this->cachePlugin = null; |
| 68 | + $this->pluginClient = null; |
112 | 69 | } |
113 | 70 |
|
114 | 71 | /** |
|
0 commit comments