@@ -51,17 +51,17 @@ public function retrieve($uri)
51
51
}
52
52
53
53
$ this ->messageBody = $ response ;
54
+
54
55
if (function_exists ('http_get_last_response_headers ' )) {
55
- // Use http_get_last_response_headers() for BC compatibility with PHP 8.5+
56
- // where $http_response_header is deprecated.
57
- $ http_response_header = http_get_last_response_headers ();
56
+ $ httpResponseHeaders = http_get_last_response_headers ();
57
+ } else {
58
+ /** @phpstan-ignore nullCoalesce.variable ($http_response_header can non-existing when no request was made) */
59
+ $ httpResponseHeaders = $ http_response_header ?? [];
58
60
}
59
- if (!empty ($ http_response_header )) {
60
- // $http_response_header cannot be tested, because it's defined in the method's local scope
61
- // See http://php.net/manual/en/reserved.variables.httpresponseheader.php for more info.
62
- $ this ->fetchContentType ($ http_response_header ); // @codeCoverageIgnore
63
- } else { // @codeCoverageIgnore
64
- // Could be a "file://" url or something else - fake up the response
61
+
62
+ if (!empty ($ httpResponseHeaders )) {
63
+ $ this ->fetchContentType ($ httpResponseHeaders );
64
+ } else {
65
65
$ this ->contentType = null ;
66
66
}
67
67
@@ -73,7 +73,7 @@ public function retrieve($uri)
73
73
*
74
74
* @return bool Whether the Content-Type header was found or not
75
75
*/
76
- private function fetchContentType (array $ headers )
76
+ private function fetchContentType (array $ headers ): bool
77
77
{
78
78
foreach (array_reverse ($ headers ) as $ header ) {
79
79
if ($ this ->contentType = self ::getContentTypeMatchInHeader ($ header )) {
0 commit comments