From 6ceabf7293c247186472f0e69dbf8a08ad91544d Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Mon, 26 Jul 2021 00:35:01 -0400 Subject: [PATCH] Clean up --- examples/get_relative.php | 4 ++-- .../get_with_callable_retry_based_on_http_status_code.php | 2 +- examples/google_spreadsheet_values_update.php | 2 +- scripts/bump_major_version.php | 4 ++-- scripts/bump_minor_version.php | 4 ++-- scripts/bump_patch_version.php | 4 ++-- tests/PHPCurlClass/Helper.php | 6 +++--- tests/PHPCurlClass/PHPCurlClassTest.php | 4 ++-- tests/PHPCurlClass/UrlTest.php | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/get_relative.php b/examples/get_relative.php index 2cad1f9..bd79287 100644 --- a/examples/get_relative.php +++ b/examples/get_relative.php @@ -9,12 +9,12 @@ $curl = new Curl('https://www.example.com/api/'); $response = $curl->get('test', [ 'key' => 'value', ]); -assert('https://www.example.com/api/test?key=value' === $curl->url); +assert($curl->url === 'https://www.example.com/api/test?key=value'); assert($curl->url === $curl->effectiveUrl); // https://www.example.com/root?key=value $response = $curl->get('/root', [ 'key' => 'value', ]); -assert('https://www.example.com/root?key=value' === $curl->url); +assert($curl->url === 'https://www.example.com/root?key=value'); assert($curl->url === $curl->effectiveUrl); diff --git a/examples/get_with_callable_retry_based_on_http_status_code.php b/examples/get_with_callable_retry_based_on_http_status_code.php index 768462d..bec2545 100644 --- a/examples/get_with_callable_retry_based_on_http_status_code.php +++ b/examples/get_with_callable_retry_based_on_http_status_code.php @@ -8,7 +8,7 @@ $max_retries = 3; $curl = new Curl(); $curl->setRetry(function ($instance) use ($max_retries) { // Retry when the result of curl_getinfo($instance->curl, CURLINFO_HTTP_CODE) is 500, 503. - return $instance->retries < $max_retries && in_array($instance->httpStatusCode, [500, 503]); + return $instance->retries < $max_retries && in_array($instance->httpStatusCode, [500, 503], true); }); $curl->get('https://httpbin.org/status/503'); diff --git a/examples/google_spreadsheet_values_update.php b/examples/google_spreadsheet_values_update.php index ac1ca38..e72c749 100644 --- a/examples/google_spreadsheet_values_update.php +++ b/examples/google_spreadsheet_values_update.php @@ -10,7 +10,7 @@ const CLIENT_ID = 'XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleuser const CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXX'; const REDIRECT_URI = 'https://www.example.com/oauth2callback'; -if (php_sapi_name() !== 'cli') { +if (PHP_SAPI !== 'cli') { throw new Exception('This application must be run on the command line.'); } diff --git a/scripts/bump_major_version.php b/scripts/bump_major_version.php index 7fe282c..798f9bd 100755 --- a/scripts/bump_major_version.php +++ b/scripts/bump_major_version.php @@ -1,6 +1,6 @@ #!/usr/bin/php server('upload_cleanup', 'POST', [ + assert($download_test->server('upload_cleanup', 'POST', [ 'file_path' => $uploaded_file_path, - ])); + ]) === 'true'); assert(file_exists($uploaded_file_path) === false); } diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index cbc4521..4a30517 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -1054,7 +1054,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testCookieFile() { - $cookie_file = dirname(__FILE__) . '/cookiefile.txt'; + $cookie_file = __DIR__ . '/cookiefile.txt'; $cookie_data = implode("\t", [ '127.0.0.1', // domain 'FALSE', // tailmatch @@ -1079,7 +1079,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testCookieJar() { - $cookie_jar = dirname(__FILE__) . '/cookiejar.txt'; + $cookie_jar = __DIR__ . '/cookiejar.txt'; $test = new Test(); $test->curl->setCookieJar($cookie_jar); diff --git a/tests/PHPCurlClass/UrlTest.php b/tests/PHPCurlClass/UrlTest.php index 94d6fe5..8d3effb 100644 --- a/tests/PHPCurlClass/UrlTest.php +++ b/tests/PHPCurlClass/UrlTest.php @@ -8,7 +8,7 @@ class UrlTest extends \PHPUnit\Framework\TestCase { public function testUrlPaths() { - $urls_file = gzopen(dirname(__FILE__) . '/urls.csv.gz', 'r'); + $urls_file = gzopen(__DIR__ . '/urls.csv.gz', 'r'); fgetcsv($urls_file); // header while (($test = fgetcsv($urls_file)) !== false) { $url = new Url($test[0], $test[1]);