Skip to content

Commit ea08e2b

Browse files
committed
Changed named params syntax to use colon
Per current RFC
1 parent 86f74a2 commit ea08e2b

12 files changed

+52
-52
lines changed

Zend/tests/named_params/basic.phpt

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,46 @@ function &id($x) {
1818
$a = "A"; $b = "B"; $c = "C"; $d = "D"; $e = "E";
1919

2020
echo "SEND_VAL:\n";
21-
test("A", "B", "C", d => "D", e => "E");
22-
test("A", "B", "C", e => "E", d => "D");
23-
test(e => "E", a => "A", d => "D", b => "B", c => "C");
24-
test("A", "B", "C", e => "E");
21+
test("A", "B", "C", d: "D", e: "E");
22+
test("A", "B", "C", e: "E", d: "D");
23+
test(e: "E", a: "A", d: "D", b: "B", c: "C");
24+
test("A", "B", "C", e: "E");
2525

2626
echo "SEND_VAL_EX:\n";
27-
test2("A", "B", "C", d => "D", e => "E");
28-
test2("A", "B", "C", e => "E", d => "D");
29-
test2(e => "E", a => "A", d => "D", b => "B", c => "C");
30-
test2("A", "B", "C", e => "E");
27+
test2("A", "B", "C", d: "D", e: "E");
28+
test2("A", "B", "C", e: "E", d: "D");
29+
test2(e: "E", a: "A", d: "D", b: "B", c: "C");
30+
test2("A", "B", "C", e: "E");
3131

3232
echo "SEND_VAR:\n";
33-
test($a, $b, $c, d => $d, e => $e);
34-
test($a, $b, $c, e => $e, d => $d);
35-
test(e => $e, a => $a, d => $d, b => $b, c => $c);
36-
test(a => $a, b => $b, c => $c, e => $e);
33+
test($a, $b, $c, d: $d, e: $e);
34+
test($a, $b, $c, e: $e, d: $d);
35+
test(e: $e, a: $a, d: $d, b: $b, c: $c);
36+
test(a: $a, b: $b, c: $c, e: $e);
3737

3838
echo "SEND_VAR_EX:\n";
39-
test2($a, $b, $c, d => $d, e => $e);
40-
test2($a, $b, $c, e => $e, d => $d);
41-
test2(e => $e, a => $a, d => $d, b => $b, c => $c);
42-
test2(a => $a, b => $b, c => $c, e => $e);
39+
test2($a, $b, $c, d: $d, e: $e);
40+
test2($a, $b, $c, e: $e, d: $d);
41+
test2(e: $e, a: $a, d: $d, b: $b, c: $c);
42+
test2(a: $a, b: $b, c: $c, e: $e);
4343

4444
echo "SEND_VAR_NO_REF:\n";
45-
test3(id("A"), id("B"), id("C"), d => id("D"), e => id("E"));
46-
test3(id("A"), id("B"), id("C"), e => id("E"), d => id("D"));
47-
test3(e => id("E"), a => id("A"), d => id("D"), b => id("B"), c => id("C"));
48-
test3(id("A"), id("B"), id("C"), e => id("E"));
45+
test3(id("A"), id("B"), id("C"), d: id("D"), e: id("E"));
46+
test3(id("A"), id("B"), id("C"), e: id("E"), d: id("D"));
47+
test3(e: id("E"), a: id("A"), d: id("D"), b: id("B"), c: id("C"));
48+
test3(id("A"), id("B"), id("C"), e: id("E"));
4949

5050
echo "SEND_VAR_NO_REF_EX:\n";
51-
test4(id("A"), id("B"), id("C"), d => id("D"), e => id("E"));
52-
test4(id("A"), id("B"), id("C"), e => id("E"), d => id("D"));
53-
test4(e => id("E"), a => id("A"), d => id("D"), b => id("B"), c => id("C"));
54-
test4(id("A"), id("B"), id("C"), e => id("E"));
51+
test4(id("A"), id("B"), id("C"), d: id("D"), e: id("E"));
52+
test4(id("A"), id("B"), id("C"), e: id("E"), d: id("D"));
53+
test4(e: id("E"), a: id("A"), d: id("D"), b: id("B"), c: id("C"));
54+
test4(id("A"), id("B"), id("C"), e: id("E"));
5555

5656
echo "SEND_REF:\n";
57-
test3($a, $b, $c, d => $d, e => $e);
58-
test3($a, $b, $c, e => $e, d => $d);
59-
test3(e => $e, a => $a, d => $d, b => $b, c => $c);
60-
test3(a => $a, b => $b, c => $c, e => $e);
57+
test3($a, $b, $c, d: $d, e: $e);
58+
test3($a, $b, $c, e: $e, d: $d);
59+
test3(e: $e, a: $a, d: $d, b: $b, c: $c);
60+
test3(a: $a, b: $b, c: $c, e: $e);
6161

6262
function test2($a, $b, $c = "c", $d = "d", $e = "e") {
6363
echo "a=$a, b=$b, c=$c, d=$d, e=$e\n";

Zend/tests/named_params/duplicate_param.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Duplicate param
66
function test($a) {}
77

88
try {
9-
test(a => 1, a => 2);
9+
test(a: 1, a: 2);
1010
} catch (Error $e) {
1111
echo $e->getMessage(), "\n";
1212
}
1313

1414
try {
15-
test(1, a => 2);
15+
test(1, a: 2);
1616
} catch (Error $e) {
1717
echo $e->getMessage(), "\n";
1818
}

Zend/tests/named_params/internal.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Named params on internal functions
33
--FILE--
44
<?php
55

6-
var_dump(array_slice(arg => [1, 2, 3, 4, 5], offset => 2, length => 2));
7-
var_dump(array_slice(length => 2, offset => 2, arg => [1, 2, 3, 4, 5]));
6+
var_dump(array_slice(arg: [1, 2, 3, 4, 5], offset: 2, length: 2));
7+
var_dump(array_slice(length: 2, offset: 2, arg: [1, 2, 3, 4, 5]));
88

9-
var_dump(array_slice(arg => ['a' => 0, 'b' => 1], offset => 1, preserve_keys => true));
10-
var_dump(array_slice(['a' => 0, 'b' => 1], preserve_keys => true, offset => 1));
9+
var_dump(array_slice(arg: ['a' => 0, 'b' => 1], offset: 1, preserve_keys: true));
10+
var_dump(array_slice(['a' => 0, 'b' => 1], preserve_keys: true, offset: 1));
1111

1212
?>
1313
--EXPECT--

Zend/tests/named_params/missing_param.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ function test($a, $b, $c, $d) {
77
}
88

99
try {
10-
test(a => 'a', d => 'd');
10+
test(a: 'a', d: 'd');
1111
} catch (ArgumentCountError $e) {
1212
echo $e->getMessage(), "\n";
1313
}
1414

1515
try {
16-
array_keys(strict => true);
16+
array_keys(strict: true);
1717
} catch (ArgumentCountError $e) {
1818
echo $e->getMessage(), "\n";
1919
}
2020

2121
try {
22-
array_keys([], strict => true);
22+
array_keys([], strict: true);
2323
} catch (ArgumentCountError $e) {
2424
echo $e->getMessage(), "\n";
2525
}
2626

2727
// This works fine, as search_value is explicitly specified.
28-
var_dump(array_keys([41, 42], search_value => 42, strict => true));
28+
var_dump(array_keys([41, 42], search_value: 42, strict: true));
2929

3030
?>
3131
--EXPECT--

Zend/tests/named_params/positional_after_named.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Cannot used positional parameter after named parameter
33
--FILE--
44
<?php
55

6-
test(a => 1, 2);
6+
test(a: 1, 2);
77

88
?>
99
--EXPECTF--

Zend/tests/named_params/references.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Check that reference detection works properly
44
<?php
55

66
$v00 = $v01 = $v32 = $v33 = 0;
7-
test(p32 => $v32, p33 => $v33, p00 => $v00, p01 => $v01);
7+
test(p32: $v32, p33: $v33, p00: $v00, p01: $v01);
88
echo "$v00 $v01 $v32 $v33\n";
99

1010
$v = [0 => 0, 1 => 0, 32 => 0, 33 => 0];
11-
test(p32 => $v[32], p33 => $v[33], p00 => $v[0], p01 => $v[1]);
11+
test(p32: $v[32], p33: $v[33], p00: $v[0], p01: $v[1]);
1212
echo "$v[0] $v[1] $v[32] $v[33]\n";
1313

1414
function test(
@@ -24,11 +24,11 @@ function test(
2424
}
2525

2626
$v00 = $v01 = $v32 = $v33 = 0;
27-
test(p32 => $v32, p33 => $v33, p00 => $v00, p01 => $v01);
27+
test(p32: $v32, p33: $v33, p00: $v00, p01: $v01);
2828
echo "$v00 $v01 $v32 $v33\n";
2929

3030
$v = [0 => 0, 1 => 0, 32 => 0, 33 => 0];
31-
test(p32 => $v[32], p33 => $v[33], p00 => $v[0], p01 => $v[1]);
31+
test(p32: $v[32], p33: $v[33], p00: $v[0], p01: $v[1]);
3232
echo "$v[0] $v[1] $v[32] $v[33]\n";
3333

3434
?>

Zend/tests/named_params/reserved.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function test($array) {
77
var_dump($array);
88
}
99

10-
test(array => []);
10+
test(array: []);
1111

1212
?>
1313
--EXPECT--

Zend/tests/named_params/unknown_named_param.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ function test2(...$a) {
1010
}
1111

1212
try {
13-
test(b => 42);
13+
test(b: 42);
1414
} catch (Error $e) {
1515
echo $e->getMessage(), "\n";
1616
}
1717

1818
try {
19-
test2(a => 42);
19+
test2(a: 42);
2020
} catch (Error $e) {
2121
echo $e->getMessage(), "\n";
2222
}

Zend/tests/named_params/unpack_and_named_1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Mixing unpacking and named params (1)
33
--FILE--
44
<?php
55

6-
test(...[], a => 42);
6+
test(...[], a: 42);
77

88
?>
99
--EXPECTF--

Zend/tests/named_params/unpack_and_named_2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Mixing unpacking and named params (2)
33
--FILE--
44
<?php
55

6-
test(a => 42, ...[]);
6+
test(a: 42, ...[]);
77

88
?>
99
--EXPECTF--

Zend/tests/named_params/variadic.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ function test2(&...$refs) {
1515
foreach ($refs as &$ref) $ref++;
1616
}
1717

18-
test(b => 'b', a => 'a', c => 'c', extra => 'extra');
18+
test(b: 'b', a: 'a', c: 'c', extra: 'extra');
1919
echo "\n";
2020

21-
test('a', 'b', 'c', d => 'd');
21+
test('a', 'b', 'c', d: 'd');
2222
echo "\n";
2323

2424
$x = 0;
2525
$y = 0;
26-
test2(x => $x, y => $y);
26+
test2(x: $x, y: $y);
2727
var_dump($x, $y);
2828

2929
?>

Zend/zend_language_parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ non_empty_argument_list:
760760

761761
argument:
762762
expr { $$ = $1; }
763-
| identifier T_DOUBLE_ARROW expr
763+
| identifier ':' expr
764764
{ $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, $3); }
765765
| T_ELLIPSIS expr { $$ = zend_ast_create(ZEND_AST_UNPACK, $2); }
766766
;

0 commit comments

Comments
 (0)