From 9a538f3a6bd6ccad3f76eb4a711c04f820cc6c9b Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Sun, 12 May 2019 21:13:07 -0700 Subject: [PATCH] Reduce number of ops --- src/Curl/CaseInsensitiveArray.php | 2 +- src/Curl/Curl.php | 6 +++--- src/Curl/Encoder.php | 2 +- src/Curl/MultiCurl.php | 4 ++-- tests/PHPCurlClass/Helper.php | 2 +- tests/PHPCurlClass/PHPCurlClassTest.php | 8 ++++---- tests/PHPCurlClass/PHPMultiCurlClassTest.php | 6 +++--- tests/PHPCurlClass/RangeHeader.php | 2 +- tests/PHPCurlClass/server.php | 2 +- tests/script.sh | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Curl/CaseInsensitiveArray.php b/src/Curl/CaseInsensitiveArray.php index 113e9fc..e6dd49c 100644 --- a/src/Curl/CaseInsensitiveArray.php +++ b/src/Curl/CaseInsensitiveArray.php @@ -211,7 +211,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator */ public function valid() { - return (bool) !(key($this->data) === null); + return (bool) (key($this->data) !== null); } /** diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 146acfe..8003cd3 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -371,7 +371,7 @@ class Curl $this->rawResponse = curl_multi_getcontent($ch); $this->curlErrorMessage = curl_error($ch); } - $this->curlError = !($this->curlErrorCode === 0); + $this->curlError = $this->curlErrorCode !== 0; // Transfer the header callback data and release the temporary store to avoid memory leak. $this->rawResponseHeaders = $this->headerCallbackData->rawResponseHeaders; @@ -443,7 +443,7 @@ class Curl $this->call($this->completeCallback); // Close open file handles and reset the curl instance. - if (!($this->fileHandle === null)) { + if ($this->fileHandle !== null) { $this->downloadComplete($this->fileHandle); } } @@ -1007,7 +1007,7 @@ class Curl CURLOPT_RETURNTRANSFER => 'CURLOPT_RETURNTRANSFER', ); - if (in_array($option, array_keys($required_options), true) && !($value === true)) { + if (in_array($option, array_keys($required_options), true) && $value !== true) { trigger_error($required_options[$option] . ' is a required option', E_USER_WARNING); } diff --git a/src/Curl/Encoder.php b/src/Curl/Encoder.php index 67e3e99..ffe7ced 100644 --- a/src/Curl/Encoder.php +++ b/src/Curl/Encoder.php @@ -29,7 +29,7 @@ class Encoder } $value = call_user_func_array('json_encode', $args); - if (!(json_last_error() === JSON_ERROR_NONE)) { + if (json_last_error() !== JSON_ERROR_NONE) { if (function_exists('json_last_error_msg')) { $error_message = 'json_encode error: ' . json_last_error_msg(); } else { diff --git a/src/Curl/MultiCurl.php b/src/Curl/MultiCurl.php index bacc3b6..e35a39b 100644 --- a/src/Curl/MultiCurl.php +++ b/src/Curl/MultiCurl.php @@ -785,7 +785,7 @@ class MultiCurl curl_multi_remove_handle($this->multiCurl, $curl->curl); $curlm_error_code = curl_multi_add_handle($this->multiCurl, $curl->curl); - if (!($curlm_error_code === CURLM_OK)) { + if ($curlm_error_code !== CURLM_OK) { throw new \ErrorException( 'cURL multi add handle error: ' . curl_multi_strerror($curlm_error_code) ); @@ -957,7 +957,7 @@ class MultiCurl } $curlm_error_code = curl_multi_add_handle($this->multiCurl, $curl->curl); - if (!($curlm_error_code === CURLM_OK)) { + if ($curlm_error_code !== CURLM_OK) { throw new \ErrorException('cURL multi add handle error: ' . curl_multi_strerror($curlm_error_code)); } diff --git a/tests/PHPCurlClass/Helper.php b/tests/PHPCurlClass/Helper.php index 32ce1aa..17bed1f 100644 --- a/tests/PHPCurlClass/Helper.php +++ b/tests/PHPCurlClass/Helper.php @@ -110,7 +110,7 @@ function upload_file_to_server($upload_file_path) { $uploaded_file_path = $upload_test->curl->response->file_path; // Ensure files are not the same path. - assert(!($upload_file_path === $uploaded_file_path)); + assert($upload_file_path !== $uploaded_file_path); // Ensure file uploaded successfully. assert(md5_file($upload_file_path) === $upload_test->curl->responseHeaders['ETag']); diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index bc8e5fd..7adcc54 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -915,7 +915,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $expect_error = $test['expect_error']; $test = new Test(); - if (!($max_filesize === false)) { + if ($max_filesize !== false) { $test->curl->setMaxFilesize($max_filesize); } $test->server('download_file_size', 'GET', array( @@ -1095,7 +1095,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $test->server('cookiejar', 'GET'); $test->curl->close(); - $this->assertTrue(!(strpos(file_get_contents($cookie_jar), "\t" . 'mycookie' . "\t" . 'yum') === false)); + $this->assertTrue(strpos(file_get_contents($cookie_jar), "\t" . 'mycookie' . "\t" . 'yum') !== false); unlink($cookie_jar); $this->assertFalse(file_exists($cookie_jar)); } @@ -3521,7 +3521,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $test = new Test(); $test->curl->setOpt(CURLOPT_COOKIEJAR, '/dev/null'); - if (!($maximum_number_of_retries === null)) { + if ($maximum_number_of_retries !== null) { $test->curl->setRetry($maximum_number_of_retries); } @@ -3595,7 +3595,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $test = new Test(); $test->curl->setOpt(CURLOPT_COOKIEJAR, '/dev/null'); - if (!($maximum_number_of_retries === null)) { + if ($maximum_number_of_retries !== null) { $test->curl->setRetry(function ($instance) use ($maximum_number_of_retries) { $return = $instance->retries < $maximum_number_of_retries; return $return; diff --git a/tests/PHPCurlClass/PHPMultiCurlClassTest.php b/tests/PHPCurlClass/PHPMultiCurlClassTest.php index 4e22b4e..5b2a43c 100644 --- a/tests/PHPCurlClass/PHPMultiCurlClassTest.php +++ b/tests/PHPCurlClass/PHPMultiCurlClassTest.php @@ -2565,7 +2565,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase $multi_curl->complete(function ($instance) use (&$multi_curl, &$urls, &$urls_called) { $urls_called[] = $instance->url; $next_url = array_pop($urls); - if (!($next_url === null)) { + if ($next_url !== null) { $multi_curl->addGet($next_url); } }); @@ -2768,7 +2768,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase $multi_curl->setOpt(CURLOPT_COOKIEJAR, '/dev/null'); $multi_curl->setHeader('X-DEBUG-TEST', 'retry'); - if (!($maximum_number_of_retries === null)) { + if ($maximum_number_of_retries !== null) { $multi_curl->setRetry($maximum_number_of_retries); } @@ -2845,7 +2845,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase $multi_curl->setOpt(CURLOPT_COOKIEJAR, '/dev/null'); $multi_curl->setHeader('X-DEBUG-TEST', 'retry'); - if (!($maximum_number_of_retries === null)) { + if ($maximum_number_of_retries !== null) { $multi_curl->setRetry(function ($instance) use ($maximum_number_of_retries) { $return = $instance->retries < $maximum_number_of_retries; return $return; diff --git a/tests/PHPCurlClass/RangeHeader.php b/tests/PHPCurlClass/RangeHeader.php index 3835e15..380d2c5 100644 --- a/tests/PHPCurlClass/RangeHeader.php +++ b/tests/PHPCurlClass/RangeHeader.php @@ -25,7 +25,7 @@ class RangeHeader // "If the last-byte-pos value is present, it MUST be greater than or equal to the first-byte-pos in that // byte-range-spec, or the byte- range-spec is syntactically invalid." - if (!($this->last_byte === null) && !($this->last_byte >= $this->first_byte)) { + if ($this->last_byte !== null && !($this->last_byte >= $this->first_byte)) { $this->is_valid = false; } } diff --git a/tests/PHPCurlClass/server.php b/tests/PHPCurlClass/server.php index 6f48250..3ef0c75 100644 --- a/tests/PHPCurlClass/server.php +++ b/tests/PHPCurlClass/server.php @@ -110,7 +110,7 @@ if ($test === 'http_basic_auth') { $A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2 ); - if (!($data['response'] === $valid_response)) { + if ($data['response'] !== $valid_response) { header('HTTP/1.1 401 Unauthorized'); echo 'invalid'; exit; diff --git a/tests/script.sh b/tests/script.sh index ec41cc0..4b39024 100755 --- a/tests/script.sh +++ b/tests/script.sh @@ -48,7 +48,7 @@ find_invalid_indentation() { $line_number += 1; $leading_space_count = strspn($line, ' '); $remainder = $leading_space_count % 4; - if (!($remainder === 0)) { + if ($remainder !== 0) { // Allow doc comments. if (substr(ltrim($line), 0, 1) === '*') { continue;