Skip to content

Commit 2f31b13

Browse files
committed
Update the syntax of clone with
1 parent ac04bf5 commit 2f31b13

30 files changed

+75
-76
lines changed

Zend/tests/clone_initializer/clone_initializer_error1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class Foo
1313

1414
?>
1515
--EXPECTF--
16-
Parse error: syntax error, unexpected token ";", expecting "{" in %s on line %d
16+
Parse error: syntax error, unexpected token ";", expecting "[" in %s on line %d

Zend/tests/clone_initializer/clone_initializer_error10.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class Foo
1515
$foo1 = new Foo(0);
1616

1717
try {
18-
$foo2 = clone $foo1 with {bar: 1};
18+
$foo2 = clone $foo1 with ["bar" => 1];
1919
} catch (Error $exception) {
2020
echo $exception->getMessage() . "\n";
2121
}
2222

2323
try {
24-
$foo2 = clone $foo1 with {baz: 1};
24+
$foo2 = clone $foo1 with ["baz" => 1];
2525
} catch (Error $exception) {
2626
echo $exception->getMessage() . "\n";
2727
}

Zend/tests/clone_initializer/clone_initializer_error11.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class Foo
1616

1717
public function with()
1818
{
19-
return clone $this with {
19+
return clone $this with [
2020
"bar" => 1,
2121
"bar" => 2,
22-
};
22+
];
2323
}
2424
}
2525

Zend/tests/clone_initializer/clone_initializer_error2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Foo
77
{
88
public function withProperties()
99
{
10-
return clone $this with {1: "value"};
10+
return clone $this with [1: "value"];
1111
}
1212
}
1313

Zend/tests/clone_initializer/clone_initializer_error3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Foo
1111
$foo = new Foo();
1212

1313
try {
14-
$foo = clone $foo with {bar: 1};
14+
$foo = clone $foo with ["bar" => 1];
1515
} catch (Error $exception) {
1616
echo $exception->getMessage() . "\n";
1717
}

Zend/tests/clone_initializer/clone_initializer_error4.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ class Foo
1111

1212
public function with()
1313
{
14-
return clone $this with {
15-
bar: 1,
16-
bar: 2,
17-
};
14+
return clone $this with [
15+
"bar" => 1,
16+
"bar" => 2,
17+
];
1818
}
1919
}
2020

Zend/tests/clone_initializer/clone_initializer_error5.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class Foo
1111
$obj1 = new Foo();
1212

1313
try {
14-
clone $obj1 with {bar: []};
14+
clone $obj1 with ["bar" => []];
1515
} catch (TypeError $e) {
1616
echo $e->getMessage() . "\n";
1717
}
1818

1919
try {
20-
clone $obj1 with {bar: []}; // The same as above but now using cache slots
20+
clone $obj1 with ["bar" => []]; // The same as above but now using cache slots
2121
} catch (TypeError $e) {
2222
echo $e->getMessage() . "\n";
2323
}

Zend/tests/clone_initializer/clone_initializer_error6.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ function returnFoo() {
1717
}
1818

1919
try {
20-
clone returnFoo() with {bar: new stdClass()};
20+
clone returnFoo() with ["bar" => new stdClass()];
2121
} catch (Exception $e) {
2222
echo $e->getMessage() . "\n";
2323
}
2424

2525
try {
26-
clone returnFoo() with {bar: new stdClass()}; // The same as above but now using cache slots
26+
clone returnFoo() with ["bar" => new stdClass()]; // The same as above but now using cache slots
2727
} catch (Exception $e) {
2828
echo $e->getMessage() . "\n";
2929
}

Zend/tests/clone_initializer/clone_initializer_error7.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ function returnFoo() {
1616
}
1717

1818
try {
19-
clone returnFoo() with {bar: new stdClass()};
19+
clone returnFoo() with ["bar" => new stdClass()];
2020
} catch (Exception $e) {
2121
echo $e->getMessage() . "\n";
2222
}
2323

2424
try {
25-
clone returnFoo() with {bar: new stdClass()}; // The same as above but now using cache slots
25+
clone returnFoo() with ["bar" => new stdClass()]; // The same as above but now using cache slots
2626
} catch (Exception $e) {
2727
echo $e->getMessage() . "\n";
2828
}

Zend/tests/clone_initializer/clone_initializer_error8.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,49 @@ Test "clone with" with invalid property names
44
<?php
55

66
try {
7-
clone new stdClass() with {$undefined => 1};
7+
clone new stdClass() with [$undefined => 1];
88
} catch (TypeError $e) {
99
echo $e->getMessage() . "\n";
1010
}
1111

1212
try {
13-
clone new stdClass() with {$undefined => 1}; // The same as above but now using cache slots
13+
clone new stdClass() with [$undefined => 1]; // The same as above but now using cache slots
1414
} catch (TypeError $e) {
1515
echo $e->getMessage() . "\n";
1616
}
1717

1818
try {
19-
clone new stdClass() with {null => 1};
19+
clone new stdClass() with [null => 1];
2020
} catch (TypeError $e) {
2121
echo $e->getMessage() . "\n";
2222
}
2323

2424
try {
25-
clone new stdClass() with {null => 1}; // The same as above but now using cache slots
25+
clone new stdClass() with [null => 1]; // The same as above but now using cache slots
2626
} catch (TypeError $e) {
2727
echo $e->getMessage() . "\n";
2828
}
2929

3030
try {
31-
clone new stdClass() with {[] => 1};
31+
clone new stdClass() with [[] => 1];
3232
} catch (TypeError $e) {
3333
echo $e->getMessage() . "\n";
3434
}
3535

3636
try {
37-
clone new stdClass() with {[] => 1}; // The same as above but now using cache slots
37+
clone new stdClass() with [[] => 1]; // The same as above but now using cache slots
3838
} catch (TypeError $e) {
3939
echo $e->getMessage() . "\n";
4040
}
4141

4242
try {
43-
clone new stdClass() with {1 => 1};
43+
clone new stdClass() with [1 => 1];
4444
} catch (TypeError $e) {
4545
echo $e->getMessage() . "\n";
4646
}
4747

4848
try {
49-
clone new stdClass() with {1 => 1}; // The same as above but now using cache slots
49+
clone new stdClass() with [1 => 1]; // The same as above but now using cache slots
5050
} catch (TypeError $e) {
5151
echo $e->getMessage() . "\n";
5252
}

0 commit comments

Comments
 (0)