File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
src/JsonSchema/Uri/Retrievers Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -51,17 +51,12 @@ public function retrieve($uri)
51
51
}
52
52
53
53
$ this ->messageBody = $ response ;
54
- 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 ();
58
- }
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
54
+
55
+ $ httpResponseHeaders = PHP_VERSION >= 80400 ? http_get_last_response_headers () : $ http_response_header ?? [];
56
+
57
+ if (!empty ($ httpResponseHeaders )) {
58
+ $ this ->fetchContentType ($ httpResponseHeaders );
59
+ } else {
65
60
$ this ->contentType = null ;
66
61
}
67
62
@@ -73,7 +68,7 @@ public function retrieve($uri)
73
68
*
74
69
* @return bool Whether the Content-Type header was found or not
75
70
*/
76
- private function fetchContentType (array $ headers )
71
+ private function fetchContentType (array $ headers ): bool
77
72
{
78
73
foreach (array_reverse ($ headers ) as $ header ) {
79
74
if ($ this ->contentType = self ::getContentTypeMatchInHeader ($ header )) {
You can’t perform that action at this time.
0 commit comments