Skip to content

Commit 66d92b9

Browse files
authored
Merge pull request php-curl-class#694 from zachborboa/master
Remove some uses of function_exists()
2 parents 9c08d0b + c4ee562 commit 66d92b9

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

src/Curl/Curl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ public function exec($ch = null)
494494
$this->headerCallbackData->stopRequest = false;
495495

496496
// Include additional error code information in error message when possible.
497-
if ($this->curlError && function_exists('curl_strerror')) {
497+
if ($this->curlError) {
498498
$this->curlErrorMessage =
499499
curl_strerror($this->curlErrorCode) . (
500500
empty($this->curlErrorMessage) ? '' : ': ' . $this->curlErrorMessage
@@ -1567,7 +1567,7 @@ public function diagnose($return = false)
15671567
*/
15681568
public function reset()
15691569
{
1570-
if (function_exists('curl_reset') && (is_resource($this->curl) || $this->curl instanceof \CurlHandle)) {
1570+
if (is_resource($this->curl) || $this->curl instanceof \CurlHandle) {
15711571
curl_reset($this->curl);
15721572
} else {
15731573
$this->curl = curl_init();

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)