diff --git a/README.md b/README.md
index 716a45f..59a583f 100644
--- a/README.md
+++ b/README.md
@@ -59,17 +59,17 @@ if ($curl->error) {
```php
// https://www.example.com/search?q=keyword
$curl = new Curl();
-$curl->get('https://www.example.com/search', array(
+$curl->get('https://www.example.com/search', [
'q' => 'keyword',
-));
+]);
```
```php
$curl = new Curl();
-$curl->post('https://www.example.com/login/', array(
+$curl->post('https://www.example.com/login/', [
'username' => 'myusername',
'password' => 'mypassword',
-));
+]);
```
```php
@@ -100,31 +100,31 @@ $curl->get('https://shortn.example.com/bHbVsP');
```php
$curl = new Curl();
-$curl->put('https://api.example.com/user/', array(
+$curl->put('https://api.example.com/user/', [
'first_name' => 'Zach',
'last_name' => 'Borboa',
-));
+]);
```
```php
$curl = new Curl();
-$curl->patch('https://api.example.com/profile/', array(
+$curl->patch('https://api.example.com/profile/', [
'image' => '@path/to/file.jpg',
-));
+]);
```
```php
$curl = new Curl();
-$curl->patch('https://api.example.com/profile/', array(
+$curl->patch('https://api.example.com/profile/', [
'image' => new CURLFile('path/to/file.jpg'),
-));
+]);
```
```php
$curl = new Curl();
-$curl->delete('https://api.example.com/user/', array(
+$curl->delete('https://api.example.com/user/', [
'id' => '1234',
-));
+]);
```
```php
@@ -175,15 +175,15 @@ $multi_curl->complete(function($instance) {
echo 'call completed' . "\n";
});
-$multi_curl->addGet('https://www.google.com/search', array(
+$multi_curl->addGet('https://www.google.com/search', [
'q' => 'hello world',
-));
-$multi_curl->addGet('https://duckduckgo.com/', array(
+]);
+$multi_curl->addGet('https://duckduckgo.com/', [
'q' => 'hello world',
-));
-$multi_curl->addGet('https://www.bing.com/search', array(
+]);
+$multi_curl->addGet('https://www.bing.com/search', [
'q' => 'hello world',
-));
+]);
$multi_curl->start(); // Blocks until all items in the queue have been processed.
```
@@ -202,13 +202,13 @@ Curl::buildPostData($data)
Curl::call()
Curl::close()
Curl::complete($callback)
-Curl::delete($url, $query_parameters = array(), $data = array())
+Curl::delete($url, $query_parameters = [], $data = [])
Curl::disableTimeout()
Curl::download($url, $mixed_filename)
Curl::error($callback)
Curl::exec($ch = null)
Curl::execDone()
-Curl::get($url, $data = array())
+Curl::get($url, $data = [])
Curl::getAttempts()
Curl::getBeforeSendCallback()
Curl::getCompleteCallback()
@@ -241,19 +241,19 @@ Curl::getRetryDecider()
Curl::getSuccessCallback()
Curl::getUrl()
Curl::getXmlDecoder()
-Curl::head($url, $data = array())
+Curl::head($url, $data = [])
Curl::isChildOfMultiCurl()
Curl::isCurlError()
Curl::isError()
Curl::isHttpError()
-Curl::options($url, $data = array())
-Curl::patch($url, $data = array())
+Curl::options($url, $data = [])
+Curl::patch($url, $data = [])
Curl::post($url, $data = '', $follow_303_with_post = false)
Curl::progress($callback)
-Curl::put($url, $data = array())
+Curl::put($url, $data = [])
Curl::removeHeader($key)
Curl::reset()
-Curl::search($url, $data = array())
+Curl::search($url, $data = [])
Curl::setBasicAuthentication($username, $password = '')
Curl::setConnectTimeout($seconds)
Curl::setCookie($key, $value)
@@ -295,15 +295,15 @@ Curl::verbose($on = true, $output = 'STDERR')
MultiCurl::__construct($base_url = null)
MultiCurl::__destruct()
MultiCurl::addCurl(Curl $curl)
-MultiCurl::addDelete($url, $query_parameters = array(), $data = array())
+MultiCurl::addDelete($url, $query_parameters = [], $data = [])
MultiCurl::addDownload($url, $mixed_filename)
-MultiCurl::addGet($url, $data = array())
-MultiCurl::addHead($url, $data = array())
-MultiCurl::addOptions($url, $data = array())
-MultiCurl::addPatch($url, $data = array())
+MultiCurl::addGet($url, $data = [])
+MultiCurl::addHead($url, $data = [])
+MultiCurl::addOptions($url, $data = [])
+MultiCurl::addPatch($url, $data = [])
MultiCurl::addPost($url, $data = '', $follow_303_with_post = false)
-MultiCurl::addPut($url, $data = array())
-MultiCurl::addSearch($url, $data = array())
+MultiCurl::addPut($url, $data = [])
+MultiCurl::addSearch($url, $data = [])
MultiCurl::beforeSend($callback)
MultiCurl::close()
MultiCurl::complete($callback)
diff --git a/SECURITY.md b/SECURITY.md
index d922198..e228edd 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -21,7 +21,7 @@ echo $curl->response;
Safer:
```php
-function is_allowed_url($url, $allowed_url_schemes = array('http', 'https')) {
+function is_allowed_url($url, $allowed_url_schemes = ['http', 'https']) {
$valid_url = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED) !== false;
if ($valid_url) {
$scheme = parse_url($url, PHP_URL_SCHEME);
@@ -54,9 +54,9 @@ $ curl https://www.example.com/upload_photo.php --data "photo=@/etc/passwd"
```php
// upload_photo.php
$curl = new Curl();
-$curl->post('http://www.anotherwebsite.com/', array(
+$curl->post('http://www.anotherwebsite.com/', [
'photo' => $_POST['photo'], // DANGER!
-));
+]);
```
### Unsafe response with redirection enabled
diff --git a/examples/delete.php b/examples/delete.php
index 4028ac8..af20e13 100644
--- a/examples/delete.php
+++ b/examples/delete.php
@@ -8,14 +8,14 @@ use Curl\Curl;
$curl = new Curl();
$curl->delete(
'https://httpbin.org/delete',
- array(
+ [
'key' => 'value',
- ),
- array(
+ ],
+ [
'a' => '1',
'b' => '2',
'c' => '3',
- )
+ ]
);
if ($curl->error) {
diff --git a/examples/deviant_art_rss.php b/examples/deviant_art_rss.php
index 33ada13..16012d3 100644
--- a/examples/deviant_art_rss.php
+++ b/examples/deviant_art_rss.php
@@ -4,10 +4,10 @@ require __DIR__ . '/../vendor/autoload.php';
use Curl\Curl;
$curl = new Curl();
-$curl->get('http://backend.deviantart.com/rss.xml', array(
+$curl->get('http://backend.deviantart.com/rss.xml', [
'q' => 'boost:popular in:photography/people/fashion',
'type' => 'deviation',
-));
+]);
foreach ($curl->response->channel->item as $entry) {
$thumbnails = $entry->children('http://search.yahoo.com/mrss/')->thumbnail;
diff --git a/examples/flickr.class.php b/examples/flickr.class.php
index b98274c..86bfc61 100644
--- a/examples/flickr.class.php
+++ b/examples/flickr.class.php
@@ -46,23 +46,23 @@ class Flickr
private function getOAuthParameters()
{
- return array(
+ return [
'oauth_nonce' => md5(microtime() . mt_rand()),
'oauth_timestamp' => time(),
'oauth_consumer_key' => FLICKR_API_KEY,
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_version' => '1.0',
- );
+ ];
}
private function getSignature($request_method, $url, $parameters)
{
ksort($parameters, SORT_STRING);
- $request = implode('&', array(
+ $request = implode('&', [
rawurlencode($request_method),
rawurlencode($url),
rawurlencode(http_build_query($parameters, '', '&', PHP_QUERY_RFC3986)),
- ));
+ ]);
$key = FLICKR_API_SECRET . '&';
if (!empty($_SESSION['oauth_access_token_secret'])) {
$key .= $_SESSION['oauth_access_token_secret'];
@@ -76,12 +76,12 @@ class Flickr
private function getRequestToken()
{
$oauth_data = $this->getOAuthParameters();
- $oauth_data['oauth_callback'] = implode('', array(
+ $oauth_data['oauth_callback'] = implode('', [
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http',
'://',
$_SERVER['SERVER_NAME'],
$_SERVER['SCRIPT_NAME'],
- ));
+ ]);
$request_token_url = 'https://www.flickr.com/services/oauth/request_token';
$oauth_data['oauth_signature'] = $this->getSignature('POST', $request_token_url, $oauth_data);
@@ -93,10 +93,10 @@ class Flickr
$_SESSION['oauth_token_secret'] = $parts['oauth_token_secret'];
// Continue to Flickr for user's authorization.
- header('Location: https://secure.flickr.com/services/oauth/authorize?' . http_build_query(array(
+ header('Location: https://secure.flickr.com/services/oauth/authorize?' . http_build_query([
'oauth_token' => $parts['oauth_token'],
'perms' => 'write',
- )));
+ ]));
exit;
}
diff --git a/examples/flickr_photo_search.php b/examples/flickr_photo_search.php
index ab8f518..b8965dd 100644
--- a/examples/flickr_photo_search.php
+++ b/examples/flickr_photo_search.php
@@ -5,7 +5,7 @@ use Curl\Curl;
const FLICKR_API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
-$data = array(
+$data = [
'method' => 'flickr.photos.search',
'api_key' => FLICKR_API_KEY,
'text' => 'happy',
@@ -13,7 +13,7 @@ $data = array(
'safe_search' => '3',
'format' => 'json',
'nojsoncallback' => '1',
-);
+];
$curl = new Curl();
$curl->get('https://api.flickr.com/services/rest/', $data);
diff --git a/examples/get.php b/examples/get.php
index c6928b6..9de37d7 100644
--- a/examples/get.php
+++ b/examples/get.php
@@ -6,9 +6,9 @@ use Curl\Curl;
// curl --request GET "https://httpbin.org/get?key=value"
$curl = new Curl();
-$curl->get('https://httpbin.org/get', array(
+$curl->get('https://httpbin.org/get', [
'key' => 'value',
-));
+]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
diff --git a/examples/get_base_url_1.php b/examples/get_base_url_1.php
index 0b791fd..5f3bcc7 100644
--- a/examples/get_base_url_1.php
+++ b/examples/get_base_url_1.php
@@ -5,8 +5,8 @@ use Curl\Curl;
$curl = new Curl('https://httpbin.org/get');
for ($i = 1; $i <= 10; $i++) {
- $curl->get(array(
+ $curl->get([
'page' => $i,
- ));
+ ]);
// TODO: Do something with result $curl->response.
}
diff --git a/examples/get_base_url_2.php b/examples/get_base_url_2.php
index 3f926eb..2164d87 100644
--- a/examples/get_base_url_2.php
+++ b/examples/get_base_url_2.php
@@ -6,8 +6,8 @@ use Curl\Curl;
$curl = new Curl();
$curl->setUrl('https://httpbin.org/get');
for ($i = 1; $i <= 10; $i++) {
- $curl->get(array(
+ $curl->get([
'page' => $i,
- ));
+ ]);
// TODO: Do something with result $curl->response.
}
diff --git a/examples/get_pages.php b/examples/get_pages.php
index 9cc802a..faf4ade 100644
--- a/examples/get_pages.php
+++ b/examples/get_pages.php
@@ -5,8 +5,8 @@ use Curl\Curl;
$curl = new Curl();
for ($i = 1; $i <= 10; $i++) {
- $curl->get('https://httpbin.org/get', array(
+ $curl->get('https://httpbin.org/get', [
'page' => $i,
- ));
+ ]);
// TODO: Do something with result $curl->response.
}
diff --git a/examples/get_relative.php b/examples/get_relative.php
index 35c77c0..2cad1f9 100644
--- a/examples/get_relative.php
+++ b/examples/get_relative.php
@@ -6,15 +6,15 @@ use Curl\Curl;
$curl = new Curl('https://www.example.com/api/');
// https://www.example.com/api/test?key=value
-$response = $curl->get('test', array(
+$response = $curl->get('test', [
'key' => 'value',
-));
+]);
assert('https://www.example.com/api/test?key=value' === $curl->url);
assert($curl->url === $curl->effectiveUrl);
// https://www.example.com/root?key=value
-$response = $curl->get('/root', array(
+$response = $curl->get('/root', [
'key' => 'value',
-));
+]);
assert('https://www.example.com/root?key=value' === $curl->url);
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 2100b5c..768462d 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, array(500, 503));
+ return $instance->retries < $max_retries && in_array($instance->httpStatusCode, [500, 503]);
});
$curl->get('https://httpbin.org/status/503');
diff --git a/examples/github_create_gist.php b/examples/github_create_gist.php
index 3247466..8620bc1 100644
--- a/examples/github_create_gist.php
+++ b/examples/github_create_gist.php
@@ -10,14 +10,14 @@ EOF;
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
-$curl->post('https://api.github.com/gists', array(
+$curl->post('https://api.github.com/gists', [
'description' => 'PHP-Curl-Class test.',
'public' => 'true',
- 'files' => array(
- 'Untitled.php' => array(
+ 'files' => [
+ 'Untitled.php' => [
'content' => $content,
- ),
- ),
-));
+ ],
+ ],
+]);
echo 'Gist created at ' . $curl->response->html_url . "\n";
diff --git a/examples/gmail_send_email.php b/examples/gmail_send_email.php
index 86e2793..8e79ef5 100644
--- a/examples/gmail_send_email.php
+++ b/examples/gmail_send_email.php
@@ -13,18 +13,18 @@ if (isset($_GET['code'])) {
// Exchange the authorization code for an access token.
$curl = new Curl();
- $curl->post('https://accounts.google.com/o/oauth2/token', array(
+ $curl->post('https://accounts.google.com/o/oauth2/token', [
'code' => $code,
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
- 'redirect_uri' => implode('', array(
+ 'redirect_uri' => implode('', [
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http',
'://',
$_SERVER['SERVER_NAME'],
$_SERVER['SCRIPT_NAME'],
- )),
+ ]),
'grant_type' => 'authorization_code',
- ));
+ ]);
if ($curl->error) {
echo $curl->response->error . ': ' . $curl->response->error_description;
@@ -63,18 +63,18 @@ if (isset($_GET['code'])) {
echo 'Email ' . $curl->response->id . ' was sent.';
} else {
$curl = new Curl();
- $curl->get('https://accounts.google.com/o/oauth2/auth', array(
+ $curl->get('https://accounts.google.com/o/oauth2/auth', [
'scope' => 'https://www.googleapis.com/auth/gmail.compose',
- 'redirect_uri' => implode('', array(
+ 'redirect_uri' => implode('', [
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http',
'://',
$_SERVER['SERVER_NAME'],
$_SERVER['SCRIPT_NAME'],
- )),
+ ]),
'response_type' => 'code',
'client_id' => CLIENT_ID,
'approval_prompt' => 'force',
- ));
+ ]);
$url = $curl->responseHeaders['Location'];
echo 'Continue';
diff --git a/examples/google_maps_geocode_address.php b/examples/google_maps_geocode_address.php
index 908a515..d5bba76 100644
--- a/examples/google_maps_geocode_address.php
+++ b/examples/google_maps_geocode_address.php
@@ -5,9 +5,9 @@ use Curl\Curl;
$address = 'Paris, France';
$curl = new Curl();
-$curl->get('https://maps.googleapis.com/maps/api/geocode/json', array(
+$curl->get('https://maps.googleapis.com/maps/api/geocode/json', [
'address' => $address,
-));
+]);
if ($curl->response->status === 'OK') {
$result = $curl->response->results['0'];
diff --git a/examples/google_plus_profile.php b/examples/google_plus_profile.php
index 817d507..dd0d95a 100644
--- a/examples/google_plus_profile.php
+++ b/examples/google_plus_profile.php
@@ -13,18 +13,18 @@ if (isset($_GET['code'])) {
// Exchange the authorization code for an access token.
$curl = new Curl();
- $curl->post('https://accounts.google.com/o/oauth2/token', array(
+ $curl->post('https://accounts.google.com/o/oauth2/token', [
'code' => $code,
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
- 'redirect_uri' => implode('', array(
+ 'redirect_uri' => implode('', [
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http',
'://',
$_SERVER['SERVER_NAME'],
$_SERVER['SCRIPT_NAME'],
- )),
+ ]),
'grant_type' => 'authorization_code',
- ));
+ ]);
if ($curl->error) {
echo $curl->response->error . ': ' . $curl->response->error_description;
@@ -50,18 +50,18 @@ if (isset($_GET['code'])) {
echo 'Hi ' . $curl->response->displayName . '.';
} else {
$curl = new Curl();
- $curl->get('https://accounts.google.com/o/oauth2/auth', array(
+ $curl->get('https://accounts.google.com/o/oauth2/auth', [
'scope' => 'https://www.googleapis.com/auth/plus.me',
- 'redirect_uri' => implode('', array(
+ 'redirect_uri' => implode('', [
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http',
'://',
$_SERVER['SERVER_NAME'],
$_SERVER['SCRIPT_NAME'],
- )),
+ ]),
'response_type' => 'code',
'client_id' => CLIENT_ID,
'approval_prompt' => 'force',
- ));
+ ]);
$url = $curl->responseHeaders['Location'];
echo 'Continue';
diff --git a/examples/google_spreadsheet_values_update.php b/examples/google_spreadsheet_values_update.php
index b7ba355..ac1ca38 100644
--- a/examples/google_spreadsheet_values_update.php
+++ b/examples/google_spreadsheet_values_update.php
@@ -15,14 +15,14 @@ if (php_sapi_name() !== 'cli') {
}
// Request authorization from the user.
-$auth_url = OAUTH2_AUTH_URL . '?' . http_build_query(array(
+$auth_url = OAUTH2_AUTH_URL . '?' . http_build_query([
'access_type' => 'offline',
'approval_prompt' => 'force',
'client_id' => CLIENT_ID,
'redirect_uri' => REDIRECT_URI,
'response_type' => 'code',
'scope' => 'https://www.googleapis.com/auth/spreadsheets',
-));
+]);
echo 'Open the following link in your browser:' . "\n";
echo $auth_url . "\n";
echo 'Enter verification code: ';
@@ -30,33 +30,33 @@ $code = trim(fgets(STDIN));
// Exchange authorization code for an access token.
$curl = new Curl();
-$curl->post(OAUTH2_TOKEN_URI, array(
+$curl->post(OAUTH2_TOKEN_URI, [
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
'code' => $code,
'grant_type' => 'authorization_code',
'redirect_uri' => REDIRECT_URI,
-));
+]);
$access_token = $curl->response;
// Update spreadsheet.
$spreadsheet_id = '1Z2cXhdG-K44KgSzHTcGhx1dY-xY31yuYGwX21F4GeUp';
$range = 'Sheet1!A1';
$url = 'https://sheets.googleapis.com/v4/spreadsheets/' . $spreadsheet_id . '/values/' . $range;
-$url .= '?' . http_build_query(array(
+$url .= '?' . http_build_query([
'valueInputOption' => 'USER_ENTERED',
-));
+]);
-$data = array(
- 'values' => array(
- array(
+$data = [
+ 'values' => [
+ [
'This is cell A1',
'B1',
'C1',
'and D1',
- ),
- ),
-);
+ ],
+ ],
+];
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
diff --git a/examples/gratipay_send_tip.php b/examples/gratipay_send_tip.php
index 3fc16c1..78eb923 100644
--- a/examples/gratipay_send_tip.php
+++ b/examples/gratipay_send_tip.php
@@ -6,18 +6,18 @@ use Curl\Curl;
const GRATIPAY_USERNAME = 'XXXXXXXXXX';
const GRATIPAY_API_KEY = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
-$data = array(
- array(
+$data = [
+ [
'username' => 'user' . mt_rand(),
'platform' => 'gratipay',
'amount' => '0.02',
- ),
- array(
+ ],
+ [
'username' => 'user' . mt_rand(),
'platform' => 'gratipay',
'amount' => '0.02',
- ),
-);
+ ],
+];
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
diff --git a/examples/head.php b/examples/head.php
index 6c98a3d..e4a0169 100644
--- a/examples/head.php
+++ b/examples/head.php
@@ -6,9 +6,9 @@ use Curl\Curl;
// curl --head "http://127.0.0.1:8000/?key=value"
$curl = new Curl();
-$curl->head('http://127.0.0.1:8000/', array(
+$curl->head('http://127.0.0.1:8000/', [
'key' => 'value',
-));
+]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
diff --git a/examples/instagram_popular_media.php b/examples/instagram_popular_media.php
index 2c30d09..ecbc4c2 100644
--- a/examples/instagram_popular_media.php
+++ b/examples/instagram_popular_media.php
@@ -8,24 +8,24 @@ const INSTAGRAM_CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
session_start();
-$redirect_uri = implode('', array(
+$redirect_uri = implode('', [
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http',
'://',
$_SERVER['SERVER_NAME'],
$_SERVER['SCRIPT_NAME'],
-));
+]);
if (isset($_GET['code'])) {
$code = $_GET['code'];
$curl = new Curl();
- $curl->post('https://api.instagram.com/oauth/access_token', array(
+ $curl->post('https://api.instagram.com/oauth/access_token', [
'client_id' => INSTAGRAM_CLIENT_ID,
'client_secret' => INSTAGRAM_CLIENT_SECRET,
'grant_type' => 'authorization_code',
'redirect_uri' => $redirect_uri,
'code' => $code,
- ));
+ ]);
if ($curl->error) {
echo $curl->response->error_type . ': ' . $curl->response->errorMessage . '
';
@@ -38,9 +38,9 @@ if (isset($_GET['code'])) {
if (isset($_SESSION['access_token'])) {
$curl = new Curl();
- $curl->get('https://api.instagram.com/v1/media/popular', array(
+ $curl->get('https://api.instagram.com/v1/media/popular', [
'access_token' => $_SESSION['access_token'],
- ));
+ ]);
foreach ($curl->response->data as $media) {
echo
'' .
@@ -48,10 +48,10 @@ if (isset($_SESSION['access_token'])) {
'';
}
} else {
- header('Location: https://api.instagram.com/oauth/authorize/?' . http_build_query(array(
+ header('Location: https://api.instagram.com/oauth/authorize/?' . http_build_query([
'client_id' => INSTAGRAM_CLIENT_ID,
'redirect_uri' => $redirect_uri,
'response_type' => 'code',
- )));
+ ]));
exit;
}
diff --git a/examples/instagram_search_photos.php b/examples/instagram_search_photos.php
index 891aa10..f5bfcad 100644
--- a/examples/instagram_search_photos.php
+++ b/examples/instagram_search_photos.php
@@ -6,11 +6,11 @@ use Curl\Curl;
const INSTAGRAM_CLIENT_ID = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$curl = new Curl();
-$curl->get('https://api.instagram.com/v1/media/search', array(
+$curl->get('https://api.instagram.com/v1/media/search', [
'client_id' => INSTAGRAM_CLIENT_ID,
'lat' => '37.8296',
'lng' => '-122.4832',
-));
+]);
foreach ($curl->response->data as $media) {
$image = $media->images->low_resolution;
diff --git a/examples/mailchimp_subscribe_email_address.php b/examples/mailchimp_subscribe_email_address.php
index bac1b94..d92fa1d 100644
--- a/examples/mailchimp_subscribe_email_address.php
+++ b/examples/mailchimp_subscribe_email_address.php
@@ -9,9 +9,9 @@ $MAILCHIMP_BASE_URL = 'https://' . $parts['1'] . '.api.mailchimp.com/2.0/';
$curl = new Curl();
-$curl->get($MAILCHIMP_BASE_URL . '/lists/list.json', array(
+$curl->get($MAILCHIMP_BASE_URL . '/lists/list.json', [
'apikey' => MAILCHIMP_API_KEY,
-));
+]);
if ($curl->response->total === 0) {
echo 'No lists found';
@@ -21,13 +21,13 @@ if ($curl->response->total === 0) {
$lists = $curl->response->data;
$list = $lists['0'];
-$curl->post($MAILCHIMP_BASE_URL . '/lists/subscribe.json', array(
+$curl->post($MAILCHIMP_BASE_URL . '/lists/subscribe.json', [
'apikey' => MAILCHIMP_API_KEY,
'id' => $list->id,
- 'email' => array(
+ 'email' => [
'email' => 'user@example.com',
- ),
-));
+ ],
+]);
if ($curl->error) {
echo $curl->response->name . ': ' . $curl->response->error . "\n";
diff --git a/examples/multi_curl_add_curl.php b/examples/multi_curl_add_curl.php
index 6b3c8e8..87e99a1 100644
--- a/examples/multi_curl_add_curl.php
+++ b/examples/multi_curl_add_curl.php
@@ -11,21 +11,21 @@ $multi_curl->complete(function ($instance) {
$curl_1 = new Curl();
$curl_1->setOpt(CURLOPT_POST, true);
-$curl_1->setOpt(CURLOPT_POSTFIELDS, array(
+$curl_1->setOpt(CURLOPT_POSTFIELDS, [
'to' => 'alice',
'subject' => 'hi',
'body' => 'hi Alice',
-));
+]);
$curl_1->setUrl('https://httpbin.org/post');
$multi_curl->addCurl($curl_1);
$curl_2 = new Curl();
$curl_2->setOpt(CURLOPT_POST, true);
-$curl_2->setOpt(CURLOPT_POSTFIELDS, array(
+$curl_2->setOpt(CURLOPT_POSTFIELDS, [
'to' => 'bob',
'subject' => 'hi',
'body' => 'hi Bob',
-));
+]);
$curl_2->setUrl('https://httpbin.org/post');
$multi_curl->addCurl($curl_2);
diff --git a/examples/multi_curl_before_send.php b/examples/multi_curl_before_send.php
index cec2f98..dd03d61 100644
--- a/examples/multi_curl_before_send.php
+++ b/examples/multi_curl_before_send.php
@@ -3,10 +3,10 @@ require __DIR__ . '/../vendor/autoload.php';
use Curl\MultiCurl;
-$headers = array(
+$headers = [
'Content-Type' => 'application/json',
'X-CUSTOM-HEADER' => 'my-custom-header',
-);
+];
$multi_curl = new MultiCurl();
diff --git a/examples/multi_curl_delete.php b/examples/multi_curl_delete.php
index b1d5854..46d00a8 100644
--- a/examples/multi_curl_delete.php
+++ b/examples/multi_curl_delete.php
@@ -5,11 +5,11 @@ use Curl\MultiCurl;
$multi_curl = new MultiCurl();
-$multi_curl->addDelete('https://httpbin.org/delete', array(
+$multi_curl->addDelete('https://httpbin.org/delete', [
'id' => '123',
-));
-$multi_curl->addDelete('https://httpbin.org/delete', array(
+]);
+$multi_curl->addDelete('https://httpbin.org/delete', [
'id' => '456',
-));
+]);
$multi_curl->start();
diff --git a/examples/multi_curl_get.php b/examples/multi_curl_get.php
index 0aba9bf..abd0a0d 100644
--- a/examples/multi_curl_get.php
+++ b/examples/multi_curl_get.php
@@ -5,14 +5,14 @@ use Curl\MultiCurl;
$multi_curl = new MultiCurl();
-$multi_curl->addGet('https://www.google.com/search', array(
+$multi_curl->addGet('https://www.google.com/search', [
'q' => 'hello world',
-));
-$multi_curl->addGet('https://duckduckgo.com/', array(
+]);
+$multi_curl->addGet('https://duckduckgo.com/', [
'q' => 'hello world',
-));
-$multi_curl->addGet('https://www.bing.com/search', array(
+]);
+$multi_curl->addGet('https://www.bing.com/search', [
'q' => 'hello world',
-));
+]);
$multi_curl->start();
diff --git a/examples/multi_curl_get_callbacks.php b/examples/multi_curl_get_callbacks.php
index 5e21842..0f2065f 100644
--- a/examples/multi_curl_get_callbacks.php
+++ b/examples/multi_curl_get_callbacks.php
@@ -18,14 +18,14 @@ $multi_curl->complete(function ($instance) {
echo 'call to "' . $instance->url . '" completed.' . "\n";
});
-$multi_curl->addGet('https://www.google.com/search', array(
+$multi_curl->addGet('https://www.google.com/search', [
'q' => 'hello world',
-));
-$multi_curl->addGet('https://duckduckgo.com/', array(
+]);
+$multi_curl->addGet('https://duckduckgo.com/', [
'q' => 'hello world',
-));
-$multi_curl->addGet('https://www.bing.com/search', array(
+]);
+$multi_curl->addGet('https://www.bing.com/search', [
'q' => 'hello world',
-));
+]);
$multi_curl->start();
diff --git a/examples/multi_curl_get_load_test.php b/examples/multi_curl_get_load_test.php
index a026801..6b93431 100644
--- a/examples/multi_curl_get_load_test.php
+++ b/examples/multi_curl_get_load_test.php
@@ -4,7 +4,7 @@ require __DIR__ . '/../vendor/autoload.php';
use Curl\MultiCurl;
$server_count = 5;
-$urls = array();
+$urls = [];
$port = 8000;
for ($i = 0; $i < $server_count; $i++) {
$port += 1;
diff --git a/examples/multi_curl_get_with_new_random_proxy.php b/examples/multi_curl_get_with_new_random_proxy.php
index 1997934..58bca60 100644
--- a/examples/multi_curl_get_with_new_random_proxy.php
+++ b/examples/multi_curl_get_with_new_random_proxy.php
@@ -4,11 +4,11 @@ require __DIR__ . '/../vendor/autoload.php';
use Curl\ArrayUtil;
use Curl\MultiCurl;
-$proxies = array(
+$proxies = [
'someproxy.com:9999',
'someproxy.com:80',
'someproxy.com:443',
-);
+];
$max_retries = 3;
$multi_curl = new MultiCurl();
diff --git a/examples/multi_curl_patch.php b/examples/multi_curl_patch.php
index 9efe38f..c546472 100644
--- a/examples/multi_curl_patch.php
+++ b/examples/multi_curl_patch.php
@@ -5,13 +5,13 @@ use Curl\MultiCurl;
$multi_curl = new MultiCurl();
-$multi_curl->addPatch('https://httpbin.org/patch', array(
+$multi_curl->addPatch('https://httpbin.org/patch', [
'id' => '123',
'body' => 'hello world!',
-));
-$multi_curl->addPatch('https://httpbin.org/patch', array(
+]);
+$multi_curl->addPatch('https://httpbin.org/patch', [
'id' => '456',
'body' => 'hello world!',
-));
+]);
$multi_curl->start();
diff --git a/examples/multi_curl_post.php b/examples/multi_curl_post.php
index 1336ae1..997c24a 100644
--- a/examples/multi_curl_post.php
+++ b/examples/multi_curl_post.php
@@ -5,15 +5,15 @@ use Curl\MultiCurl;
$multi_curl = new MultiCurl();
-$multi_curl->addPost('https://httpbin.org/post', array(
+$multi_curl->addPost('https://httpbin.org/post', [
'to' => 'alice',
'subject' => 'hi',
'body' => 'hi Alice',
-));
-$multi_curl->addPost('https://httpbin.org/post', array(
+]);
+$multi_curl->addPost('https://httpbin.org/post', [
'to' => 'bob',
'subject' => 'hi',
'body' => 'hi Bob',
-));
+]);
$multi_curl->start();
diff --git a/examples/multi_curl_proxies.php b/examples/multi_curl_proxies.php
index dd0e76e..3bb00eb 100644
--- a/examples/multi_curl_proxies.php
+++ b/examples/multi_curl_proxies.php
@@ -4,14 +4,14 @@ require __DIR__ . '/../vendor/autoload.php';
use Curl\MultiCurl;
$multi_curl = new MultiCurl();
-$multi_curl->setProxies(array(
+$multi_curl->setProxies([
'someproxy.com:9999',
'someproxy.com:80',
'someproxy.com:443',
'someproxy.com:1080',
'someproxy.com:3128',
'someproxy.com:8080',
-));
+]);
$multi_curl->addGet('https://httpbin.org/ip');
$multi_curl->addGet('https://httpbin.org/ip');
$multi_curl->addGet('https://httpbin.org/ip');
diff --git a/examples/multi_curl_put.php b/examples/multi_curl_put.php
index de7d844..4236aad 100644
--- a/examples/multi_curl_put.php
+++ b/examples/multi_curl_put.php
@@ -5,15 +5,15 @@ use Curl\MultiCurl;
$multi_curl = new MultiCurl();
-$multi_curl->addPut('https://httpbin.org/put', array(
+$multi_curl->addPut('https://httpbin.org/put', [
'id' => '123',
'subject' => 'hello',
'body' => 'hello',
-));
-$multi_curl->addPut('https://httpbin.org/put', array(
+]);
+$multi_curl->addPut('https://httpbin.org/put', [
'id' => '456',
'subject' => 'hello',
'body' => 'hello',
-));
+]);
$multi_curl->start();
diff --git a/examples/multi_curl_set_custom_instance_tag.php b/examples/multi_curl_set_custom_instance_tag.php
index 1b9cf86..3c80690 100644
--- a/examples/multi_curl_set_custom_instance_tag.php
+++ b/examples/multi_curl_set_custom_instance_tag.php
@@ -3,11 +3,11 @@ require __DIR__ . '/../vendor/autoload.php';
use Curl\MultiCurl;
-$urls = array(
+$urls = [
'tag3' => 'https://httpbin.org/post',
'tag4' => 'https://httpbin.org/get',
'tag5' => 'https://httpbin.org/html',
-);
+];
$multi_curl = new MultiCurl();
diff --git a/examples/multi_curl_upload_file.php b/examples/multi_curl_upload_file.php
index cffdaa6..b4aa70d 100644
--- a/examples/multi_curl_upload_file.php
+++ b/examples/multi_curl_upload_file.php
@@ -10,16 +10,16 @@ $multi_curl = new MultiCurl();
// then try uncommenting the following line:
// $multi_curl->setHeader('Content-Type', 'multipart/form-data');
-$multi_curl->addPost('https://httpbin.org/post', array(
+$multi_curl->addPost('https://httpbin.org/post', [
'image' => new CURLFile('the-lorax.jpg'),
-));
+]);
-$multi_curl->addPost('https://httpbin.org/post', array(
+$multi_curl->addPost('https://httpbin.org/post', [
'image' => new CURLFile('swomee-swans.jpg'),
-));
+]);
-$multi_curl->addPost('https://httpbin.org/post', array(
+$multi_curl->addPost('https://httpbin.org/post', [
'image' => new CURLFile('truffula-trees.jpg'),
-));
+]);
$multi_curl->start();
diff --git a/examples/options.php b/examples/options.php
index b1f9d17..92fed89 100644
--- a/examples/options.php
+++ b/examples/options.php
@@ -6,9 +6,9 @@ use Curl\Curl;
// curl --get --request OPTIONS "http://127.0.0.1:8000/" --data "foo=bar"
$curl = new Curl();
-$curl->options('http://127.0.0.1:8000/', array(
+$curl->options('http://127.0.0.1:8000/', [
'foo' => 'bar',
-));
+]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
diff --git a/examples/patch.php b/examples/patch.php
index fac3061..a3ce50f 100644
--- a/examples/patch.php
+++ b/examples/patch.php
@@ -6,11 +6,11 @@ use Curl\Curl;
// curl --request PATCH "https://httpbin.org/patch" --data "a=1&b=2&c=3"
$curl = new Curl();
-$curl->patch('https://httpbin.org/patch', array(
+$curl->patch('https://httpbin.org/patch', [
'a' => '1',
'b' => '2',
'c' => '3',
-));
+]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
diff --git a/examples/post.php b/examples/post.php
index 133b852..5802414 100644
--- a/examples/post.php
+++ b/examples/post.php
@@ -6,11 +6,11 @@ use Curl\Curl;
// curl --request POST "https://httpbin.org/post" --data "id=1&content=Hello+world%21&date=2015-06-30+19%3A42%3A21"
$curl = new Curl();
-$curl->post('https://httpbin.org/post', array(
+$curl->post('https://httpbin.org/post', [
'id' => '1',
'content' => 'Hello world!',
'date' => date('Y-m-d H:i:s'),
-));
+]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
diff --git a/examples/post_json.php b/examples/post_json.php
index c336ab9..37bab8c 100644
--- a/examples/post_json.php
+++ b/examples/post_json.php
@@ -9,11 +9,11 @@ use Curl\Curl;
// -d '{"id":"1","content":"Hello world!","date":"2015-06-30 19:42:21"}' \
// "https://httpbin.org/post"
-$data = array(
+$data = [
'id' => '1',
'content' => 'Hello world!',
'date' => date('Y-m-d H:i:s'),
-);
+];
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
diff --git a/examples/post_json_array_response.php b/examples/post_json_array_response.php
index 3e7e499..ca8cd33 100644
--- a/examples/post_json_array_response.php
+++ b/examples/post_json_array_response.php
@@ -9,11 +9,11 @@ use Curl\Curl;
// -d '{"id":"1","content":"Hello world!","date":"2015-06-30 19:42:21"}' \
// "https://httpbin.org/post"
-$data = array(
+$data = [
'id' => '1',
'content' => 'Hello world!',
'date' => date('Y-m-d H:i:s'),
-);
+];
$curl = new Curl();
$curl->setDefaultJsonDecoder($assoc = true);
diff --git a/examples/post_json_manual_encoding.php b/examples/post_json_manual_encoding.php
index acdf0ff..ca5ab71 100644
--- a/examples/post_json_manual_encoding.php
+++ b/examples/post_json_manual_encoding.php
@@ -9,11 +9,11 @@ use Curl\Curl;
// -d '{"id":"1","content":"Hello world!","date":"2015-06-30 19:42:21"}' \
// "https://httpbin.org/post"
-$data = json_encode(array(
+$data = json_encode([
'id' => '1',
'content' => 'Hello world!',
'date' => date('Y-m-d H:i:s'),
-), JSON_UNESCAPED_UNICODE);
+], JSON_UNESCAPED_UNICODE);
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
diff --git a/examples/post_multiple_values_same_key_with_indexes_explicit.php b/examples/post_multiple_values_same_key_with_indexes_explicit.php
index 07be716..d82bf84 100644
--- a/examples/post_multiple_values_same_key_with_indexes_explicit.php
+++ b/examples/post_multiple_values_same_key_with_indexes_explicit.php
@@ -6,7 +6,7 @@ use Curl\Curl;
// curl "https://httpbin.org/post" -d "foo[0]=bar&foo[1]=baz"
$curl = new Curl();
-$curl->post('https://httpbin.org/post', array(
+$curl->post('https://httpbin.org/post', [
'foo[0]' => 'bar',
'foo[1]' => 'baz',
-));
+]);
diff --git a/examples/post_multiple_values_same_key_with_indexes_implicit.php b/examples/post_multiple_values_same_key_with_indexes_implicit.php
index 1e05f59..780bc79 100644
--- a/examples/post_multiple_values_same_key_with_indexes_implicit.php
+++ b/examples/post_multiple_values_same_key_with_indexes_implicit.php
@@ -6,9 +6,9 @@ use Curl\Curl;
// curl "https://httpbin.org/post" -d "foo[]=bar&foo[]=baz"
$curl = new Curl();
-$curl->post('https://httpbin.org/post', array(
- 'foo' => array(
+$curl->post('https://httpbin.org/post', [
+ 'foo' => [
'bar',
'baz',
- ),
-));
+ ],
+]);
diff --git a/examples/post_multiple_values_same_key_without_indexes.php b/examples/post_multiple_values_same_key_without_indexes.php
index 00514c6..39950cd 100644
--- a/examples/post_multiple_values_same_key_without_indexes.php
+++ b/examples/post_multiple_values_same_key_without_indexes.php
@@ -11,7 +11,7 @@ use Curl\Curl;
// curl "https://httpbin.org/post" -d "foo=bar&foo=baz"
function http_build_query_without_indexes($query) {
- $array = array();
+ $array = [];
foreach ($query as $key => $value) {
$key = rawurlencode($key);
if (is_array($value)) {
@@ -28,11 +28,11 @@ function http_build_query_without_indexes($query) {
}
$curl = new Curl();
-$curl->post('https://httpbin.org/post', http_build_query_without_indexes(array(
- 'foo' => array(
+$curl->post('https://httpbin.org/post', http_build_query_without_indexes([
+ 'foo' => [
'bar',
'baz',
- ),
-)));
+ ],
+]));
// @codingStandardsIgnoreFile
diff --git a/examples/post_redirect_get.php b/examples/post_redirect_get.php
index 581b12d..2c816f5 100644
--- a/examples/post_redirect_get.php
+++ b/examples/post_redirect_get.php
@@ -3,20 +3,20 @@
// using GET requests).
$curl = new Curl();
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
-$curl->post('https://www.example.com/login/', array(
+$curl->post('https://www.example.com/login/', [
'username' => 'myusername',
'password' => 'mypassword',
-));
+]);
// POST data and follow 303 redirections by POSTing data again. Please note
// that 303 redirections should not be handled this way.
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
$curl = new Curl();
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
-$curl->post('https://www.example.com/login/', array(
+$curl->post('https://www.example.com/login/', [
'username' => 'myusername',
'password' => 'mypassword',
-), false);
+], false);
// A POST request performs a post-redirect-get by default. Other request
// methods force an option which conflicts with the post-redirect-get behavior.
diff --git a/examples/put.php b/examples/put.php
index cfd0e5d..b9892a7 100644
--- a/examples/put.php
+++ b/examples/put.php
@@ -6,11 +6,11 @@ use Curl\Curl;
// curl --request PUT "https://httpbin.org/put" --data "id=1&first_name=Zach&last_name=Borboa"
$curl = new Curl();
-$curl->put('https://httpbin.org/put', array(
+$curl->put('https://httpbin.org/put', [
'id' => '1',
'first_name' => 'Zach',
'last_name' => 'Borboa',
-));
+]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
diff --git a/examples/receive_large_file_chunked.php b/examples/receive_large_file_chunked.php
index d2bc687..d5fff18 100644
--- a/examples/receive_large_file_chunked.php
+++ b/examples/receive_large_file_chunked.php
@@ -5,7 +5,7 @@
function file_get_contents_chunked($filename, $chunk_size, $callback) {
$handle = fopen($filename, 'r');
while (!feof($handle)) {
- call_user_func_array($callback, array(fread($handle, $chunk_size)));
+ call_user_func_array($callback, [fread($handle, $chunk_size)]);
}
fclose($handle);
}
diff --git a/examples/reddit_top_pics.php b/examples/reddit_top_pics.php
index 14fd8c4..f79019c 100644
--- a/examples/reddit_top_pics.php
+++ b/examples/reddit_top_pics.php
@@ -3,7 +3,7 @@ require __DIR__ . '/../vendor/autoload.php';
use Curl\Curl;
-$data = array();
+$data = [];
if (isset($_GET['after'])) {
$data['after'] = $_GET['after'];
}
diff --git a/examples/search.php b/examples/search.php
index c6d0ee5..6604b9a 100644
--- a/examples/search.php
+++ b/examples/search.php
@@ -6,11 +6,11 @@ use Curl\Curl;
// curl --request SEARCH "http://127.0.0.1:8000/" --data "a=1&b=2&c=3"
$curl = new Curl();
-$curl->search('http://127.0.0.1:8000/', array(
+$curl->search('http://127.0.0.1:8000/', [
'a' => '1',
'b' => '2',
'c' => '3',
-));
+]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
diff --git a/examples/set_url_1.php b/examples/set_url_1.php
index c79e65b..bbb2f2d 100644
--- a/examples/set_url_1.php
+++ b/examples/set_url_1.php
@@ -11,8 +11,8 @@ $curl = new Curl('https://www.example.com/search');
for ($i = 1; $i <= $pages; $i++) {
// https://www.example.com/search?q=coffee&page=N
- $curl->get(array(
+ $curl->get([
'q' => $q,
'page' => $i,
- ));
+ ]);
}
diff --git a/examples/set_url_2.php b/examples/set_url_2.php
index 0022efd..b296b1d 100644
--- a/examples/set_url_2.php
+++ b/examples/set_url_2.php
@@ -12,8 +12,8 @@ $curl->setUrl('https://www.example.com/search');
for ($i = 1; $i <= $pages; $i++) {
// https://www.example.com/search?q=coffee&page=N
- $curl->get(array(
+ $curl->get([
'q' => $q,
'page' => $i,
- ));
+ ]);
}
diff --git a/examples/twitter_post_tweet.php b/examples/twitter_post_tweet.php
index fa4157f..830d00c 100644
--- a/examples/twitter_post_tweet.php
+++ b/examples/twitter_post_tweet.php
@@ -10,7 +10,7 @@ const OAUTH_TOKEN_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$status = 'I love php curl class. https://github.com/php-curl-class/php-curl-class';
-$oauth_data = array(
+$oauth_data = [
'oauth_consumer_key' => API_KEY,
'oauth_nonce' => md5(microtime() . mt_rand()),
'oauth_signature_method' => 'HMAC-SHA1',
@@ -18,15 +18,15 @@ $oauth_data = array(
'oauth_token' => OAUTH_ACCESS_TOKEN,
'oauth_version' => '1.0',
'status' => $status,
-);
+];
$url = 'https://api.twitter.com/1.1/statuses/update.json';
-$request = implode('&', array(
+$request = implode('&', [
'POST',
rawurlencode($url),
rawurlencode(http_build_query($oauth_data, '', '&', PHP_QUERY_RFC3986)),
-));
-$key = implode('&', array(API_SECRET, OAUTH_TOKEN_SECRET));
+]);
+$key = implode('&', [API_SECRET, OAUTH_TOKEN_SECRET]);
$oauth_data['oauth_signature'] = base64_encode(hash_hmac('sha1', $request, $key, true));
$data = http_build_query($oauth_data, '', '&');
diff --git a/examples/twitter_trending_topics.php b/examples/twitter_trending_topics.php
index ccf1864..23926e5 100644
--- a/examples/twitter_trending_topics.php
+++ b/examples/twitter_trending_topics.php
@@ -10,7 +10,7 @@ const OAUTH_TOKEN_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$woeid = '2487956';
-$oauth_data = array(
+$oauth_data = [
'id' => $woeid,
'oauth_consumer_key' => API_KEY,
'oauth_nonce' => md5(microtime() . mt_rand()),
@@ -18,31 +18,31 @@ $oauth_data = array(
'oauth_timestamp' => time(),
'oauth_token' => OAUTH_ACCESS_TOKEN,
'oauth_version' => '1.0',
-);
+];
$request_values = $oauth_data;
ksort($request_values);
$url = 'https://api.twitter.com/1.1/trends/place.json';
-$request = implode('&', array(
+$request = implode('&', [
'GET',
rawurlencode($url),
rawurlencode(http_build_query($request_values, '', '&', PHP_QUERY_RFC3986)),
-));
-$key = implode('&', array(rawurlencode(API_SECRET), rawurlencode(OAUTH_TOKEN_SECRET)));
+]);
+$key = implode('&', [rawurlencode(API_SECRET), rawurlencode(OAUTH_TOKEN_SECRET)]);
$oauth_data['oauth_signature'] = base64_encode(hash_hmac('sha1', $request, $key, true));
-$authorization = array();
+$authorization = [];
foreach ($oauth_data as $key => $value) {
$authorization[] = $key . '="' . rawurlencode($value) . '"';
}
$authorization = 'Authorization: OAuth ' . implode(', ', $authorization);
$curl = new Curl();
-$curl->setOpt(CURLOPT_HTTPHEADER, array($authorization));
-$curl->get($url, array(
+$curl->setOpt(CURLOPT_HTTPHEADER, [$authorization]);
+$curl->get($url, [
'id' => $woeid,
-));
+]);
echo 'Current trends:' . "\n";
foreach ($curl->response['0']->trends as $trend) {
diff --git a/examples/upload_file.php b/examples/upload_file.php
index 33b2939..d239c2d 100644
--- a/examples/upload_file.php
+++ b/examples/upload_file.php
@@ -12,9 +12,9 @@ $curl = new Curl();
// then try uncommenting the following line:
// $curl->setHeader('Content-Type', 'multipart/form-data');
-$curl->post('https://httpbin.org/post', array(
+$curl->post('https://httpbin.org/post', [
'myfile' => $myfile,
-));
+]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
diff --git a/examples/youtube_list_playlist_videos.php b/examples/youtube_list_playlist_videos.php
index 6e9c96e..bb5337f 100644
--- a/examples/youtube_list_playlist_videos.php
+++ b/examples/youtube_list_playlist_videos.php
@@ -8,12 +8,12 @@ const YOUTUBE_API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$playlistId = 'RDHJb0VYVtaNc';
$curl = new Curl();
-$curl->get('https://www.googleapis.com/youtube/v3/playlistItems', array(
+$curl->get('https://www.googleapis.com/youtube/v3/playlistItems', [
'key' => YOUTUBE_API_KEY,
'maxResults' => '50',
'part' => 'snippet',
'playlistId' => $playlistId,
-));
+]);
echo 'Songs in this playlist:' . "\n";
diff --git a/examples/youtube_video_count.php b/examples/youtube_video_count.php
index 924d7fc..4d76de8 100644
--- a/examples/youtube_video_count.php
+++ b/examples/youtube_video_count.php
@@ -3,14 +3,14 @@ require __DIR__ . '/../vendor/autoload.php';
use Curl\Curl;
-$video_ids = array(
+$video_ids = [
'9bZkp7q19f0',
'_OBlgSz8sSM',
'uelHwf8o7_U',
'KQ6zr6kCPj8',
'ASO_zypdnsQ',
'pRpeEdMmmQ0',
-);
+];
foreach ($video_ids as $video_id) {
$curl = new Curl();
diff --git a/scripts/bump_major_version.php b/scripts/bump_major_version.php
index 729be0b..7fe282c 100755
--- a/scripts/bump_major_version.php
+++ b/scripts/bump_major_version.php
@@ -4,15 +4,15 @@ require dirname(__FILE__) . '/../src/Curl/Curl.php';
$current_version = Curl\Curl::VERSION;
list($major, $_, $__) = explode('.', $current_version);
-$new_version = implode('.', array((string)((int)$major += 1), '0', '0'));
+$new_version = implode('.', [(string)((int)$major += 1), '0', '0']);
-foreach (array(
- array(
+foreach ([
+ [
dirname(__FILE__) . '/../src/Curl/Curl.php',
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
'const VERSION = \'' . $new_version . '\';',
- ),
- ) as $info) {
+ ],
+ ] as $info) {
list($filepath, $find, $replace) = $info;
$data = preg_replace($find, $replace, file_get_contents($filepath));
file_put_contents($filepath, $data);
diff --git a/scripts/bump_minor_version.php b/scripts/bump_minor_version.php
index bb75575..8cdaa29 100755
--- a/scripts/bump_minor_version.php
+++ b/scripts/bump_minor_version.php
@@ -4,15 +4,15 @@ require dirname(__FILE__) . '/../src/Curl/Curl.php';
$current_version = Curl\Curl::VERSION;
list($major, $minor, $_) = explode('.', $current_version);
-$new_version = implode('.', array($major, (string)((int)$minor += 1), '0'));
+$new_version = implode('.', [$major, (string)((int)$minor += 1), '0']);
-foreach (array(
- array(
+foreach ([
+ [
dirname(__FILE__) . '/../src/Curl/Curl.php',
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
'const VERSION = \'' . $new_version . '\';',
- ),
- ) as $info) {
+ ],
+ ] as $info) {
list($filepath, $find, $replace) = $info;
$data = preg_replace($find, $replace, file_get_contents($filepath));
file_put_contents($filepath, $data);
diff --git a/scripts/bump_patch_version.php b/scripts/bump_patch_version.php
index 18594e5..6490980 100755
--- a/scripts/bump_patch_version.php
+++ b/scripts/bump_patch_version.php
@@ -4,15 +4,15 @@ require dirname(__FILE__) . '/../src/Curl/Curl.php';
$current_version = Curl\Curl::VERSION;
list($major, $minor, $patch) = explode('.', $current_version);
-$new_version = implode('.', array($major, $minor, (string)((int)$patch += 1)));
+$new_version = implode('.', [$major, $minor, (string)((int)$patch += 1)]);
-foreach (array(
- array(
+foreach ([
+ [
dirname(__FILE__) . '/../src/Curl/Curl.php',
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
'const VERSION = \'' . $new_version . '\';',
- ),
- ) as $info) {
+ ],
+ ] as $info) {
list($filepath, $find, $replace) = $info;
$data = preg_replace($find, $replace, file_get_contents($filepath));
file_put_contents($filepath, $data);
diff --git a/scripts/update_readme_methods.sh b/scripts/update_readme_methods.sh
index 903f1d3..4a59d17 100755
--- a/scripts/update_readme_methods.sh
+++ b/scripts/update_readme_methods.sh
@@ -34,7 +34,7 @@ echo "${after}" >> "README.md"
script=$(cat <<'EOF'
$data = file_get_contents('README.md');
preg_match_all('/^### ([\w ]+)/m', $data, $matches);
- $toc = array();
+ $toc = [];
foreach ($matches['1'] as $match) {
$href = '#' . str_replace(' ', '-', strtolower($match));
$toc[] = '- [' . $match . '](' . $href . ')';
diff --git a/src/Curl/ArrayUtil.php b/src/Curl/ArrayUtil.php
index ba8aa92..39698a3 100644
--- a/src/Curl/ArrayUtil.php
+++ b/src/Curl/ArrayUtil.php
@@ -78,7 +78,7 @@ class ArrayUtil
*/
public static function arrayFlattenMultidim($array, $prefix = false)
{
- $return = array();
+ $return = [];
if (is_array($array) || is_object($array)) {
if (empty($array)) {
$return[$prefix] = '';
diff --git a/src/Curl/CaseInsensitiveArray.php b/src/Curl/CaseInsensitiveArray.php
index e6dd49c..2592265 100644
--- a/src/Curl/CaseInsensitiveArray.php
+++ b/src/Curl/CaseInsensitiveArray.php
@@ -16,7 +16,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
* @see next()
* @see key()
*/
- private $data = array();
+ private $data = [];
/**
* @var string[] Case-sensitive keys.
@@ -24,7 +24,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
* @see offsetUnset()
* @see key()
*/
- private $keys = array();
+ private $keys = [];
/**
* Construct
diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php
index d16a973..d817b2d 100644
--- a/src/Curl/Curl.php
+++ b/src/Curl/Curl.php
@@ -29,7 +29,7 @@ class Curl
public $requestHeaders = null;
public $responseHeaders = null;
public $rawResponseHeaders = '';
- public $responseCookies = array();
+ public $responseCookies = [];
public $response = null;
public $rawResponse = null;
@@ -50,17 +50,17 @@ class Curl
public $jsonDecoder = null;
public $xmlDecoder = null;
- private $cookies = array();
- private $headers = array();
- private $options = array();
+ private $cookies = [];
+ private $headers = [];
+ private $options = [];
- private $jsonDecoderArgs = array();
+ private $jsonDecoderArgs = [];
private $jsonPattern = '/^(?:application|text)\/(?:[a-z]+(?:[\.-][0-9a-z]+){0,}[\+\.]|x-)?json(?:-[a-z]+)?/i';
- private $xmlDecoderArgs = array();
+ private $xmlDecoderArgs = [];
private $xmlPattern = '~^(?:text/|application/(?:atom\+|rss\+|soap\+)?)xml~i';
private $defaultDecoder = null;
- public static $RFC2616 = array(
+ public static $RFC2616 = [
// RFC 2616: "any CHAR except CTLs or separators".
// CHAR =
// CTL = responseCookies = array();
+ $this->responseCookies = [];
$this->call($this->beforeSendCallback);
$this->rawResponse = curl_exec($this->curl);
$this->curlErrorCode = curl_errno($this->curl);
@@ -479,7 +479,7 @@ class Curl
$this->rawResponseHeaders = $this->headerCallbackData->rawResponseHeaders;
$this->responseCookies = $this->headerCallbackData->responseCookies;
$this->headerCallbackData->rawResponseHeaders = '';
- $this->headerCallbackData->responseCookies = array();
+ $this->headerCallbackData->responseCookies = [];
// Include additional error code information in error message when possible.
if ($this->curlError && function_exists('curl_strerror')) {
@@ -490,7 +490,7 @@ class Curl
}
$this->httpStatusCode = $this->getInfo(CURLINFO_HTTP_CODE);
- $this->httpError = in_array(floor($this->httpStatusCode / 100), array(4, 5));
+ $this->httpError = in_array(floor($this->httpStatusCode / 100), [4, 5]);
$this->error = $this->curlError || $this->httpError;
$this->errorCode = $this->error ? ($this->curlError ? $this->curlErrorCode : $this->httpStatusCode) : 0;
@@ -559,7 +559,7 @@ class Curl
*
* @return mixed Returns the value provided by exec.
*/
- public function get($url, $data = array())
+ public function get($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -581,7 +581,7 @@ class Curl
*/
public function getInfo($opt = null)
{
- $args = array();
+ $args = [];
$args[] = $this->curl;
if (func_num_args()) {
@@ -613,7 +613,7 @@ class Curl
*
* @return mixed Returns the value provided by exec.
*/
- public function head($url, $data = array())
+ public function head($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -634,7 +634,7 @@ class Curl
*
* @return mixed Returns the value provided by exec.
*/
- public function options($url, $data = array())
+ public function options($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -654,7 +654,7 @@ class Curl
*
* @return mixed Returns the value provided by exec.
*/
- public function patch($url, $data = array())
+ public function patch($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -728,7 +728,7 @@ class Curl
*
* @return mixed Returns the value provided by exec.
*/
- public function put($url, $data = array())
+ public function put($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -757,7 +757,7 @@ class Curl
*
* @return mixed Returns the value provided by exec.
*/
- public function search($url, $data = array())
+ public function search($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -1029,7 +1029,7 @@ class Curl
public function setHeader($key, $value)
{
$this->headers[$key] = $value;
- $headers = array();
+ $headers = [];
foreach ($this->headers as $key => $value) {
$headers[] = $key . ': ' . $value;
}
@@ -1061,7 +1061,7 @@ class Curl
}
}
- $headers = array();
+ $headers = [];
foreach ($this->headers as $key => $value) {
$headers[] = $key . ': ' . $value;
}
@@ -1079,7 +1079,7 @@ class Curl
{
if ($mixed === false || is_callable($mixed)) {
$this->jsonDecoder = $mixed;
- $this->jsonDecoderArgs = array();
+ $this->jsonDecoderArgs = [];
}
}
@@ -1093,7 +1093,7 @@ class Curl
{
if ($mixed === false || is_callable($mixed)) {
$this->xmlDecoder = $mixed;
- $this->xmlDecoderArgs = array();
+ $this->xmlDecoderArgs = [];
}
}
@@ -1108,9 +1108,9 @@ class Curl
*/
public function setOpt($option, $value)
{
- $required_options = array(
+ $required_options = [
CURLOPT_RETURNTRANSFER => 'CURLOPT_RETURNTRANSFER',
- );
+ ];
if (in_array($option, array_keys($required_options), true) && $value !== true) {
trigger_error($required_options[$option] . ' is a required option', E_USER_WARNING);
@@ -1385,7 +1385,7 @@ class Curl
public function unsetHeader($key)
{
unset($this->headers[$key]);
- $headers = array();
+ $headers = [];
foreach ($this->headers as $key => $value) {
$headers[] = $key . ': ' . $value;
}
@@ -1620,7 +1620,7 @@ class Curl
public function __get($name)
{
$return = null;
- if (in_array($name, self::$deferredProperties) && is_callable(array($this, $getter = '__get_' . $name))) {
+ if (in_array($name, self::$deferredProperties) && is_callable([$this, $getter = '__get_' . $name])) {
$return = $this->$name = $this->$getter();
}
return $return;
@@ -1768,7 +1768,7 @@ class Curl
}
}
- return array(isset($raw_headers['0']) ? $raw_headers['0'] : '', $http_headers);
+ return [isset($raw_headers['0']) ? $raw_headers['0'] : '', $http_headers];
}
/**
@@ -1870,7 +1870,7 @@ class Curl
*/
private function setEncodedCookie($key, $value)
{
- $name_chars = array();
+ $name_chars = [];
foreach (str_split($key) as $name_char) {
if (isset($this->rfc2616[$name_char])) {
$name_chars[] = $name_char;
@@ -1879,7 +1879,7 @@ class Curl
}
}
- $value_chars = array();
+ $value_chars = [];
foreach (str_split($value) as $value_char) {
if (isset($this->rfc6265[$value_char])) {
$value_chars[] = $value_char;
@@ -1907,7 +1907,7 @@ class Curl
// Create a placeholder to temporarily store the header callback data.
$header_callback_data = new \stdClass();
$header_callback_data->rawResponseHeaders = '';
- $header_callback_data->responseCookies = array();
+ $header_callback_data->responseCookies = [];
$this->headerCallbackData = $header_callback_data;
$this->setOpt(CURLOPT_HEADERFUNCTION, createHeaderCallback($header_callback_data));
diff --git a/src/Curl/MultiCurl.php b/src/Curl/MultiCurl.php
index e2e82f4..3920912 100644
--- a/src/Curl/MultiCurl.php
+++ b/src/Curl/MultiCurl.php
@@ -12,8 +12,8 @@ class MultiCurl
public $startTime = null;
public $stopTime = null;
- private $curls = array();
- private $activeCurls = array();
+ private $curls = [];
+ private $activeCurls = [];
private $isStarted = false;
private $currentStartTime = null;
private $currentRequestCount = 0;
@@ -35,9 +35,9 @@ class MultiCurl
private $retry = null;
- private $cookies = array();
- private $headers = array();
- private $options = array();
+ private $cookies = [];
+ private $headers = [];
+ private $options = [];
private $proxies = null;
private $jsonDecoder = null;
@@ -66,7 +66,7 @@ class MultiCurl
*
* @return object
*/
- public function addDelete($url, $query_parameters = array(), $data = array())
+ public function addDelete($url, $query_parameters = [], $data = [])
{
if (is_array($url)) {
$data = $query_parameters;
@@ -150,7 +150,7 @@ class MultiCurl
*
* @return object
*/
- public function addGet($url, $data = array())
+ public function addGet($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -173,7 +173,7 @@ class MultiCurl
*
* @return object
*/
- public function addHead($url, $data = array())
+ public function addHead($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -196,7 +196,7 @@ class MultiCurl
*
* @return object
*/
- public function addOptions($url, $data = array())
+ public function addOptions($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -219,7 +219,7 @@ class MultiCurl
*
* @return object
*/
- public function addPatch($url, $data = array())
+ public function addPatch($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -290,7 +290,7 @@ class MultiCurl
*
* @return object
*/
- public function addPut($url, $data = array())
+ public function addPut($url, $data = [])
{
if (is_array($url)) {
$data = $url;
@@ -317,7 +317,7 @@ class MultiCurl
*
* @return object
*/
- public function addSearch($url, $data = array())
+ public function addSearch($url, $data = [])
{
if (is_array($url)) {
$data = $url;
diff --git a/src/Curl/Url.php b/src/Curl/Url.php
index 866903c..36094a3 100644
--- a/src/Curl/Url.php
+++ b/src/Curl/Url.php
@@ -101,7 +101,7 @@ class Url
$r = $this->parseUrl($this->relativeUrl);
$r['authorized'] = isset($r['scheme']) || isset($r['host']) || isset($r['port'])
|| isset($r['user']) || isset($r['pass']);
- $target = array();
+ $target = [];
if (isset($r['scheme'])) {
$target['scheme'] = $r['scheme'];
$target['host'] = isset($r['host']) ? $r['host'] : null;
@@ -173,7 +173,7 @@ class Url
// $9 = Related (fragment)
preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/', $url, $output_array);
- $parts = array();
+ $parts = [];
if (isset($output_array['1']) && $output_array['1'] !== '') {
$parts['scheme'] = $output_array['1'];
}
diff --git a/tests/PHPCurlClass/Helper.php b/tests/PHPCurlClass/Helper.php
index efc4c77..156a03f 100644
--- a/tests/PHPCurlClass/Helper.php
+++ b/tests/PHPCurlClass/Helper.php
@@ -60,7 +60,7 @@ class Test
\PHPUnit\Framework\Assert::assertEquals($request_method, $this->curl->responseHeaders['X-REQUEST-METHOD']);
}
- public function chainRequests($first, $second, $data = array())
+ public function chainRequests($first, $second, $data = [])
{
$this->chainedRequest($first, $data);
$this->chainedRequest($second, $data);
@@ -69,7 +69,7 @@ class Test
public static function getTestUrl($port)
{
if (getenv('PHP_CURL_CLASS_LOCAL_TEST') === 'yes' ||
- in_array(getenv('CI_PHP_VERSION'), array('7.0', '7.1', '7.2', '7.3', '7.4', '8.0', 'nightly'))) {
+ in_array(getenv('CI_PHP_VERSION'), ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', 'nightly'])) {
return 'http://127.0.0.1:' . $port . '/';
} else {
return self::TEST_URL;
@@ -129,9 +129,9 @@ if (function_exists('finfo_open')) {
function upload_file_to_server($upload_file_path) {
$upload_test = new Test();
- $upload_test->server('upload_response', 'POST', array(
+ $upload_test->server('upload_response', 'POST', [
'image' => '@' . $upload_file_path,
- ));
+ ]);
$uploaded_file_path = $upload_test->curl->response->file_path;
// Ensure files are not the same path.
@@ -147,9 +147,9 @@ function remove_file_from_server($uploaded_file_path) {
$download_test = new Test();
// Ensure file successfully removed.
- assert('true' === $download_test->server('upload_cleanup', 'POST', array(
+ assert('true' === $download_test->server('upload_cleanup', 'POST', [
'file_path' => $uploaded_file_path,
- )));
+ ]));
assert(file_exists($uploaded_file_path) === false);
}
@@ -172,7 +172,7 @@ function get_multi_curl_property_value($instance, $property_name)
function get_request_stats($request_stats, $multi_curl)
{
$messages =
- array('total duration: ' . sprintf('%.6f', round($multi_curl->stopTime - $multi_curl->startTime, 6)) . "\n");
+ ['total duration: ' . sprintf('%.6f', round($multi_curl->stopTime - $multi_curl->startTime, 6)) . "\n"];
foreach ($request_stats as $instance_id => &$value) {
$value['relative_start'] = sprintf('%.6f', round($value['start'] - $multi_curl->startTime, 6));
diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php
index eb1317a..97ffcad 100644
--- a/tests/PHPCurlClass/PHPCurlClassTest.php
+++ b/tests/PHPCurlClass/PHPCurlClassTest.php
@@ -18,20 +18,20 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testArrayAssociative()
{
- $this->assertTrue(\Curl\ArrayUtil::isArrayAssoc(array(
+ $this->assertTrue(\Curl\ArrayUtil::isArrayAssoc([
'foo' => 'wibble',
'bar' => 'wubble',
'baz' => 'wobble',
- )));
+ ]));
}
public function testArrayIndexed()
{
- $this->assertFalse(\Curl\ArrayUtil::isArrayAssoc(array(
+ $this->assertFalse(\Curl\ArrayUtil::isArrayAssoc([
'wibble',
'wubble',
'wobble',
- )));
+ ]));
}
public function testCaseInsensitiveArrayGet()
@@ -49,7 +49,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testCaseInsensitiveArraySet()
{
$array = new CaseInsensitiveArray();
- foreach (array('FOO', 'FOo', 'Foo', 'fOO', 'fOo', 'foO', 'foo') as $key) {
+ foreach (['FOO', 'FOo', 'Foo', 'fOO', 'fOo', 'foO', 'foo'] as $key) {
$value = mt_rand();
$array[$key] = $value;
$this->assertCount(1, $array);
@@ -68,12 +68,12 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testBuildPostDataArgSeparator()
{
- $data = array(
+ $data = [
'foo' => 'Hello',
'bar' => 'World',
- );
+ ];
- foreach (array(false, '&', '&') as $arg_separator) {
+ foreach ([false, '&', '&'] as $arg_separator) {
if ($arg_separator) {
ini_set('arg_separator.output', $arg_separator);
}
@@ -89,7 +89,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$curl_version = 'curl\/' . $curl_version['version'];
$test = new Test();
- $user_agent = $test->server('server', 'GET', array('key' => 'HTTP_USER_AGENT'));
+ $user_agent = $test->server('server', 'GET', ['key' => 'HTTP_USER_AGENT']);
$this->assertRegExp('/' . $php_version . '/', $user_agent);
$this->assertRegExp('/' . $curl_version . '/', $user_agent);
}
@@ -102,7 +102,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testUrl()
{
- $data = array('foo' => 'bar');
+ $data = ['foo' => 'bar'];
// curl -v --get --request GET "http://127.0.0.1:8000/" --data "foo=bar"
$test = new Test();
@@ -147,11 +147,11 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testSetUrlInConstructor()
{
- $data = array('key' => 'value');
+ $data = ['key' => 'value'];
$curl = new Curl(Test::TEST_URL);
$curl->setHeader('X-DEBUG-TEST', 'delete_with_body');
- $curl->delete($data, array('wibble' => 'wubble'));
+ $curl->delete($data, ['wibble' => 'wubble']);
$this->assertEquals('{"get":{"key":"value"},"delete":{"wibble":"wubble"}}', $curl->rawResponse);
$curl = new Curl(Test::TEST_URL);
@@ -197,7 +197,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testSetUrl()
{
- $data = array('key' => 'value');
+ $data = ['key' => 'value'];
$curl = new Curl();
$curl->setUrl(Test::TEST_URL);
@@ -262,7 +262,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test = new Test();
$test->server('get', 'GET');
$this->assertEquals(Test::TEST_URL, $test->curl->effectiveUrl);
- $test->server('get', 'GET', array('a' => '1', 'b' => '2'));
+ $test->server('get', 'GET', ['a' => '1', 'b' => '2']);
$this->assertEquals(Test::TEST_URL . '?a=1&b=2', $test->curl->effectiveUrl);
}
@@ -307,9 +307,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPostData()
{
$test = new Test();
- $this->assertEquals('key=value', $test->server('post', 'POST', array(
+ $this->assertEquals('key=value', $test->server('post', 'POST', [
'key' => 'value',
- )));
+ ]));
}
public function testPostDataEmptyJson()
@@ -323,16 +323,16 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPostAssociativeArrayData()
{
- $data = array(
+ $data = [
'username' => 'myusername',
'password' => 'mypassword',
- 'more_data' => array(
+ 'more_data' => [
'param1' => 'something',
'param2' => 'other thing',
'param3' => 123,
'param4' => 3.14,
- ),
- );
+ ],
+ ];
$test = new Test();
$test->curl->setDefaultJsonDecoder(true);
@@ -342,12 +342,12 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPostContentLength()
{
- $test_data = array(
- array(false, 0),
- array('', 0),
- array(array(), 0),
- array(null, 0),
- );
+ $test_data = [
+ [false, 0],
+ ['', 0],
+ [[], 0],
+ [null, 0],
+ ];
foreach ($test_data as $data) {
$test = new Test();
list($post_data, $expected_content_length) = $data;
@@ -362,14 +362,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPostMultidimensionalData()
{
- $data = array(
+ $data = [
'key' => 'file',
- 'file' => array(
+ 'file' => [
'wibble',
'wubble',
'wobble',
- ),
- );
+ ],
+ ];
$this->assertEquals(
'key=file&file[0]=wibble&file[1]=wubble&file[2]=wobble',
@@ -384,20 +384,20 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPostMultidimensionalDataWithFile()
{
- $tests = array();
+ $tests = [];
$file_path_1 = \Helper\get_png();
- $tests[] = array(
+ $tests[] = [
'file_path' => $file_path_1,
'post_data_image' => '@' . $file_path_1,
- );
+ ];
if (class_exists('CURLFile')) {
$file_path_2 = \Helper\get_png();
- $tests[] = array(
+ $tests[] = [
'file_path' => $file_path_2,
'post_data_image' => new \CURLFile($file_path_2),
- );
+ ];
}
foreach ($tests as $test_data) {
@@ -411,14 +411,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->curl->setDefaultJsonDecoder($assoc);
// Keep POST data separate from FILES data for comparison.
- $post_data_without_file = array(
+ $post_data_without_file = [
'key' => 'value',
- 'alpha' => array(
+ 'alpha' => [
'a' => '1',
'b' => '2',
'c' => '3',
- ),
- );
+ ],
+ ];
$post_data = $post_data_without_file;
$post_data['image'] = $post_data_image;
@@ -449,10 +449,10 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$file_path = \Helper\get_png();
$test = new Test();
- $this->assertEquals('image/png', $test->server('post_file_path_upload', 'POST', array(
+ $this->assertEquals('image/png', $test->server('post_file_path_upload', 'POST', [
'key' => 'image',
'image' => '@' . $file_path,
- )));
+ ]));
unlink($file_path);
$this->assertFalse(file_exists($file_path));
@@ -464,10 +464,10 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$file_path = \Helper\get_png();
$test = new Test();
- $this->assertEquals('image/png', $test->server('post_file_path_upload', 'POST', array(
+ $this->assertEquals('image/png', $test->server('post_file_path_upload', 'POST', [
'key' => 'image',
'image' => new \CURLFile($file_path),
- )));
+ ]));
unlink($file_path);
$this->assertFalse(file_exists($file_path));
@@ -477,10 +477,10 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPostNonFilePathUpload()
{
$test = new Test();
- $test->server('post', 'POST', array(
+ $test->server('post', 'POST', [
'foo' => 'bar',
'file' => '@not-a-file',
- ));
+ ]);
$this->assertFalse($test->curl->error);
$this->assertEquals('foo=bar&file=%40not-a-file', $test->curl->response);
}
@@ -495,7 +495,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
// Follow 303 redirection with POST
$test = new Test();
$test->curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
- $this->assertEquals('Redirected: POST', $test->server('post_redirect_get', 'POST', array(), true));
+ $this->assertEquals('Redirected: POST', $test->server('post_redirect_get', 'POST', [], true));
// Ensure that it is possible to reuse an existing Curl object.
$this->assertEquals('Redirected: GET', $test->server('post_redirect_get', 'POST'));
@@ -510,14 +510,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPutData()
{
$test = new Test();
- $this->assertEquals('key=value', $test->server('put', 'PUT', array(
+ $this->assertEquals('key=value', $test->server('put', 'PUT', [
'key' => 'value',
- )));
+ ]));
$test = new Test();
- $this->assertEquals('{"key":"value"}', $test->server('put', 'PUT', json_encode(array(
+ $this->assertEquals('{"key":"value"}', $test->server('put', 'PUT', json_encode([
'key' => 'value',
- ))));
+ ])));
}
public function testPutFileHandle()
@@ -544,9 +544,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
// against.
$test = new Test();
$test->curl->setHeader('Content-Type', 'multipart/form-data');
- $test->server('put', 'PUT', array(
+ $test->server('put', 'PUT', [
'foo' => 'bar',
- ));
+ ]);
// Check the "expect" header value only when it is provided in the request.
if (isset($test->curl->requestHeaders['Expect'])) {
@@ -572,24 +572,24 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPatchData()
{
$test = new Test();
- $this->assertEquals('key=value', $test->server('patch', 'PATCH', array(
+ $this->assertEquals('key=value', $test->server('patch', 'PATCH', [
'key' => 'value',
- )));
+ ]));
$test = new Test();
- $this->assertEquals('{"key":"value"}', $test->server('patch', 'PATCH', json_encode(array(
+ $this->assertEquals('{"key":"value"}', $test->server('patch', 'PATCH', json_encode([
'key' => 'value',
- ))));
+ ])));
}
public function testPatchRequestMethodWithMultidimArray()
{
- $data = array(
- 'data' => array(
+ $data = [
+ 'data' => [
'foo' => 'bar',
'wibble' => 'wubble',
- ),
- );
+ ],
+ ];
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'data_values');
@@ -607,7 +607,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testDeleteRequestBody()
{
$test = new Test();
- $test->server('delete_with_body', 'DELETE', array('foo' => 'bar'), array('wibble' => 'wubble'));
+ $test->server('delete_with_body', 'DELETE', ['foo' => 'bar'], ['wibble' => 'wubble']);
$this->assertEquals('{"get":{"foo":"bar"},"delete":{"wibble":"wubble"}}', $test->curl->rawResponse);
}
@@ -615,15 +615,15 @@ class CurlTest extends \PHPUnit\Framework\TestCase
{
$request_body = 'a=1&b=2&c=3';
$test = new Test();
- $test->server('request_method', 'DELETE', array(), $request_body);
+ $test->server('request_method', 'DELETE', [], $request_body);
$this->assertEquals(strlen($request_body), $test->curl->requestHeaders['content-length']);
}
public function testDeleteContentLengthUnsetWithoutBody()
{
- $request_body = array();
+ $request_body = [];
$test = new Test();
- $test->server('request_method', 'DELETE', array(), $request_body);
+ $test->server('request_method', 'DELETE', [], $request_body);
$this->assertFalse(isset($test->curl->requestHeaders['content-length']));
}
@@ -652,9 +652,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$downloaded_file_path = tempnam('/tmp', 'php-curl-class.');
$download_test = new Test();
$download_test->curl->setHeader('X-DEBUG-TEST', 'download_response');
- $this->assertTrue($download_test->curl->download(Test::TEST_URL . '?' . http_build_query(array(
+ $this->assertTrue($download_test->curl->download(Test::TEST_URL . '?' . http_build_query([
'file_path' => $uploaded_file_path,
- )), $downloaded_file_path));
+ ]), $downloaded_file_path));
$this->assertNotEquals($uploaded_file_path, $downloaded_file_path);
$this->assertEquals(filesize($upload_file_path), filesize($downloaded_file_path));
@@ -685,9 +685,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$callback_called = false;
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'download_response');
- $curl->download(Test::TEST_URL . '?' . http_build_query(array(
+ $curl->download(Test::TEST_URL . '?' . http_build_query([
'file_path' => $uploaded_file_path,
- )), function ($instance, $fh) use (&$callback_called) {
+ ]), function ($instance, $fh) use (&$callback_called) {
\PHPUnit\Framework\Assert::assertFalse($callback_called);
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
\PHPUnit\Framework\Assert::assertTrue(is_resource($fh));
@@ -714,7 +714,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$filesize = filesize($filename);
- foreach (array(
+ foreach ([
false,
0,
1,
@@ -745,7 +745,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$filesize + 2,
$filesize + 3,
- ) as $length) {
+ ] as $length) {
$source = Test::TEST_URL;
$destination = \Helper\get_tmp_file_path();
@@ -782,9 +782,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
// Download (the remaining bytes of) the file.
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'download_file_range');
- $curl->download($source . '?' . http_build_query(array(
+ $curl->download($source . '?' . http_build_query([
'file_path' => $uploaded_file_path,
- )), $destination);
+ ]), $destination);
clearstatcache();
@@ -829,75 +829,75 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testMaxFilesize()
{
- $tests = array(
- array(
+ $tests = [
+ [
'bytes' => 1,
'max_filesize' => false,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 1,
'max_filesize' => 1,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 1,
'max_filesize' => 2,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 1,
'max_filesize' => 0,
'expect_error' => true,
- ),
+ ],
- array(
+ [
'bytes' => 2,
'max_filesize' => false,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 2,
'max_filesize' => 2,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 2,
'max_filesize' => 3,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 2,
'max_filesize' => 1,
'expect_error' => true,
- ),
+ ],
- array(
+ [
'bytes' => 1000,
'max_filesize' => false,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 1000,
'max_filesize' => 1000,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 1000,
'max_filesize' => 1001,
'expect_error' => false,
- ),
- array(
+ ],
+ [
'bytes' => 1000,
'max_filesize' => 999,
'expect_error' => true,
- ),
- array(
+ ],
+ [
'bytes' => 1000,
'max_filesize' => 0,
'expect_error' => true,
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$bytes = $test['bytes'];
$max_filesize = $test['max_filesize'];
@@ -907,9 +907,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
if ($max_filesize !== false) {
$test->curl->setMaxFilesize($max_filesize);
}
- $test->server('download_file_size', 'GET', array(
+ $test->server('download_file_size', 'GET', [
'bytes' => $bytes,
- ));
+ ]);
// Ensure exceeding download limit aborts the transfer and sets a CURLE_ABORTED_BY_CALLBACK error.
if ($expect_error) {
@@ -966,20 +966,20 @@ class CurlTest extends \PHPUnit\Framework\TestCase
{
$test = new Test();
$test->curl->setReferrer('myreferrer');
- $this->assertEquals('myreferrer', $test->server('server', 'GET', array(
+ $this->assertEquals('myreferrer', $test->server('server', 'GET', [
'key' => 'HTTP_REFERER',
- )));
+ ]));
$test = new Test();
$test->curl->setReferer('myreferer');
- $this->assertEquals('myreferer', $test->server('server', 'GET', array(
+ $this->assertEquals('myreferer', $test->server('server', 'GET', [
'key' => 'HTTP_REFERER',
- )));
+ ]));
}
public function testResponseBody()
{
- foreach (array(
+ foreach ([
'GET' => 'OK',
'POST' => 'OK',
'PUT' => 'OK',
@@ -988,7 +988,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'DELETE' => 'OK',
'HEAD' => '',
'OPTIONS' => 'OK',
- ) as $request_method => $expected_response) {
+ ] as $request_method => $expected_response) {
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'response_body');
$this->assertEquals($expected_response, $curl->$request_method(Test::TEST_URL));
@@ -1005,11 +1005,11 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testSetCookies()
{
- $cookies = array(
+ $cookies = [
'mycookie' => 'yum',
'fruit' => 'apple',
'color' => 'red',
- );
+ ];
$test = new Test();
$test->curl->setCookies($cookies);
$test->server('setcookie', 'GET');
@@ -1054,7 +1054,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testCookieFile()
{
$cookie_file = dirname(__FILE__) . '/cookiefile.txt';
- $cookie_data = implode("\t", array(
+ $cookie_data = implode("\t", [
'127.0.0.1', // domain
'FALSE', // tailmatch
'/', // path
@@ -1062,15 +1062,15 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'0', // expires
'mycookie', // name
'yum', // value
- )) . "\n";
+ ]) . "\n";
file_put_contents($cookie_file, $cookie_data);
$test = new Test();
$test->curl->setCookieFile($cookie_file);
$this->assertEquals($cookie_data, file_get_contents($test->curl->getOpt(CURLOPT_COOKIEFILE)));
- $this->assertEquals('yum', $test->server('cookie', 'GET', array(
+ $this->assertEquals('yum', $test->server('cookie', 'GET', [
'key' => 'mycookie',
- )));
+ ]));
unlink($cookie_file);
$this->assertFalse(file_exists($cookie_file));
@@ -1103,9 +1103,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testDefaultTimeout()
{
$test = new Test('8001');
- $test->server('timeout', 'GET', array(
+ $test->server('timeout', 'GET', [
'seconds' => '31',
- ));
+ ]);
$this->assertTrue($test->curl->error);
$this->assertTrue($test->curl->curlError);
$this->assertEquals(CURLE_OPERATION_TIMEOUTED, $test->curl->errorCode);
@@ -1117,9 +1117,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
{
$test = new Test('8002');
$test->curl->setTimeout(5);
- $test->server('timeout', 'GET', array(
+ $test->server('timeout', 'GET', [
'seconds' => '10',
- ));
+ ]);
$this->assertTrue($test->curl->error);
$this->assertTrue($test->curl->curlError);
$this->assertEquals(CURLE_OPERATION_TIMEOUTED, $test->curl->errorCode);
@@ -1131,9 +1131,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
{
$test = new Test('8003');
$test->curl->setTimeout(10);
- $test->server('timeout', 'GET', array(
+ $test->server('timeout', 'GET', [
'seconds' => '5',
- ));
+ ]);
$this->assertFalse($test->curl->error, $test->message);
$this->assertFalse($test->curl->curlError, $test->message);
@@ -1148,7 +1148,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->curl->get(Test::ERROR_URL);
$this->assertTrue($test->curl->error);
$this->assertTrue($test->curl->curlError);
- $possible_errors = array(CURLE_SEND_ERROR, CURLE_OPERATION_TIMEOUTED, CURLE_COULDNT_CONNECT, CURLE_GOT_NOTHING);
+ $possible_errors = [CURLE_SEND_ERROR, CURLE_OPERATION_TIMEOUTED, CURLE_COULDNT_CONNECT, CURLE_GOT_NOTHING];
$this->assertTrue(
in_array($test->curl->errorCode, $possible_errors, true),
'errorCode: ' . $test->curl->errorCode
@@ -1185,9 +1185,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->curl->setHeader('Content-Type', 'application/json');
$test->curl->setHeader('X-Requested-With', 'XMLHttpRequest');
$test->curl->setHeader('Accept', 'application/json');
- $this->assertEquals('application/json', $test->server('server', 'GET', array('key' => 'CONTENT_TYPE')));
- $this->assertEquals('XMLHttpRequest', $test->server('server', 'GET', array('key' => 'HTTP_X_REQUESTED_WITH')));
- $this->assertEquals('application/json', $test->server('server', 'GET', array('key' => 'HTTP_ACCEPT')));
+ $this->assertEquals('application/json', $test->server('server', 'GET', ['key' => 'CONTENT_TYPE']));
+ $this->assertEquals('XMLHttpRequest', $test->server('server', 'GET', ['key' => 'HTTP_X_REQUESTED_WITH']));
+ $this->assertEquals('application/json', $test->server('server', 'GET', ['key' => 'HTTP_ACCEPT']));
}
public function testResponseHeaderCaseSensitivity()
@@ -1262,18 +1262,18 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testNestedData()
{
$test = new Test();
- $data = array(
+ $data = [
'username' => 'myusername',
'password' => 'mypassword',
- 'more_data' => array(
+ 'more_data' => [
'param1' => 'something',
'param2' => 'other thing',
- 'another' => array(
+ 'another' => [
'extra' => 'level',
'because' => 'I need it',
- ),
- ),
- );
+ ],
+ ],
+ ];
$this->assertEquals(http_build_query($data), $test->server('post', 'POST', $data));
}
@@ -1287,9 +1287,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testPostArrayUrlEncodedContentType()
{
$test = new Test();
- $test->server('server', 'POST', array(
+ $test->server('server', 'POST', [
'foo' => 'bar',
- ));
+ ]);
$this->assertEquals('application/x-www-form-urlencoded', $test->curl->requestHeaders['Content-Type']);
}
@@ -1298,9 +1298,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$file_path = \Helper\get_png();
$test = new Test();
- $test->server('server', 'POST', array(
+ $test->server('server', 'POST', [
'image' => '@' . $file_path,
- ));
+ ]);
// Check the "expect" header value only when it is provided in the request.
if (isset($test->curl->requestHeaders['Expect'])) {
@@ -1323,9 +1323,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$file_path = \Helper\get_png();
$test = new Test();
- $test->server('server', 'POST', array(
+ $test->server('server', 'POST', [
'image' => new \CURLFile($file_path),
- ));
+ ]);
// Check the "expect" header value only when it is provided in the request.
if (isset($test->curl->requestHeaders['Expect'])) {
@@ -1341,42 +1341,42 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testJsonRequest()
{
- foreach (array(
- array(
- array(
+ foreach ([
+ [
+ [
'key' => 'value',
- ),
+ ],
'{"key":"value"}',
- ),
- array(
- array(
+ ],
+ [
+ [
'key' => 'value',
- 'strings' => array(
+ 'strings' => [
'a',
'b',
'c',
- ),
- ),
+ ],
+ ],
'{"key":"value","strings":["a","b","c"]}',
- ),
- ) as $test) {
+ ],
+ ] as $test) {
list($data, $expected_response) = $test;
$test = new Test();
$this->assertEquals($expected_response, $test->server('post_json', 'POST', json_encode($data)));
- foreach (array(
+ foreach ([
'Content-Type',
'content-type',
- 'CONTENT-TYPE') as $key) {
- foreach (array(
+ 'CONTENT-TYPE'] as $key) {
+ foreach ([
'APPLICATION/JSON',
'APPLICATION/JSON; CHARSET=UTF-8',
'APPLICATION/JSON;CHARSET=UTF-8',
'application/json',
'application/json; charset=utf-8',
'application/json;charset=UTF-8',
- ) as $value) {
+ ] as $value) {
$test = new Test();
$test->curl->setHeader($key, $value);
$this->assertEquals($expected_response, $test->server('post_json', 'POST', json_encode($data)));
@@ -1391,23 +1391,23 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testJsonResponse()
{
- foreach (array(
+ foreach ([
'Content-Type',
'content-type',
- 'CONTENT-TYPE') as $key) {
- foreach (array(
+ 'CONTENT-TYPE'] as $key) {
+ foreach ([
'APPLICATION/JSON',
'APPLICATION/JSON; CHARSET=UTF-8',
'APPLICATION/JSON;CHARSET=UTF-8',
'application/json',
'application/json; charset=utf-8',
'application/json;charset=UTF-8',
- ) as $value) {
+ ] as $value) {
$test = new Test();
- $test->server('json_response', 'POST', array(
+ $test->server('json_response', 'POST', [
'key' => $key,
'value' => $value,
- ));
+ ]);
$response = $test->curl->response;
$this->assertNotNull($response);
@@ -1418,7 +1418,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$this->assertTrue(is_float($response->float));
$this->assertEmpty($response->empty);
$this->assertTrue(is_string($response->string));
- $this->assertEquals(json_encode(array(
+ $this->assertEquals(json_encode([
'null' => null,
'true' => true,
'false' => false,
@@ -1426,7 +1426,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'float' => 3.14,
'empty' => '',
'string' => 'string',
- )), $test->curl->rawResponse);
+ ]), $test->curl->rawResponse);
}
}
}
@@ -1438,9 +1438,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
{
$this->expectException(\ErrorException::class);
- $data = array(
+ $data = [
'malformed' => pack('H*', 'c32e'),
- );
+ ];
$test = new Test();
$test->curl->setHeader('Content-Type', 'application/json');
@@ -1493,7 +1493,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testJsonContentTypeDetection()
{
- $json_content_types = array(
+ $json_content_types = [
'application/alto-costmap+json',
'application/alto-costmapfilter+json',
'application/alto-directory+json',
@@ -1546,7 +1546,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'application/x-json',
'text/json',
'text/x-json',
- );
+ ];
$curl = new Curl();
$json_pattern = \Helper\get_curl_property_value($curl, 'jsonPattern');
@@ -1556,7 +1556,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(1, preg_match($json_pattern, $json_content_type), $message);
}
- $not_json_content_types = array(
+ $not_json_content_types = [
'application/1d-interleaved-parityfec',
'application/3gpdash-qoe-report+xml',
'application/3gpp-ims+xml',
@@ -2625,7 +2625,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'application/yin+xml',
'application/zip',
'application/zlib',
- );
+ ];
foreach ($not_json_content_types as $json_content_type) {
$message = '"' . $json_content_type . '" matches pattern ' . $json_pattern;
@@ -2683,13 +2683,13 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testXmlContentTypeDetection()
{
- $xml_content_types = array(
+ $xml_content_types = [
'application/atom+xml',
'application/rss+xml',
'application/soap+xml',
'application/xml',
'text/xml',
- );
+ ];
$curl = new Curl();
$xml_pattern = \Helper\get_curl_property_value($curl, 'xmlPattern');
@@ -2702,11 +2702,11 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testXmlResponse()
{
- foreach (array(
+ foreach ([
'Content-Type',
'content-type',
- 'CONTENT-TYPE') as $key) {
- foreach (array(
+ 'CONTENT-TYPE'] as $key) {
+ foreach ([
'application/atom+xml; charset=UTF-8',
'application/atom+xml;charset=UTF-8',
'application/rss+xml',
@@ -2721,12 +2721,12 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'text/xml',
'text/xml; charset=utf-8',
'text/xml;charset=utf-8',
- ) as $value) {
+ ] as $value) {
$test = new Test();
- $test->server('xml_response', 'POST', array(
+ $test->server('xml_response', 'POST', [
'key' => $key,
'value' => $value,
- ));
+ ]);
$this->assertInstanceOf('SimpleXMLElement', $test->curl->response);
@@ -2769,29 +2769,29 @@ class CurlTest extends \PHPUnit\Framework\TestCase
// "json".
$test = new Test();
$test->curl->setDefaultDecoder('json');
- $test->server('json_response', 'POST', array(
+ $test->server('json_response', 'POST', [
'key' => 'Content-Type',
'value' => 'application/but-not-json',
- ));
+ ]);
$this->assertInstanceOf('stdClass', $test->curl->response);
// "xml".
$test = new Test();
$test->curl->setDefaultDecoder('xml');
- $test->server('xml_response', 'POST', array(
+ $test->server('xml_response', 'POST', [
'key' => 'Content-Type',
'value' => 'text/but-not-xml',
- ));
+ ]);
$this->assertInstanceOf('SimpleXMLElement', $test->curl->response);
// False.
$test = new Test();
$test->curl->setDefaultDecoder('json');
$test->curl->setDefaultDecoder(false);
- $test->server('json_response', 'POST', array(
+ $test->server('json_response', 'POST', [
'key' => 'Content-Type',
'value' => 'application/but-not-json',
- ));
+ ]);
$this->assertTrue(is_string($test->curl->response));
}
@@ -2831,32 +2831,32 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testArrayToStringConversion()
{
$test = new Test();
- $test->server('post', 'POST', array(
+ $test->server('post', 'POST', [
'foo' => 'bar',
- 'baz' => array(
- ),
- ));
+ 'baz' => [
+ ],
+ ]);
$this->assertEquals('foo=bar&baz=', $test->curl->response);
$test = new Test();
- $test->server('post', 'POST', array(
+ $test->server('post', 'POST', [
'foo' => 'bar',
- 'baz' => array(
- 'qux' => array(
- ),
- ),
- ));
+ 'baz' => [
+ 'qux' => [
+ ],
+ ],
+ ]);
$this->assertEquals('foo=bar&baz[qux]=', urldecode($test->curl->response));
$test = new Test();
- $test->server('post', 'POST', array(
+ $test->server('post', 'POST', [
'foo' => 'bar',
- 'baz' => array(
- 'qux' => array(
- ),
+ 'baz' => [
+ 'qux' => [
+ ],
'wibble' => 'wobble',
- ),
- ));
+ ],
+ ]);
$this->assertEquals('foo=bar&baz[qux]=&baz[wibble]=wobble', urldecode($test->curl->response));
}
@@ -3040,14 +3040,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->chainRequests('GET', 'GET');
$test = new Test();
- $test->chainRequests('GET', 'POST', array('a' => '1'));
- $test->chainRequests('GET', 'PUT', array('b' => '22'));
- $test->chainRequests('GET', 'PATCH', array('c' => '333'));
- $test->chainRequests('GET', 'DELETE', array('d' => '4444'));
- $test->chainRequests('GET', 'HEAD', array('e' => '55555'));
- $test->chainRequests('GET', 'OPTIONS', array('f' => '666666'));
- $test->chainRequests('GET', 'SEARCH', array('h' => '7777777'));
- $test->chainRequests('GET', 'GET', array('g' => '88888888'));
+ $test->chainRequests('GET', 'POST', ['a' => '1']);
+ $test->chainRequests('GET', 'PUT', ['b' => '22']);
+ $test->chainRequests('GET', 'PATCH', ['c' => '333']);
+ $test->chainRequests('GET', 'DELETE', ['d' => '4444']);
+ $test->chainRequests('GET', 'HEAD', ['e' => '55555']);
+ $test->chainRequests('GET', 'OPTIONS', ['f' => '666666']);
+ $test->chainRequests('GET', 'SEARCH', ['h' => '7777777']);
+ $test->chainRequests('GET', 'GET', ['g' => '88888888']);
}
public function testRequestMethodSuccessivePostRequests()
@@ -3063,14 +3063,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->chainRequests('POST', 'POST');
$test = new Test();
- $test->chainRequests('POST', 'GET', array('a' => '1'));
- $test->chainRequests('POST', 'PUT', array('b' => '22'));
- $test->chainRequests('POST', 'PATCH', array('c' => '333'));
- $test->chainRequests('POST', 'DELETE', array('d' => '4444'));
- $test->chainRequests('POST', 'HEAD', array('e' => '55555'));
- $test->chainRequests('POST', 'OPTIONS', array('f' => '666666'));
- $test->chainRequests('POST', 'SEARCH', array('g' => '7777777'));
- $test->chainRequests('POST', 'POST', array('g' => '88888888'));
+ $test->chainRequests('POST', 'GET', ['a' => '1']);
+ $test->chainRequests('POST', 'PUT', ['b' => '22']);
+ $test->chainRequests('POST', 'PATCH', ['c' => '333']);
+ $test->chainRequests('POST', 'DELETE', ['d' => '4444']);
+ $test->chainRequests('POST', 'HEAD', ['e' => '55555']);
+ $test->chainRequests('POST', 'OPTIONS', ['f' => '666666']);
+ $test->chainRequests('POST', 'SEARCH', ['g' => '7777777']);
+ $test->chainRequests('POST', 'POST', ['g' => '88888888']);
}
public function testRequestMethodSuccessivePutRequests()
@@ -3086,14 +3086,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->chainRequests('PUT', 'PUT');
$test = new Test();
- $test->chainRequests('PUT', 'GET', array('a' => '1'));
- $test->chainRequests('PUT', 'POST', array('b' => '22'));
- $test->chainRequests('PUT', 'PATCH', array('c' => '333'));
- $test->chainRequests('PUT', 'DELETE', array('d' => '4444'));
- $test->chainRequests('PUT', 'HEAD', array('e' => '55555'));
- $test->chainRequests('PUT', 'OPTIONS', array('f' => '666666'));
- $test->chainRequests('PUT', 'SEARCH', array('f' => '7777777'));
- $test->chainRequests('PUT', 'PUT', array('g' => '88888888'));
+ $test->chainRequests('PUT', 'GET', ['a' => '1']);
+ $test->chainRequests('PUT', 'POST', ['b' => '22']);
+ $test->chainRequests('PUT', 'PATCH', ['c' => '333']);
+ $test->chainRequests('PUT', 'DELETE', ['d' => '4444']);
+ $test->chainRequests('PUT', 'HEAD', ['e' => '55555']);
+ $test->chainRequests('PUT', 'OPTIONS', ['f' => '666666']);
+ $test->chainRequests('PUT', 'SEARCH', ['f' => '7777777']);
+ $test->chainRequests('PUT', 'PUT', ['g' => '88888888']);
}
public function testRequestMethodSuccessivePatchRequests()
@@ -3109,14 +3109,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->chainRequests('PATCH', 'PATCH');
$test = new Test();
- $test->chainRequests('PATCH', 'GET', array('a' => '1'));
- $test->chainRequests('PATCH', 'POST', array('b' => '22'));
- $test->chainRequests('PATCH', 'PUT', array('c' => '333'));
- $test->chainRequests('PATCH', 'DELETE', array('d' => '4444'));
- $test->chainRequests('PATCH', 'HEAD', array('e' => '55555'));
- $test->chainRequests('PATCH', 'OPTIONS', array('f' => '666666'));
- $test->chainRequests('PATCH', 'SEARCH', array('f' => '7777777'));
- $test->chainRequests('PATCH', 'PATCH', array('g' => '88888888'));
+ $test->chainRequests('PATCH', 'GET', ['a' => '1']);
+ $test->chainRequests('PATCH', 'POST', ['b' => '22']);
+ $test->chainRequests('PATCH', 'PUT', ['c' => '333']);
+ $test->chainRequests('PATCH', 'DELETE', ['d' => '4444']);
+ $test->chainRequests('PATCH', 'HEAD', ['e' => '55555']);
+ $test->chainRequests('PATCH', 'OPTIONS', ['f' => '666666']);
+ $test->chainRequests('PATCH', 'SEARCH', ['f' => '7777777']);
+ $test->chainRequests('PATCH', 'PATCH', ['g' => '88888888']);
}
public function testRequestMethodSuccessiveDeleteRequests()
@@ -3132,14 +3132,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->chainRequests('DELETE', 'DELETE');
$test = new Test();
- $test->chainRequests('DELETE', 'GET', array('a' => '1'));
- $test->chainRequests('DELETE', 'POST', array('b' => '22'));
- $test->chainRequests('DELETE', 'PUT', array('c' => '333'));
- $test->chainRequests('DELETE', 'PATCH', array('d' => '4444'));
- $test->chainRequests('DELETE', 'HEAD', array('e' => '55555'));
- $test->chainRequests('DELETE', 'OPTIONS', array('f' => '666666'));
- $test->chainRequests('DELETE', 'SEARCH', array('f' => '7777777'));
- $test->chainRequests('DELETE', 'DELETE', array('g' => '88888888'));
+ $test->chainRequests('DELETE', 'GET', ['a' => '1']);
+ $test->chainRequests('DELETE', 'POST', ['b' => '22']);
+ $test->chainRequests('DELETE', 'PUT', ['c' => '333']);
+ $test->chainRequests('DELETE', 'PATCH', ['d' => '4444']);
+ $test->chainRequests('DELETE', 'HEAD', ['e' => '55555']);
+ $test->chainRequests('DELETE', 'OPTIONS', ['f' => '666666']);
+ $test->chainRequests('DELETE', 'SEARCH', ['f' => '7777777']);
+ $test->chainRequests('DELETE', 'DELETE', ['g' => '88888888']);
}
public function testRequestMethodSuccessiveHeadRequests()
@@ -3155,14 +3155,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->chainRequests('HEAD', 'HEAD');
$test = new Test();
- $test->chainRequests('HEAD', 'GET', array('a' => '1'));
- $test->chainRequests('HEAD', 'POST', array('b' => '22'));
- $test->chainRequests('HEAD', 'PUT', array('c' => '333'));
- $test->chainRequests('HEAD', 'PATCH', array('d' => '4444'));
- $test->chainRequests('HEAD', 'DELETE', array('e' => '55555'));
- $test->chainRequests('HEAD', 'OPTIONS', array('f' => '666666'));
- $test->chainRequests('HEAD', 'SEARCH', array('g' => '7777777'));
- $test->chainRequests('HEAD', 'HEAD', array('g' => '88888888'));
+ $test->chainRequests('HEAD', 'GET', ['a' => '1']);
+ $test->chainRequests('HEAD', 'POST', ['b' => '22']);
+ $test->chainRequests('HEAD', 'PUT', ['c' => '333']);
+ $test->chainRequests('HEAD', 'PATCH', ['d' => '4444']);
+ $test->chainRequests('HEAD', 'DELETE', ['e' => '55555']);
+ $test->chainRequests('HEAD', 'OPTIONS', ['f' => '666666']);
+ $test->chainRequests('HEAD', 'SEARCH', ['g' => '7777777']);
+ $test->chainRequests('HEAD', 'HEAD', ['g' => '88888888']);
}
public function testRequestMethodSuccessiveOptionsRequests()
@@ -3178,14 +3178,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->chainRequests('OPTIONS', 'OPTIONS');
$test = new Test();
- $test->chainRequests('OPTIONS', 'GET', array('a' => '1'));
- $test->chainRequests('OPTIONS', 'POST', array('b' => '22'));
- $test->chainRequests('OPTIONS', 'PUT', array('c' => '333'));
- $test->chainRequests('OPTIONS', 'PATCH', array('d' => '4444'));
- $test->chainRequests('OPTIONS', 'DELETE', array('e' => '55555'));
- $test->chainRequests('OPTIONS', 'SEARCH', array('g' => '666666'));
- $test->chainRequests('OPTIONS', 'HEAD', array('f' => '7777777'));
- $test->chainRequests('OPTIONS', 'OPTIONS', array('g' => '88888888'));
+ $test->chainRequests('OPTIONS', 'GET', ['a' => '1']);
+ $test->chainRequests('OPTIONS', 'POST', ['b' => '22']);
+ $test->chainRequests('OPTIONS', 'PUT', ['c' => '333']);
+ $test->chainRequests('OPTIONS', 'PATCH', ['d' => '4444']);
+ $test->chainRequests('OPTIONS', 'DELETE', ['e' => '55555']);
+ $test->chainRequests('OPTIONS', 'SEARCH', ['g' => '666666']);
+ $test->chainRequests('OPTIONS', 'HEAD', ['f' => '7777777']);
+ $test->chainRequests('OPTIONS', 'OPTIONS', ['g' => '88888888']);
}
public function testRequestMethodSuccessiveSearchRequests()
@@ -3201,14 +3201,14 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->chainRequests('SEARCH', 'SEARCH');
$test = new Test();
- $test->chainRequests('SEARCH', 'GET', array('a' => '1'));
- $test->chainRequests('SEARCH', 'POST', array('b' => '22'));
- $test->chainRequests('SEARCH', 'PUT', array('c' => '333'));
- $test->chainRequests('SEARCH', 'PATCH', array('d' => '4444'));
- $test->chainRequests('SEARCH', 'DELETE', array('e' => '55555'));
- $test->chainRequests('SEARCH', 'HEAD', array('f' => '666666'));
- $test->chainRequests('SEARCH', 'OPTIONS', array('g' => '7777777'));
- $test->chainRequests('SEARCH', 'SEARCH', array('g' => '88888888'));
+ $test->chainRequests('SEARCH', 'GET', ['a' => '1']);
+ $test->chainRequests('SEARCH', 'POST', ['b' => '22']);
+ $test->chainRequests('SEARCH', 'PUT', ['c' => '333']);
+ $test->chainRequests('SEARCH', 'PATCH', ['d' => '4444']);
+ $test->chainRequests('SEARCH', 'DELETE', ['e' => '55555']);
+ $test->chainRequests('SEARCH', 'HEAD', ['f' => '666666']);
+ $test->chainRequests('SEARCH', 'OPTIONS', ['g' => '7777777']);
+ $test->chainRequests('SEARCH', 'SEARCH', ['g' => '88888888']);
}
public function testMemoryLeak()
@@ -3300,10 +3300,10 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$this->assertNull($curl->getOpt($option));
// Ensure options following a Curl::setOpt() failure are not set when using Curl::setOpts().
- $options = array(
+ $options = [
$option => $null,
CURLOPT_COOKIE => 'a=b',
- );
+ ];
$curl = new Curl();
$success = @$curl->setOpts($options);
@@ -3311,11 +3311,11 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$this->assertNull($curl->getOpt(CURLOPT_COOKIE));
// Ensure Curl::setOpts() returns true when all options are successfully set.
- $options = array(
+ $options = [
CURLOPT_COOKIE => 'a=b',
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_VERBOSE => true,
- );
+ ];
$curl = new Curl();
$success = $curl->setOpts($options);
@@ -3327,64 +3327,64 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testBuildUrlArgs()
{
- $tests = array(
- array(
- 'args' => array(
+ $tests = [
+ [
+ 'args' => [
'url' => 'https://www.example.com/',
'mixed_data' => null,
- ),
+ ],
'expected' => 'https://www.example.com/',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'url' => 'https://www.example.com/',
'mixed_data' => '',
- ),
+ ],
'expected' => 'https://www.example.com/',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'url' => 'https://www.example.com/',
- 'mixed_data' => array(),
- ),
+ 'mixed_data' => [],
+ ],
'expected' => 'https://www.example.com/',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'url' => 'https://www.example.com/',
- 'mixed_data' => array(
+ 'mixed_data' => [
'a' => '1',
'b' => '2',
'c' => '3',
- ),
- ),
+ ],
+ ],
'expected' => 'https://www.example.com/?a=1&b=2&c=3',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'url' => 'https://www.example.com/?a=base',
- 'mixed_data' => array(
+ 'mixed_data' => [
'b' => '2',
'c' => '3',
- ),
- ),
+ ],
+ ],
'expected' => 'https://www.example.com/?a=base&b=2&c=3',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'url' => 'https://www.example.com/?a=base',
'mixed_data' => 'b=2&c=3'
- ),
+ ],
'expected' => 'https://www.example.com/?a=base&b=2&c=3',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'url' => 'https://www.example.com/',
'mixed_data' => 'user_ids=user_1,user_2',
- ),
+ ],
'expected' => 'https://www.example.com/?user_ids=user_1,user_2',
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$curl_1 = new Curl();
$reflector = new \ReflectionObject($curl_1);
@@ -3402,13 +3402,13 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testBuildUrlArgSeparator()
{
$base_url = 'https://www.example.com/path';
- $data = array(
+ $data = [
'arg' => 'value',
'another' => 'one',
- );
+ ];
$expected_url = $base_url . '?arg=value&another=one';
- foreach (array(false, '&', '&') as $arg_separator) {
+ foreach ([false, '&', '&'] as $arg_separator) {
if ($arg_separator) {
ini_set('arg_separator.output', $arg_separator);
}
@@ -3428,10 +3428,10 @@ class CurlTest extends \PHPUnit\Framework\TestCase
{
$request_key = 'X-Request-Id';
$request_value = '1';
- $data = array(
+ $data = [
'test' => 'server',
'key' => 'HTTP_X_REQUEST_ID',
- );
+ ];
$curl = new Curl();
$curl->setHeader($request_key, $request_value);
@@ -3463,7 +3463,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->server('server', 'GET');
$info = $test->curl->getInfo();
- $expected_keys = array(
+ $expected_keys = [
'url',
'content_type',
'http_code',
@@ -3491,7 +3491,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'local_port',
'redirect_url',
'request_header',
- );
+ ];
foreach ($expected_keys as $key) {
$this->assertArrayHasKey($key, $info);
@@ -3500,57 +3500,57 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testRetry()
{
- $tests = array(
- array(
+ $tests = [
+ [
'maximum_number_of_retries' => null,
'failures' => 0,
'expect_success' => true,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 0,
'failures' => 0,
'expect_success' => true,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 0,
'failures' => 1,
'expect_success' => false,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 1,
'failures' => 1,
'expect_success' => true,
'expect_attempts' => 2,
'expect_retries' => 1,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 1,
'failures' => 2,
'expect_success' => false,
'expect_attempts' => 2,
'expect_retries' => 1,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 2,
'failures' => 2,
'expect_success' => true,
'expect_attempts' => 3,
'expect_retries' => 2,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 3,
'failures' => 3,
'expect_success' => true,
'expect_attempts' => 4,
'expect_retries' => 3,
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$maximum_number_of_retries = $test['maximum_number_of_retries'];
$failures = $test['failures'];
@@ -3565,7 +3565,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$test->curl->setRetry($maximum_number_of_retries);
}
- $test->server('retry', 'GET', array('failures' => $failures));
+ $test->server('retry', 'GET', ['failures' => $failures]);
$this->assertEquals($expect_success, !$test->curl->error);
$this->assertEquals($expect_attempts, $test->curl->attempts);
$this->assertEquals($expect_retries, $test->curl->retries);
@@ -3574,57 +3574,57 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testRetryCallable()
{
- $tests = array(
- array(
+ $tests = [
+ [
'maximum_number_of_retries' => null,
'failures' => 0,
'expect_success' => true,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 0,
'failures' => 0,
'expect_success' => true,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 0,
'failures' => 1,
'expect_success' => false,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 1,
'failures' => 1,
'expect_success' => true,
'expect_attempts' => 2,
'expect_retries' => 1,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 1,
'failures' => 2,
'expect_success' => false,
'expect_attempts' => 2,
'expect_retries' => 1,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 2,
'failures' => 2,
'expect_success' => true,
'expect_attempts' => 3,
'expect_retries' => 2,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 3,
'failures' => 3,
'expect_success' => true,
'expect_attempts' => 4,
'expect_retries' => 3,
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$maximum_number_of_retries = $test['maximum_number_of_retries'];
$failures = $test['failures'];
@@ -3642,7 +3642,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
});
}
- $test->server('retry', 'GET', array('failures' => $failures));
+ $test->server('retry', 'GET', ['failures' => $failures]);
$this->assertEquals($expect_success, !$test->curl->error);
$this->assertEquals($expect_attempts, $test->curl->attempts);
$this->assertEquals($expect_retries, $test->curl->retries);
@@ -3654,62 +3654,62 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$curl = new Curl(Test::TEST_URL . 'path/');
$this->assertEquals('http://127.0.0.1:8000/path/', (string)$curl->url);
- $curl->get('test', array(
+ $curl->get('test', [
'a' => '1',
'b' => '2',
- ));
+ ]);
$this->assertEquals('http://127.0.0.1:8000/path/test?a=1&b=2', (string)$curl->url);
- $curl->get('/root', array(
+ $curl->get('/root', [
'c' => '3',
'd' => '4',
- ));
+ ]);
$this->assertEquals('http://127.0.0.1:8000/root?c=3&d=4', (string)$curl->url);
- $tests = array(
- array(
- 'args' => array(
+ $tests = [
+ [
+ 'args' => [
'http://www.example.com/',
'/foo',
- ),
+ ],
'expected' => 'http://www.example.com/foo',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'http://www.example.com/',
'/foo/',
- ),
+ ],
'expected' => 'http://www.example.com/foo/',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'http://www.example.com/',
'/dir/page.html',
- ),
+ ],
'expected' => 'http://www.example.com/dir/page.html',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'http://www.example.com/dir1/page2.html',
'/dir/page.html',
- ),
+ ],
'expected' => 'http://www.example.com/dir/page.html',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'http://www.example.com/dir1/page2.html',
'dir/page.html',
- ),
+ ],
'expected' => 'http://www.example.com/dir1/dir/page.html',
- ),
- array(
- 'args' => array(
+ ],
+ [
+ 'args' => [
'http://www.example.com/dir1/dir3/page.html',
'../dir/page.html',
- ),
+ ],
'expected' => 'http://www.example.com/dir1/dir/page.html',
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$curl = new Curl($test['args']['0']);
$curl->setUrl($test['args']['1']);
@@ -3720,7 +3720,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
);
$curl = new Curl($test['args']['0']);
- $curl->setUrl($test['args']['1'], array('a' => '1', 'b' => '2'));
+ $curl->setUrl($test['args']['1'], ['a' => '1', 'b' => '2']);
$this->assertEquals(
$test['expected'] . '?a=1&b=2',
$curl->getOpt(CURLOPT_URL),
@@ -3737,7 +3737,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
);
$curl = new Curl();
- $curl->setUrl($test['args']['0'], array('a' => '1', 'b' => '2'));
+ $curl->setUrl($test['args']['0'], ['a' => '1', 'b' => '2']);
$curl->setUrl($test['args']['1']);
$this->assertEquals(
$test['expected'],
@@ -3747,7 +3747,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$curl = new Curl();
$curl->setUrl($test['args']['0']);
- $curl->setUrl($test['args']['1'], array('a' => '1', 'b' => '2'));
+ $curl->setUrl($test['args']['1'], ['a' => '1', 'b' => '2']);
$this->assertEquals(
$test['expected'] . '?a=1&b=2',
$curl->getOpt(CURLOPT_URL),
@@ -3755,8 +3755,8 @@ class CurlTest extends \PHPUnit\Framework\TestCase
);
$curl = new Curl();
- $curl->setUrl($test['args']['0'], array('a' => '1', 'b' => '2'));
- $curl->setUrl($test['args']['1'], array('c' => '3', 'd' => '4'));
+ $curl->setUrl($test['args']['0'], ['a' => '1', 'b' => '2']);
+ $curl->setUrl($test['args']['1'], ['c' => '3', 'd' => '4']);
$this->assertEquals(
$test['expected'] . '?c=3&d=4',
$curl->getOpt(CURLOPT_URL),
@@ -3770,15 +3770,15 @@ class CurlTest extends \PHPUnit\Framework\TestCase
{
$test = new Test();
- $original_user_agent = $test->server('server', 'GET', array('key' => 'HTTP_USER_AGENT'));
+ $original_user_agent = $test->server('server', 'GET', ['key' => 'HTTP_USER_AGENT']);
$this->assertNotEquals('New agent', $original_user_agent);
$test->curl->setUserAgent('New agent');
- $user_agent = $test->server('server', 'GET', array('key' => 'HTTP_USER_AGENT'));
+ $user_agent = $test->server('server', 'GET', ['key' => 'HTTP_USER_AGENT']);
$this->assertEquals('New agent', $user_agent);
$test->curl->reset();
- $user_agent = $test->server('server', 'GET', array('key' => 'HTTP_USER_AGENT'));
+ $user_agent = $test->server('server', 'GET', ['key' => 'HTTP_USER_AGENT']);
$this->assertEquals($original_user_agent, $user_agent);
}
@@ -3882,7 +3882,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testSetHeadersAssociativeArray()
{
$curl = new Curl();
- $curl->setHeaders(array(
+ $curl->setHeaders([
' Key1 ' => ' Value1 ',
' Key2 ' => ' Value2',
' Key3 ' => 'Value3 ',
@@ -3899,9 +3899,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'Key14' => ' Value14',
'Key15' => 'Value15 ',
'Key16' => 'Value16',
- ));
+ ]);
- $this->assertEquals(array(
+ $this->assertEquals([
'Key1: Value1',
'Key2: Value2',
'Key3: Value3',
@@ -3918,7 +3918,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'Key14: Value14',
'Key15: Value15',
'Key16: Value16',
- ), $curl->getOpt(CURLOPT_HTTPHEADER));
+ ], $curl->getOpt(CURLOPT_HTTPHEADER));
$headers = \Helper\get_curl_property_value($curl, 'headers');
$this->assertEquals('Value1', $headers['Key1']);
@@ -3942,7 +3942,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testSetHeadersIndexedArray()
{
$curl = new Curl();
- $curl->setHeaders(array(
+ $curl->setHeaders([
' Key1 : Value1 ',
' Key2 : Value2',
' Key3 :Value3 ',
@@ -3959,9 +3959,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'Key14: Value14',
'Key15:Value15 ',
'Key16:Value16',
- ));
+ ]);
- $this->assertEquals(array(
+ $this->assertEquals([
'Key1: Value1',
'Key2: Value2',
'Key3: Value3',
@@ -3978,7 +3978,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'Key14: Value14',
'Key15: Value15',
'Key16: Value16',
- ), $curl->getOpt(CURLOPT_HTTPHEADER));
+ ], $curl->getOpt(CURLOPT_HTTPHEADER));
$headers = \Helper\get_curl_property_value($curl, 'headers');
$this->assertEquals('Value1', $headers['Key1']);
diff --git a/tests/PHPCurlClass/PHPMultiCurlClassTest.php b/tests/PHPCurlClass/PHPMultiCurlClassTest.php
index adc5825..19da0dc 100644
--- a/tests/PHPCurlClass/PHPMultiCurlClassTest.php
+++ b/tests/PHPCurlClass/PHPMultiCurlClassTest.php
@@ -669,8 +669,8 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
\PHPUnit\Framework\Assert::assertTrue($instance->error);
\PHPUnit\Framework\Assert::assertTrue($instance->curlError);
\PHPUnit\Framework\Assert::assertFalse($instance->httpError);
- $possible_errors = array(
- CURLE_SEND_ERROR, CURLE_OPERATION_TIMEOUTED, CURLE_COULDNT_CONNECT, CURLE_GOT_NOTHING);
+ $possible_errors = [
+ CURLE_SEND_ERROR, CURLE_OPERATION_TIMEOUTED, CURLE_COULDNT_CONNECT, CURLE_GOT_NOTHING];
\PHPUnit\Framework\Assert::assertTrue(
in_array($instance->errorCode, $possible_errors, true),
'errorCode: ' . $instance->errorCode
@@ -2045,7 +2045,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
{
$multi_curl_user_agent = 'multi curl user agent';
$curl_user_agent = 'curl user agent';
- $data = array('key' => 'HTTP_USER_AGENT');
+ $data = ['key' => 'HTTP_USER_AGENT'];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'server');
@@ -2250,15 +2250,15 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
{
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'setcookie');
- $multi_curl->setCookies(array(
+ $multi_curl->setCookies([
'mycookie' => 'yum',
'cookie-for-all-before' => 'a',
- ));
+ ]);
$get_1 = $multi_curl->addGet(Test::TEST_URL);
- $get_1->setCookies(array(
+ $get_1->setCookies([
'cookie-for-1st-request' => '1',
- ));
+ ]);
$get_1->complete(function ($instance) {
\PHPUnit\Framework\Assert::assertEquals('yum', $instance->responseCookies['mycookie']);
\PHPUnit\Framework\Assert::assertEquals('a', $instance->responseCookies['cookie-for-all-before']);
@@ -2267,13 +2267,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
});
$get_2 = $multi_curl->addGet(Test::TEST_URL);
- $get_2->setCookies(array(
+ $get_2->setCookies([
'cookie-for-2nd-request' => '2',
- ));
+ ]);
$get_2->beforeSend(function ($instance) {
- $instance->setCookies(array(
+ $instance->setCookies([
'mycookie' => 'yummy',
- ));
+ ]);
});
$get_2->complete(function ($instance) {
\PHPUnit\Framework\Assert::assertEquals('yummy', $instance->responseCookies['mycookie']);
@@ -2282,9 +2282,9 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
\PHPUnit\Framework\Assert::assertEquals('2', $instance->responseCookies['cookie-for-2nd-request']);
});
- $multi_curl->setCookies(array(
+ $multi_curl->setCookies([
'cookie-for-all-after' => 'b',
- ));
+ ]);
$multi_curl->start();
$this->assertEquals('yum', $get_1->responseCookies['mycookie']);
@@ -2293,25 +2293,25 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testJsonRequest()
{
- foreach (array(
- array(
- array(
+ foreach ([
+ [
+ [
'key' => 'value',
- ),
+ ],
'{"key":"value"}',
- ),
- array(
- array(
+ ],
+ [
+ [
'key' => 'value',
- 'strings' => array(
+ 'strings' => [
'a',
'b',
'c',
- ),
- ),
+ ],
+ ],
'{"key":"value","strings":["a","b","c"]}',
- ),
- ) as $test) {
+ ],
+ ] as $test) {
list($data, $expected_response) = $test;
$multi_curl = new MultiCurl();
@@ -2322,18 +2322,18 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
$multi_curl->addPost(Test::TEST_URL, json_encode($data));
$multi_curl->start();
- foreach (array(
+ foreach ([
'Content-Type',
'content-type',
- 'CONTENT-TYPE') as $key) {
- foreach (array(
+ 'CONTENT-TYPE'] as $key) {
+ foreach ([
'APPLICATION/JSON',
'APPLICATION/JSON; CHARSET=UTF-8',
'APPLICATION/JSON;CHARSET=UTF-8',
'application/json',
'application/json; charset=utf-8',
'application/json;charset=UTF-8',
- ) as $value) {
+ ] as $value) {
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'post_json');
$multi_curl->setHeader($key, $value);
@@ -2358,10 +2358,10 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testJsonDecoder()
{
- $data = array(
+ $data = [
'key' => 'Content-Type',
'value' => 'application/json',
- );
+ ];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'json_response');
@@ -2571,9 +2571,9 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
$downloaded_file_path = tempnam('/tmp', 'php-curl-class.');
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'download_response');
- $multi_curl->addDownload(Test::TEST_URL . '?' . http_build_query(array(
+ $multi_curl->addDownload(Test::TEST_URL . '?' . http_build_query([
'file_path' => $uploaded_file_path,
- )), $downloaded_file_path);
+ ]), $downloaded_file_path);
$multi_curl->complete(function ($instance) use ($upload_file_path) {
\PHPUnit\Framework\Assert::assertFalse($instance->error);
\PHPUnit\Framework\Assert::assertEquals(md5_file($upload_file_path), $instance->responseHeaders['ETag']);
@@ -2601,7 +2601,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
$filesize = filesize($filename);
- foreach (array(
+ foreach ([
false,
0,
1,
@@ -2632,7 +2632,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
$filesize + 2,
$filesize + 3,
- ) as $length) {
+ ] as $length) {
$source = Test::TEST_URL;
$destination = \Helper\get_tmp_file_path();
@@ -2669,9 +2669,9 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// Download (the remaining bytes of) the file.
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'download_file_range');
- $multi_curl->addDownload($source . '?' . http_build_query(array(
+ $multi_curl->addDownload($source . '?' . http_build_query([
'file_path' => $uploaded_file_path,
- )), $destination);
+ ]), $destination);
clearstatcache();
@@ -2726,18 +2726,18 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// Upload a file.
$upload_file_path = \Helper\get_png();
$upload_test = new Test();
- $upload_test->server('upload_response', 'POST', array(
+ $upload_test->server('upload_response', 'POST', [
'image' => '@' . $upload_file_path,
- ));
+ ]);
$uploaded_file_path = $upload_test->curl->response->file_path;
// Download the file.
$download_callback_called = false;
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'download_response');
- $multi_curl->addDownload(Test::TEST_URL . '?' . http_build_query(array(
+ $multi_curl->addDownload(Test::TEST_URL . '?' . http_build_query([
'file_path' => $uploaded_file_path,
- )), function ($instance, $fh) use (&$download_callback_called) {
+ ]), function ($instance, $fh) use (&$download_callback_called) {
\PHPUnit\Framework\Assert::assertFalse($download_callback_called);
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
\PHPUnit\Framework\Assert::assertTrue(is_resource($fh));
@@ -2751,9 +2751,9 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($download_callback_called);
// Remove server file.
- $this->assertEquals('true', $upload_test->server('upload_cleanup', 'POST', array(
+ $this->assertEquals('true', $upload_test->server('upload_cleanup', 'POST', [
'file_path' => $uploaded_file_path,
- )));
+ ]));
unlink($upload_file_path);
$this->assertFalse(file_exists($upload_file_path));
@@ -2779,11 +2779,11 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetUrlInConstructor()
{
- $data = array('key' => 'value');
+ $data = ['key' => 'value'];
$multi_curl = new MultiCurl(Test::TEST_URL);
$multi_curl->setHeader('X-DEBUG-TEST', 'delete_with_body');
- $multi_curl->addDelete($data, array('wibble' => 'wubble'))->complete(function ($instance) {
+ $multi_curl->addDelete($data, ['wibble' => 'wubble'])->complete(function ($instance) {
\PHPUnit\Framework\Assert::assertEquals(
'{"get":{"key":"value"},"delete":{"wibble":"wubble"}}',
$instance->rawResponse
@@ -2853,7 +2853,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetUrl()
{
- $data = array('key' => 'value');
+ $data = ['key' => 'value'];
$multi_curl = new MultiCurl();
$multi_curl->setUrl(Test::TEST_URL);
@@ -2943,15 +2943,15 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
{
$multi_curl = new MultiCurl();
- $urls = array();
- $copy_of_urls = array();
+ $urls = [];
+ $copy_of_urls = [];
for ($i = 0; $i < 10; $i++) {
$url = Test::TEST_URL . '?' . md5(mt_rand());
$urls[] = $url;
$copy_of_urls[] = $url;
}
- $urls_called = array();
+ $urls_called = [];
$multi_curl->complete(function ($instance) use (&$multi_curl, &$urls, &$urls_called) {
$urls_called[] = $instance->url;
$next_url = array_pop($urls);
@@ -3001,7 +3001,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
$multi_curl = new MultiCurl(Test::TEST_URL);
$multi_curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
$multi_curl->setHeader('X-DEBUG-TEST', 'post_redirect_get');
- $multi_curl->addPost(array(), false)->complete(function ($instance) {
+ $multi_curl->addPost([], false)->complete(function ($instance) {
\PHPUnit\Framework\Assert::assertEquals('Redirected: POST', $instance->response);
});
$multi_curl->start();
@@ -3010,7 +3010,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
$multi_curl = new MultiCurl(Test::TEST_URL);
$multi_curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
$multi_curl->setHeader('X-DEBUG-TEST', 'post_redirect_get');
- $multi_curl->addPost(array(), true)->complete(function ($instance) {
+ $multi_curl->addPost([], true)->complete(function ($instance) {
\PHPUnit\Framework\Assert::assertEquals('Redirected: GET', $instance->response);
});
$multi_curl->start();
@@ -3037,10 +3037,10 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
{
$request_key = 'X-Request-Id';
$request_value = '1';
- $data = array(
+ $data = [
'test' => 'server',
'key' => 'HTTP_X_REQUEST_ID',
- );
+ ];
$multi_curl = new MultiCurl();
$multi_curl->setHeader($request_key, $request_value);
@@ -3109,57 +3109,57 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testRetryMulti()
{
- $tests = array(
- array(
+ $tests = [
+ [
'maximum_number_of_retries' => null,
'failures' => 0,
'expect_success' => true,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 0,
'failures' => 0,
'expect_success' => true,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 0,
'failures' => 1,
'expect_success' => false,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 1,
'failures' => 1,
'expect_success' => true,
'expect_attempts' => 2,
'expect_retries' => 1,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 1,
'failures' => 2,
'expect_success' => false,
'expect_attempts' => 2,
'expect_retries' => 1,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 2,
'failures' => 2,
'expect_success' => true,
'expect_attempts' => 3,
'expect_retries' => 2,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 3,
'failures' => 3,
'expect_success' => true,
'expect_attempts' => 4,
'expect_retries' => 3,
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$maximum_number_of_retries = $test['maximum_number_of_retries'];
$failures = $test['failures'];
@@ -3175,7 +3175,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
$multi_curl->setRetry($maximum_number_of_retries);
}
- $instance = $multi_curl->addGet(Test::TEST_URL, array('failures' => $failures));
+ $instance = $multi_curl->addGet(Test::TEST_URL, ['failures' => $failures]);
$multi_curl->start();
$this->assertEquals($expect_success, !$instance->error);
@@ -3186,57 +3186,57 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testRetryCallableMulti()
{
- $tests = array(
- array(
+ $tests = [
+ [
'maximum_number_of_retries' => null,
'failures' => 0,
'expect_success' => true,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 0,
'failures' => 0,
'expect_success' => true,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 0,
'failures' => 1,
'expect_success' => false,
'expect_attempts' => 1,
'expect_retries' => 0,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 1,
'failures' => 1,
'expect_success' => true,
'expect_attempts' => 2,
'expect_retries' => 1,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 1,
'failures' => 2,
'expect_success' => false,
'expect_attempts' => 2,
'expect_retries' => 1,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 2,
'failures' => 2,
'expect_success' => true,
'expect_attempts' => 3,
'expect_retries' => 2,
- ),
- array(
+ ],
+ [
'maximum_number_of_retries' => 3,
'failures' => 3,
'expect_success' => true,
'expect_attempts' => 4,
'expect_retries' => 3,
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$maximum_number_of_retries = $test['maximum_number_of_retries'];
$failures = $test['failures'];
@@ -3255,7 +3255,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
});
}
- $instance = $multi_curl->addGet(Test::TEST_URL, array('failures' => $failures));
+ $instance = $multi_curl->addGet(Test::TEST_URL, ['failures' => $failures]);
$multi_curl->start();
$this->assertEquals($expect_success, !$instance->error);
@@ -3325,13 +3325,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetProxiesRandomProxy()
{
- $proxies = array(
+ $proxies = [
'example.com:80',
'example.com:443',
'example.com:1080',
'example.com:3128',
'example.com:8080',
- );
+ ];
$multi_curl = new MultiCurl();
$multi_curl->setProxies($proxies);
@@ -3364,13 +3364,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetProxiesAlreadySet()
{
- $proxies = array(
+ $proxies = [
'example.com:80',
'example.com:443',
'example.com:1080',
'example.com:3128',
'example.com:8080',
- );
+ ];
$multi_curl = new MultiCurl();
$multi_curl->setProxies($proxies);
@@ -3437,138 +3437,138 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetRateLimitUnits()
{
- foreach (array(
- array(
+ foreach ([
+ [
'rate_limit' => '1/s',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '1/1s',
'max_requests' => '1',
'interval' => '1',
'unit' => 's',
'interval_seconds' => '1',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '1/1s',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '1/1s',
'max_requests' => '1',
'interval' => '1',
'unit' => 's',
'interval_seconds' => '1',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '10/60s',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '10/60s',
'max_requests' => '10',
'interval' => '60',
'unit' => 's',
'interval_seconds' => '60',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '10/60S',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '10/60s',
'max_requests' => '10',
'interval' => '60',
'unit' => 's',
'interval_seconds' => '60',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '1/m',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '1/1m',
'max_requests' => '1',
'interval' => '1',
'unit' => 'm',
'interval_seconds' => '60',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '1/1m',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '1/1m',
'max_requests' => '1',
'interval' => '1',
'unit' => 'm',
'interval_seconds' => '60',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '5000/60m',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '5000/60m',
'max_requests' => '5000',
'interval' => '60',
'unit' => 'm',
'interval_seconds' => '3600',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '5000/60M',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '5000/60m',
'max_requests' => '5000',
'interval' => '60',
'unit' => 'm',
'interval_seconds' => '3600',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '1/h',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '1/1h',
'max_requests' => '1',
'interval' => '1',
'unit' => 'h',
'interval_seconds' => '3600',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '1/1h',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '1/1h',
'max_requests' => '1',
'interval' => '1',
'unit' => 'h',
'interval_seconds' => '3600',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '5000/1h',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '5000/1h',
'max_requests' => '5000',
'interval' => '1',
'unit' => 'h',
'interval_seconds' => '3600',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '100000/24h',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '100000/24h',
'max_requests' => '100000',
'interval' => '24',
'unit' => 'h',
'interval_seconds' => '86400',
- ),
- ),
- array(
+ ],
+ ],
+ [
'rate_limit' => '100000/24H',
- 'expected' => array(
+ 'expected' => [
'rate_limit' => '100000/24h',
'max_requests' => '100000',
'interval' => '24',
'unit' => 'h',
'interval_seconds' => '86400',
- ),
- ),
- ) as $test) {
+ ],
+ ],
+ ] as $test) {
$multi_curl = new MultiCurl();
$multi_curl->setRateLimit($test['rate_limit']);
@@ -3606,13 +3606,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R4--|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -3675,13 +3675,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R4--|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -3742,13 +3742,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R4--|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -3809,13 +3809,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R4--|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -3877,13 +3877,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R4------|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -3945,13 +3945,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R4------|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4013,13 +4013,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R5------|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4089,13 +4089,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R5------|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4165,13 +4165,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
// R5------|
// 0 1 2 3 4 5 6 7 8 9 10 11 12
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('2/5s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4233,12 +4233,12 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetRateLimitPerSecondOnePerSecond()
{
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setRateLimit('1/1s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4267,13 +4267,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetRateLimitFivePerThirtySecond()
{
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('5/30s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4297,13 +4297,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetRateLimitOnePerOneMinute()
{
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('1/1m');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4327,13 +4327,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetRateLimitThreePerOneMinute()
{
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('3/1m');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4355,13 +4355,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetRateLimitThreePerSixtyFiveSeconds()
{
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('3/65s');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4383,13 +4383,13 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetRateLimitTenPerTwoMinutes()
{
- $request_stats = array();
+ $request_stats = [];
$multi_curl = new MultiCurl();
$multi_curl->setHeader('X-DEBUG-TEST', 'timeout');
$multi_curl->setRateLimit('10/2m');
$multi_curl->beforeSend(function ($instance) use (&$request_stats) {
- $request_stats[$instance->id] = array();
+ $request_stats[$instance->id] = [];
$request_stats[$instance->id]['start'] = microtime(true);
});
$multi_curl->complete(function ($instance) use (&$request_stats) {
@@ -4437,7 +4437,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetHeadersAssociativeArray()
{
$multi_curl = new MultiCurl();
- $multi_curl->setHeaders(array(
+ $multi_curl->setHeaders([
' Key1 ' => ' Value1 ',
' Key2 ' => ' Value2',
' Key3 ' => 'Value3 ',
@@ -4454,12 +4454,12 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
'Key14' => ' Value14',
'Key15' => 'Value15 ',
'Key16' => 'Value16',
- ));
+ ]);
$multi_curl->addGet(Test::TEST_URL);
$curls = \Helper\get_multi_curl_property_value($multi_curl, 'curls');
foreach ($curls as $curl) {
- $this->assertEquals(array(
+ $this->assertEquals([
'Key1: Value1',
'Key2: Value2',
'Key3: Value3',
@@ -4476,7 +4476,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
'Key14: Value14',
'Key15: Value15',
'Key16: Value16',
- ), $curl->getOpt(CURLOPT_HTTPHEADER));
+ ], $curl->getOpt(CURLOPT_HTTPHEADER));
$headers = \Helper\get_curl_property_value($curl, 'headers');
$this->assertEquals('Value1', $headers['Key1']);
@@ -4501,7 +4501,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
public function testSetHeadersIndexedArray()
{
$multi_curl = new MultiCurl();
- $multi_curl->setHeaders(array(
+ $multi_curl->setHeaders([
' Key1 : Value1 ',
' Key2 : Value2',
' Key3 :Value3 ',
@@ -4518,12 +4518,12 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
'Key14: Value14',
'Key15:Value15 ',
'Key16:Value16',
- ));
+ ]);
$multi_curl->addGet(Test::TEST_URL);
$curls = \Helper\get_multi_curl_property_value($multi_curl, 'curls');
foreach ($curls as $curl) {
- $this->assertEquals(array(
+ $this->assertEquals([
'Key1: Value1',
'Key2: Value2',
'Key3: Value3',
@@ -4540,7 +4540,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase
'Key14: Value14',
'Key15: Value15',
'Key16: Value16',
- ), $curl->getOpt(CURLOPT_HTTPHEADER));
+ ], $curl->getOpt(CURLOPT_HTTPHEADER));
$headers = \Helper\get_curl_property_value($curl, 'headers');
$this->assertEquals('Value1', $headers['Key1']);
diff --git a/tests/PHPCurlClass/UrlTest.php b/tests/PHPCurlClass/UrlTest.php
index 2b98c83..94d6fe5 100644
--- a/tests/PHPCurlClass/UrlTest.php
+++ b/tests/PHPCurlClass/UrlTest.php
@@ -52,16 +52,16 @@ class UrlTest extends \PHPUnit\Framework\TestCase
public function testRemoveDotSegments()
{
// TODO: Add tests using "Normal Examples" and "Abnormal Examples" from RFC 3986.
- $tests = array(
- array(
+ $tests = [
+ [
'path' => '/a/b/c/./../../g',
'expected' => '/a/g',
- ),
- array(
+ ],
+ [
'path' => 'mid/content=5/../6',
'expected' => 'mid/6',
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$actual_path = Url::removeDotSegments($test['path']);
$this->assertEquals($test['expected'], $actual_path);
@@ -87,14 +87,14 @@ class UrlTest extends \PHPUnit\Framework\TestCase
// | | | | |
// scheme authority path query fragment
$input_url = 'foo://example.com:8042/over/there?name=ferret#nose';
- $expected_parts = array(
+ $expected_parts = [
'scheme' => 'foo',
'host' => 'example.com',
'port' => '8042',
'path' => '/over/there',
'query' => 'name=ferret',
'fragment' => 'nose',
- );
+ ];
$this->assertEquals($expected_parts, parse_url($input_url));
@@ -110,7 +110,7 @@ class UrlTest extends \PHPUnit\Framework\TestCase
public function testParseUrlExample()
{
$input_url = 'http://username:password@hostname:9090/path?arg=value#anchor';
- $expected_parts = array(
+ $expected_parts = [
'scheme' => 'http',
'host' => 'hostname',
'port' => '9090',
@@ -119,7 +119,7 @@ class UrlTest extends \PHPUnit\Framework\TestCase
'path' => '/path',
'query' => 'arg=value',
'fragment' => 'anchor',
- );
+ ];
$this->assertEquals($expected_parts, parse_url($input_url));
diff --git a/tests/PHPCurlClass/User.php b/tests/PHPCurlClass/User.php
index accce10..69fd468 100644
--- a/tests/PHPCurlClass/User.php
+++ b/tests/PHPCurlClass/User.php
@@ -18,10 +18,10 @@ if (interface_exists('JsonSerializable')) {
public function jsonSerialize()
{
- return array(
+ return [
'name' => $this->name,
'email' => $this->email,
- );
+ ];
}
}
}
diff --git a/tests/PHPCurlClass/server.php b/tests/PHPCurlClass/server.php
index aa38e65..29882f4 100644
--- a/tests/PHPCurlClass/server.php
+++ b/tests/PHPCurlClass/server.php
@@ -14,9 +14,9 @@ require_once 'Helper.php';
use Helper\Test;
$http_raw_post_data = file_get_contents('php://input');
-$_PUT = array();
-$_PATCH = array();
-$_DELETE = array();
+$_PUT = [];
+$_PATCH = [];
+$_DELETE = [];
$request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
if (!array_key_exists('CONTENT_TYPE', $_SERVER) && array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
@@ -60,15 +60,15 @@ if ($test === 'http_basic_auth') {
}
header('Content-Type: application/json');
- echo json_encode(array(
+ echo json_encode([
'username' => $_SERVER['PHP_AUTH_USER'],
'password' => $_SERVER['PHP_AUTH_PW'],
- ));
+ ]);
exit;
} elseif ($test === 'http_digest_auth') {
- $users = array(
+ $users = [
'myusername' => 'mypassword',
- );
+ ];
$realm = 'Restricted area';
$qop = 'auth';
@@ -87,7 +87,7 @@ if ($test === 'http_basic_auth') {
exit;
}
- $data = array(
+ $data = [
'nonce' => '',
'nc' => '',
'cnonce' => '',
@@ -95,7 +95,7 @@ if ($test === 'http_basic_auth') {
'username' => '',
'uri' => '',
'response' => '',
- );
+ ];
preg_match_all(
'@(' . implode('|', array_keys($data)) . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@',
$_SERVER['PHP_AUTH_DIGEST'],
@@ -140,10 +140,10 @@ if ($test === 'http_basic_auth') {
exit;
} elseif ($test === 'post_multidimensional' || $test === 'post_multidimensional_with_file') {
header('Content-Type: application/json');
- echo json_encode(array(
+ echo json_encode([
'post' => $_POST,
'files' => $_FILES,
- ));
+ ]);
exit;
} elseif ($test === 'post_file_path_upload') {
echo Helper\mime_type($_FILES[$key]['tmp_name']);
@@ -188,7 +188,7 @@ if ($test === 'http_basic_auth') {
} else {
header('Content-Type: application/json');
}
- echo json_encode(array(
+ echo json_encode([
'null' => null,
'true' => true,
'false' => false,
@@ -196,7 +196,7 @@ if ($test === 'http_basic_auth') {
'float' => 3.14,
'empty' => '',
'string' => 'string',
- ));
+ ]);
exit;
} elseif ($test === 'xml_response') {
$key = $_POST['key'];
@@ -246,9 +246,9 @@ if ($test === 'http_basic_auth') {
move_uploaded_file($_FILES['image']['tmp_name'], $tmp_filename);
header('Content-Type: application/json');
header('ETag: ' . md5_file($tmp_filename));
- echo json_encode(array(
+ echo json_encode([
'file_path' => $tmp_filename,
- ));
+ ]);
exit;
} elseif ($test === 'upload_cleanup') {
$unsafe_file_path = $_POST['file_path'];
@@ -325,10 +325,10 @@ if ($test === 'http_basic_auth') {
exit;
} elseif ($test === 'delete_with_body') {
header('Content-Type: application/json');
- echo json_encode(array(
+ echo json_encode([
'get' => $_GET,
'delete' => $_DELETE,
- ));
+ ]);
exit;
} elseif ($test === 'data_values') {
header('Content-Type: application/json');
@@ -383,7 +383,7 @@ if ($test === 'http_basic_auth') {
header('Content-Type: text/plain');
-$data_mapping = array(
+$data_mapping = [
'cookie' => $_COOKIE,
'delete' => $_GET,
'get' => $_GET,
@@ -391,7 +391,7 @@ $data_mapping = array(
'post' => $_POST,
'put' => $_PUT,
'server' => $_SERVER,
-);
+];
if (!empty($test)) {
$data = $data_mapping[$test];