Skip to content

Commit 10d3bd0

Browse files
committed
Use shorthand array initialisation, update version
1 parent ff95b00 commit 10d3bd0

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

codebird-cors-proxy.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* Proxy to the Twitter API, adding CORS headers to replies.
77
*
88
* @package codebird
9-
* @version 1.3.0
9+
* @version 1.4.0
1010
* @author Jublo Solutions <[email protected]>
11-
* @copyright 2013-2014 Jublo Solutions <[email protected]>
11+
* @copyright 2013-2015 Jublo Solutions <[email protected]>
1212
*
1313
* This program is free software: you can redistribute it and/or modify
1414
* it under the terms of the GNU General Public License as published by
@@ -27,12 +27,12 @@
2727
if (! function_exists('http_get_request_headers')) {
2828
function http_get_request_headers()
2929
{
30-
$arh = array();
30+
$arh = [];
3131
$rx_http = '/\AHTTP_/';
3232
foreach ($_SERVER as $key => $val) {
3333
if (preg_match($rx_http, $key)) {
3434
$arh_key = preg_replace($rx_http, '', $key);
35-
$rx_matches = array();
35+
$rx_matches = [];
3636
// do some nasty string manipulations to restore the original letter case
3737
// this should work in most cases
3838
$rx_matches = explode('_', $arh_key);
@@ -67,13 +67,13 @@ function http_get_request_body()
6767
}
6868
}
6969

70-
$constants = array(
70+
$constants = [
7171
'CURLE_SSL_CERTPROBLEM' => 58,
7272
'CURLE_SSL_CACERT' => 60,
7373
'CURLE_SSL_CACERT_BADFILE' => 77,
7474
'CURLE_SSL_CRL_BADFILE' => 82,
7575
'CURLE_SSL_ISSUER_ERROR' => 83
76-
);
76+
];
7777
foreach ($constants as $id => $i) {
7878
defined($id) or define($id, $i);
7979
}
@@ -85,13 +85,13 @@ function http_get_request_body()
8585
$url = $_SERVER['REQUEST_URI'];
8686
$method = $_SERVER['REQUEST_METHOD'];
8787

88-
$cors_headers = array(
88+
$cors_headers = [
8989
'Access-Control-Allow-Origin: *',
9090
'Access-Control-Allow-Headers: Origin, X-Authorization, Content-Type',
9191
'Access-Control-Allow-Methods: POST, GET, OPTIONS',
9292
'Access-Control-Expose-Headers: '
9393
. 'X-Rate-Limit-Limit, X-Rate-Limit-Remaining, X-Rate-Limit-Reset'
94-
);
94+
];
9595

9696
foreach($cors_headers as $cors_header) {
9797
header($cors_header);
@@ -103,7 +103,7 @@ function http_get_request_body()
103103

104104
// get request headers
105105
$headers_received = http_get_request_headers();
106-
$headers = array('Expect:');
106+
$headers = ['Expect:'];
107107

108108
// extract authorization header
109109
if (isset($headers_received['X-Authorization'])) {
@@ -141,11 +141,11 @@ function http_get_request_body()
141141

142142
// check for other base64 parameters
143143
foreach ($_POST as $key => $value) {
144-
$possible_files = array(
144+
$possible_files = [
145145
// media[] is checked above
146146
'image',
147147
'banner'
148-
);
148+
];
149149

150150
if (! in_array($key, $possible_files)) {
151151
continue;
@@ -214,13 +214,13 @@ function http_get_request_body()
214214
$validation_result = curl_errno($ch);
215215
if (in_array(
216216
$validation_result,
217-
array(
217+
[
218218
CURLE_SSL_CERTPROBLEM,
219219
CURLE_SSL_CACERT,
220220
CURLE_SSL_CACERT_BADFILE,
221221
CURLE_SSL_CRL_BADFILE,
222222
CURLE_SSL_ISSUER_ERROR
223-
)
223+
]
224224
)
225225
) {
226226
die('Error ' . $validation_result . ' while validating the Twitter API certificate.');

0 commit comments

Comments
 (0)