1 | <?php |
||
25 | class HttpClient |
||
26 | { |
||
27 | /** |
||
28 | * HTTP client for requests to the application |
||
29 | * |
||
30 | * @var HttpClient |
||
31 | */ |
||
32 | private $httpClient; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $hostname; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | private $port; |
||
43 | |||
44 | /** |
||
45 | * @param string $hostname Default hostname if not specified in the URL |
||
46 | * @param string $port Default port if not specified in the URL |
||
47 | */ |
||
48 | 34 | public function __construct($hostname, $port) |
|
53 | |||
54 | /** |
||
55 | * Get HTTP response from your application |
||
56 | * |
||
57 | * @param string $uri HTTP URI |
||
58 | * @param array $headers HTTP headers |
||
59 | * @param string $method HTTP method |
||
60 | * |
||
61 | * @return ResponseInterface |
||
62 | */ |
||
63 | 34 | public function getResponse($uri, array $headers, $method) |
|
72 | |||
73 | /** |
||
74 | * Get HTTP adapter for your application |
||
75 | * |
||
76 | * @return PhpHttpClient |
||
77 | */ |
||
78 | 34 | private function getHttpClient() |
|
86 | |||
87 | /** |
||
88 | * Create a request |
||
89 | * |
||
90 | * @param string $method |
||
91 | * @param string $uri |
||
92 | * @param array $headers |
||
93 | * |
||
94 | * @return RequestInterface |
||
95 | * @throws \Exception |
||
96 | */ |
||
97 | 34 | private function createRequest($method, $uri, $headers) |
|
98 | { |
||
99 | 34 | $uri = $this->createUri($uri); |
|
100 | 34 | if ($uri->getHost() === '') { |
|
101 | // Add base URI host |
||
102 | 34 | $uri = $uri->withHost($this->hostname); |
|
103 | 34 | } |
|
104 | |||
105 | 34 | if (!$uri->getPort()) { |
|
106 | 34 | $uri = $uri->withPort($this->port); |
|
107 | 34 | } |
|
108 | |||
109 | 34 | if ($uri->getScheme() === '') { |
|
110 | 34 | $uri = $uri->withScheme('http'); |
|
111 | 34 | } |
|
112 | |||
113 | 34 | return MessageFactoryDiscovery::find()->createRequest( |
|
114 | 34 | $method, |
|
115 | 34 | $uri, |
|
116 | $headers |
||
117 | 34 | ); |
|
118 | } |
||
119 | |||
120 | /** |
||
121 | * Create PSR-7 URI object from URI string |
||
122 | * |
||
123 | * @param string $uriString |
||
124 | * |
||
125 | * @return UriInterface |
||
126 | */ |
||
127 | 34 | private function createUri($uriString) |
|
131 | } |
||
132 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..