Skip to content

Commit 9c03d19

Browse files
committed
Remove some uses of function_exists() where no longer necessary
1 parent 9c08d0b commit 9c03d19

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

tests/PHPCurlClass/Helper.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,12 @@ function get_png()
115115
return $tmp_filename;
116116
}
117117

118-
if (function_exists('finfo_open')) {
119-
function mime_type($file_path)
120-
{
121-
$finfo = finfo_open(FILEINFO_MIME_TYPE);
122-
$mime_type = finfo_file($finfo, $file_path);
123-
finfo_close($finfo);
124-
return $mime_type;
125-
}
126-
} else {
127-
function mime_type($file_path)
128-
{
129-
$mime_type = mime_content_type($file_path);
130-
return $mime_type;
131-
}
118+
function mime_type($file_path)
119+
{
120+
$finfo = finfo_open(FILEINFO_MIME_TYPE);
121+
$mime_type = finfo_file($finfo, $file_path);
122+
finfo_close($finfo);
123+
return $mime_type;
132124
}
133125

134126
function upload_file_to_server($upload_file_path) {

tests/PHPCurlClass/server.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,8 @@
312312
echo '}' . "\n";
313313
exit;
314314
} elseif ($test === 'error_message') {
315-
if (function_exists('http_response_code')) {
316-
http_response_code(401);
317-
} else {
318-
header('HTTP/1.1 401 Unauthorized');
319-
}
315+
// 401 Unauthorized.
316+
http_response_code(401);
320317
exit;
321318
} elseif ($test === 'redirect') {
322319
if (!isset($_GET['redirect'])) {
@@ -342,11 +339,8 @@
342339
echo 'Redirected: ' . $request_method;
343340
} else {
344341
if ($request_method === 'POST') {
345-
if (function_exists('http_response_code')) {
346-
http_response_code(303);
347-
} else {
348-
header('HTTP/1.1 303 See Other');
349-
}
342+
// 303 See Other.
343+
http_response_code(303);
350344

351345
header('Location: ?redirect');
352346
} else {

0 commit comments

Comments
 (0)