Skip to content

Commit 6a814ab

Browse files
committed
feat: updating php targets to use [] instead of array()
1 parent 692f540 commit 6a814ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+149
-149
lines changed

src/targets/php/curl.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = function (source, options) {
7272
value: source.postData ? source.postData.text : undefined
7373
}]
7474

75-
code.push('curl_setopt_array($curl, array(')
75+
code.push('curl_setopt_array($curl, [')
7676

7777
var curlopts = new CodeBuilder(opts.indent, '\n' + opts.indent)
7878

@@ -97,13 +97,13 @@ module.exports = function (source, options) {
9797
})
9898

9999
if (headers.length) {
100-
curlopts.push('CURLOPT_HTTPHEADER => array(')
100+
curlopts.push('CURLOPT_HTTPHEADER => [')
101101
.push(1, headers.join(',\n' + opts.indent + opts.indent))
102-
.push('),')
102+
.push('],')
103103
}
104104

105105
code.push(1, curlopts.join())
106-
.push('));')
106+
.push(']);')
107107
.blank()
108108
.push('$response = curl_exec($curl);')
109109
.push('$err = curl_error($curl);')

src/targets/php/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var convert = function (obj, indent, lastIndent) {
3131
result.push(convert(item, indent + indent, indent))
3232
})
3333

34-
result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ')'
34+
result = '[\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ']'
3535
break
3636

3737
case '[object Object]':
@@ -41,7 +41,7 @@ var convert = function (obj, indent, lastIndent) {
4141
result.push(convert(i, indent) + ' => ' + convert(obj[i], indent + indent, indent))
4242
}
4343
}
44-
result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ')'
44+
result = '[\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ']'
4545
break
4646

4747
default:

test/fixtures/output/php/curl/application-form-encoded.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$curl = curl_init();
44

5-
curl_setopt_array($curl, array(
5+
curl_setopt_array($curl, [
66
CURLOPT_URL => "http://mockbin.com/har",
77
CURLOPT_RETURNTRANSFER => true,
88
CURLOPT_ENCODING => "",
@@ -11,10 +11,10 @@
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "POST",
1313
CURLOPT_POSTFIELDS => "foo=bar&hello=world",
14-
CURLOPT_HTTPHEADER => array(
14+
CURLOPT_HTTPHEADER => [
1515
"content-type: application/x-www-form-urlencoded"
16-
),
17-
));
16+
],
17+
]);
1818

1919
$response = curl_exec($curl);
2020
$err = curl_error($curl);

test/fixtures/output/php/curl/application-json.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$curl = curl_init();
44

5-
curl_setopt_array($curl, array(
5+
curl_setopt_array($curl, [
66
CURLOPT_URL => "http://mockbin.com/har",
77
CURLOPT_RETURNTRANSFER => true,
88
CURLOPT_ENCODING => "",
@@ -11,10 +11,10 @@
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "POST",
1313
CURLOPT_POSTFIELDS => "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}",
14-
CURLOPT_HTTPHEADER => array(
14+
CURLOPT_HTTPHEADER => [
1515
"content-type: application/json"
16-
),
17-
));
16+
],
17+
]);
1818

1919
$response = curl_exec($curl);
2020
$err = curl_error($curl);

test/fixtures/output/php/curl/cookies.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$curl = curl_init();
44

5-
curl_setopt_array($curl, array(
5+
curl_setopt_array($curl, [
66
CURLOPT_URL => "http://mockbin.com/har",
77
CURLOPT_RETURNTRANSFER => true,
88
CURLOPT_ENCODING => "",
@@ -11,7 +11,7 @@
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "POST",
1313
CURLOPT_COOKIE => "foo=bar; bar=baz",
14-
));
14+
]);
1515

1616
$response = curl_exec($curl);
1717
$err = curl_error($curl);

test/fixtures/output/php/curl/custom-method.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
$curl = curl_init();
44

5-
curl_setopt_array($curl, array(
5+
curl_setopt_array($curl, [
66
CURLOPT_URL => "http://mockbin.com/har",
77
CURLOPT_RETURNTRANSFER => true,
88
CURLOPT_ENCODING => "",
99
CURLOPT_MAXREDIRS => 10,
1010
CURLOPT_TIMEOUT => 30,
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "PROPFIND",
13-
));
13+
]);
1414

1515
$response = curl_exec($curl);
1616
$err = curl_error($curl);

test/fixtures/output/php/curl/full.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$curl = curl_init();
44

5-
curl_setopt_array($curl, array(
5+
curl_setopt_array($curl, [
66
CURLOPT_URL => "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value",
77
CURLOPT_RETURNTRANSFER => true,
88
CURLOPT_ENCODING => "",
@@ -12,11 +12,11 @@
1212
CURLOPT_CUSTOMREQUEST => "POST",
1313
CURLOPT_POSTFIELDS => "foo=bar",
1414
CURLOPT_COOKIE => "foo=bar; bar=baz",
15-
CURLOPT_HTTPHEADER => array(
15+
CURLOPT_HTTPHEADER => [
1616
"accept: application/json",
1717
"content-type: application/x-www-form-urlencoded"
18-
),
19-
));
18+
],
19+
]);
2020

2121
$response = curl_exec($curl);
2222
$err = curl_error($curl);

test/fixtures/output/php/curl/headers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
$curl = curl_init();
44

5-
curl_setopt_array($curl, array(
5+
curl_setopt_array($curl, [
66
CURLOPT_URL => "http://mockbin.com/har",
77
CURLOPT_RETURNTRANSFER => true,
88
CURLOPT_ENCODING => "",
99
CURLOPT_MAXREDIRS => 10,
1010
CURLOPT_TIMEOUT => 30,
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "GET",
13-
CURLOPT_HTTPHEADER => array(
13+
CURLOPT_HTTPHEADER => [
1414
"accept: application/json",
1515
"x-foo: Bar"
16-
),
17-
));
16+
],
17+
]);
1818

1919
$response = curl_exec($curl);
2020
$err = curl_error($curl);

test/fixtures/output/php/curl/https.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
$curl = curl_init();
44

5-
curl_setopt_array($curl, array(
5+
curl_setopt_array($curl, [
66
CURLOPT_URL => "https://mockbin.com/har",
77
CURLOPT_RETURNTRANSFER => true,
88
CURLOPT_ENCODING => "",
99
CURLOPT_MAXREDIRS => 10,
1010
CURLOPT_TIMEOUT => 30,
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "GET",
13-
));
13+
]);
1414

1515
$response = curl_exec($curl);
1616
$err = curl_error($curl);

test/fixtures/output/php/curl/jsonObj-multiline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$curl = curl_init();
44

5-
curl_setopt_array($curl, array(
5+
curl_setopt_array($curl, [
66
CURLOPT_URL => "http://mockbin.com/har",
77
CURLOPT_RETURNTRANSFER => true,
88
CURLOPT_ENCODING => "",
@@ -11,10 +11,10 @@
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "POST",
1313
CURLOPT_POSTFIELDS => "{\n \"foo\": \"bar\"\n}",
14-
CURLOPT_HTTPHEADER => array(
14+
CURLOPT_HTTPHEADER => [
1515
"content-type: application/json"
16-
),
17-
));
16+
],
17+
]);
1818

1919
$response = curl_exec($curl);
2020
$err = curl_error($curl);

0 commit comments

Comments
 (0)