Skip to content

Commit 78f2cfb

Browse files
committed
with -> using
1 parent 4680583 commit 78f2cfb

16 files changed

+86
-86
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
--TEST--
2-
with() calls enter and exit
2+
using() calls enter and exit
33
--FILE--
44
<?php
55

66
require 'basic_manager.inc';
77

8-
with (new Manager() as $value) {
9-
echo "In with() block\n";
8+
using (new Manager() as $value) {
9+
echo "In using() block\n";
1010
var_dump($value);
1111
}
1212

13-
echo "After with() block\n";
13+
echo "After using() block\n";
1414

1515
?>
1616
--EXPECTF--
1717
Manager::enterContext()
18-
In with() block
18+
In using() block
1919
object(stdClass)#%d (0) {
2020
}
2121
Manager::exitContext(null)
22-
After with() block
22+
After using() block
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
--TEST--
2-
'break' in with() jumps out of the block, considered a success
2+
'break' in using() jumps out of the block, considered a success
33
--FILE--
44
<?php
55

66
require 'basic_manager.inc';
77

8-
with (new Manager() as $value) {
9-
echo "In with() block\n";
8+
using (new Manager() as $value) {
9+
echo "In using() block\n";
1010
break;
1111
echo "Not executed\n";
1212
var_dump($value);
1313
}
1414

15-
echo "After with() block\n";
15+
echo "After using() block\n";
1616

1717
?>
1818
--EXPECT--
1919
Manager::enterContext()
20-
In with() block
20+
In using() block
2121
Manager::exitContext(null)
22-
After with() block
22+
After using() block
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
--TEST--
2-
'continue' in with() jumps out of the block, considered a success, warns like 'switch'
2+
'continue' in using() jumps out of the block, considered a success, warns like 'switch'
33
--FILE--
44
<?php
55

66
require 'basic_manager.inc';
77

8-
with (new Manager() as $value) {
9-
echo "In with() block\n";
8+
using (new Manager() as $value) {
9+
echo "In using() block\n";
1010
continue;
1111
echo "Not executed\n";
1212
var_dump($value);
1313
}
1414

15-
echo "After with() block\n";
15+
echo "After using() block\n";
1616

1717
?>
1818
--EXPECTF--
19-
Warning: "continue" targeting with is equivalent to "break" in %s on line %d
19+
Warning: "continue" targeting using is equivalent to "break" in %s on line %d
2020
Manager::enterContext()
21-
In with() block
21+
In using() block
2222
Manager::exitContext(null)
23-
After with() block
23+
After using() block
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
--TEST--
2-
with() does not rethrow exception when exitContext() returns true
2+
using() does not rethrow exception when exitContext() returns true
33
--FILE--
44
<?php
55

66
require 'basic_manager.inc';
77

8-
with (new Manager(false) as $value) {
9-
echo "In with() block\n";
8+
using (new Manager(false) as $value) {
9+
echo "In using() block\n";
1010
var_dump($value);
11-
throw new Exception('exception in with block');
11+
throw new Exception('exception in using block');
1212
}
1313

14-
echo "After with() block\n";
14+
echo "After using() block\n";
1515

1616
?>
1717
--EXPECTF--
1818
Manager::enterContext()
19-
In with() block
19+
In using() block
2020
object(stdClass)#%d (0) {
2121
}
22-
Manager::exitContext(Exception(exception in with block))
23-
After with() block
22+
Manager::exitContext(Exception(exception in using block))
23+
After using() block
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
--TEST--
2-
'goto' in with() jumps out of the block, considered a success
2+
'goto' in using() jumps out of the block, considered a success
33
--FILE--
44
<?php
55

66
require 'basic_manager.inc';
77

8-
with (new Manager() as $value) {
9-
echo "In with() block\n";
8+
using (new Manager() as $value) {
9+
echo "In using() block\n";
1010
goto out;
1111
echo "Not executed\n";
1212
var_dump($value);
1313
}
1414
out:
1515

16-
echo "After with() block\n";
16+
echo "After using() block\n";
1717

1818
?>
1919
--EXPECT--
2020
Manager::enterContext()
21-
In with() block
21+
In using() block
2222
Manager::exitContext(null)
23-
After with() block
23+
After using() block

Zend/tests/context_managers/variable_is_optional.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ Variable on the rhs of 'as' is optional
55

66
require 'basic_manager.inc';
77

8-
with (new Manager()) {
9-
echo "In with() block\n";
8+
using (new Manager()) {
9+
echo "In using() block\n";
1010
}
1111

12-
echo "After with() block\n";
12+
echo "After using() block\n";
1313

1414
?>
1515
--EXPECT--
1616
Manager::enterContext()
17-
In with() block
17+
In using() block
1818
Manager::exitContext(null)
19-
After with() block
19+
After using() block
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
--TEST--
2-
with() boxes resources in ResourceContextManager
2+
using() boxes resources in ResourceContextManager
33
--FILE--
44
<?php
55

66
$fd = fopen("php://memory", "r");
7-
with ($fd as $value) {
8-
echo "In with() block\n";
7+
using ($fd as $value) {
8+
echo "In using() block\n";
99
var_dump($value);
1010
}
1111

12-
echo "After with() block\n";
12+
echo "After using() block\n";
1313
var_dump($fd);
1414

1515
?>
1616
--EXPECTF--
17-
In with() block
17+
In using() block
1818
resource(%d) of type (stream)
19-
After with() block
19+
After using() block
2020
resource(%d) of type (Unknown)
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
--TEST--
2-
with() calls exitContext($exception) on exception and re-throws by default
2+
using() calls exitContext($exception) on exception and re-throws by default
33
--FILE--
44
<?php
55

66
require 'basic_manager.inc';
77

88
try {
9-
with (new Manager() as $value) {
10-
echo "In with() block\n";
9+
using (new Manager() as $value) {
10+
echo "In using() block\n";
1111
var_dump($value);
12-
throw new Exception('exception in with block');
12+
throw new Exception('exception in using block');
1313
}
1414
} catch (Exception $e) {
1515
echo $e::class, ": ", $e->getMessage(), "\n";
1616
}
1717

18-
echo "After with() block\n";
18+
echo "After using() block\n";
1919

2020
?>
2121
--EXPECTF--
2222
Manager::enterContext()
23-
In with() block
23+
In using() block
2424
object(stdClass)#%d (0) {
2525
}
26-
Manager::exitContext(Exception(exception in with block))
27-
Exception: exception in with block
28-
After with() block
26+
Manager::exitContext(Exception(exception in using block))
27+
Exception: exception in using block
28+
After using() block
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
--TEST--
2-
with() handles Throwable
2+
using() handles Throwable
33
--FILE--
44
<?php
55

66
require 'basic_manager.inc';
77

88
try {
9-
with (new Manager() as $value) {
10-
echo "In with() block\n";
9+
using (new Manager() as $value) {
10+
echo "In using() block\n";
1111
var_dump($value);
12-
throw new Error('error in with block');
12+
throw new Error('error in using block');
1313
}
1414
} catch (Error $e) {
1515
echo $e::class, ": ", $e->getMessage(), "\n";
1616
}
1717

18-
echo "After with() block\n";
18+
echo "After using() block\n";
1919

2020
?>
2121
--EXPECTF--
2222
Manager::enterContext()
23-
In with() block
23+
In using() block
2424
object(stdClass)#%d (0) {
2525
}
26-
Manager::exitContext(Error(error in with block))
27-
Error: error in with block
28-
After with() block
26+
Manager::exitContext(Error(error in using block))
27+
Error: error in using block
28+
After using() block

Zend/tests/context_managers/with_keyword_is_semi_reserved.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
--TEST--
2-
'with' keyword is semi reserved
2+
'using' keyword is semi reserved
33
--FILE--
44
<?php
55

66
class Test {
77
const WITH = 1;
8-
public $with;
9-
function with ($with) {}
8+
public $using;
9+
function using ($using) {}
1010
}
1111

12-
$with = 1;
12+
$using = 1;
1313

1414
// Not allowed:
15-
// function with() {}
16-
// class with {}
15+
// function using() {}
16+
// class using {}
1717
// const WITH = 1;
1818

1919
?>

0 commit comments

Comments
 (0)