Skip to content

Commit 7126de4

Browse files
committed
- Next step in namespaces, using / as namespace separator.
1 parent 6ca3ad3 commit 7126de4

File tree

122 files changed

+3739
-3571
lines changed

Some content is hidden

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

122 files changed

+3739
-3571
lines changed

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ PHP NEWS
157157
. Improved syntax highlighting and consistency for variables in double-quoted
158158
strings and literal text in HEREDOCs and backticks. (Matt)
159159
. Added "?:" operator. (Marcus)
160-
. Added support for namespaces. (Dmitry, Stas, Gregory)
160+
. Added support for namespaces. (Dmitry, Stas, Gregory, Marcus)
161161
. Added support for Late Static Binding. (Dmitry, Etienne Kneuss)
162162
. Added support for __callStatic() magic method. (Sara)
163163
. Added forward_static_call(_array) to complete LSB. (Mike Lively)

Zend/tests/bug42802.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ function test1(bar $bar) {
1111
echo "ok\n";
1212
}
1313

14-
function test2(foo::bar $bar) {
14+
function test2(\foo\bar $bar) {
1515
echo "ok\n";
1616
}
17-
function test3(::foo::bar $bar) {
17+
function test3(\foo\bar $bar) {
1818
echo "ok\n";
1919
}
20-
function test4(::Exception $e) {
20+
function test4(\Exception $e) {
2121
echo "ok\n";
2222
}
2323
function test5(Exception $e) {
2424
echo "ok\n";
2525
}
26-
function test6(::bar $bar) {
26+
function test6(\bar $bar) {
2727
echo "bug\n";
2828
}
2929

@@ -42,4 +42,4 @@ ok
4242
ok
4343
ok
4444

45-
Catchable fatal error: Argument 1 passed to foo::test6() must be an instance of bar, instance of foo::bar given, called in %sbug42802.php on line 23
45+
Catchable fatal error: Argument 1 passed to foo\test6() must be an instance of bar, instance of foo\bar given, called in %sbug42802.php on line 23

Zend/tests/bug42819.phpt

Lines changed: 83 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,88 +4,100 @@ Bug #42819 (namespaces in indexes of constant arrays)
44
<?php if (!extension_loaded("spl")) print "skip"; ?>
55
--FILE--
66
<?php
7+
namespace foo\foo;
8+
9+
const C = "foo\\foo\\C\n";
10+
const I = 12;
11+
12+
class foo {
13+
const I = 32;
14+
const C = "foo\\foo\\foo::C\n";
15+
}
16+
717
namespace foo;
818

9-
const C = "foo::C\n";
19+
const C = "foo\\C\n";
1020
const I = 11;
1121

1222
class foo {
13-
const C = "foo::foo::C\n";
23+
const C = "foo\\foo::C\n";
1424
const I = 22;
1525
const C1 = C;
16-
const C2 = foo::C;
17-
const C3 = foo::foo::C;
18-
const C4 = ::foo::C;
19-
const C5 = ::foo::foo::C;
26+
const C2 = foo\C;
27+
const C3 = foo\foo::C;
28+
const C4 = \foo\C;
29+
const C5 = \foo\foo::C;
2030
const C6 = ArrayObject::STD_PROP_LIST;
2131
const C7 = E_ERROR;
2232
}
2333

2434
class bar1 {
2535
static $a1 = array(I => 0);
26-
static $a2 = array(foo::I => 0);
27-
static $a3 = array(foo::foo::I => 0);
28-
static $a4 = array(::foo::I => 0);
29-
static $a5 = array(::foo::foo::I => 0);
36+
static $a2 = array(foo\I => 0);
37+
static $a3 = array(foo\foo::I => 0);
38+
static $a4 = array(\foo\I => 0);
39+
static $a5 = array(\foo\foo::I => 0);
3040
static $a6 = array(ArrayObject::STD_PROP_LIST => 0);
3141
static $a7 = array(E_ERROR => 0);
3242
}
3343

3444
class bar2 {
3545
static $a1 = array(I => I);
36-
static $a2 = array(foo::I => I);
37-
static $a3 = array(foo::foo::I => I);
38-
static $a4 = array(::foo::I => I);
39-
static $a5 = array(::foo::foo::I => I);
46+
static $a2 = array(foo\I => I);
47+
static $a3 = array(foo\foo::I => I);
48+
static $a4 = array(\foo\I => I);
49+
static $a5 = array(\foo\foo::I => I);
4050
static $a6 = array(ArrayObject::STD_PROP_LIST => I);
4151
static $a7 = array(E_ERROR => I);
4252
}
4353

4454
class bar3 {
45-
static $a1 = array(I => foo::I);
46-
static $a2 = array(foo::I => foo::I);
47-
static $a3 = array(foo::foo::I => foo::I);
48-
static $a4 = array(::foo::I => foo::I);
49-
static $a5 = array(::foo::foo::I => foo::I);
50-
static $a6 = array(ArrayObject::STD_PROP_LIST => foo::I);
51-
static $a7 = array(E_ERROR => foo::I);
55+
static $a1 = array(I => foo\I);
56+
static $a2 = array(foo\I => foo\I);
57+
static $a3 = array(foo\foo::I => foo\I);
58+
static $a4 = array(\foo\I => foo\I);
59+
static $a5 = array(\foo\foo::I => foo\I);
60+
static $a6 = array(ArrayObject::STD_PROP_LIST => foo\I);
61+
static $a7 = array(E_ERROR => foo\I);
5262
}
5363

5464
class bar4 {
5565
static $a1 = array(I => ArrayObject::STD_PROP_LIST);
56-
static $a2 = array(foo::I => ArrayObject::STD_PROP_LIST);
57-
static $a3 = array(foo::foo::I => ArrayObject::STD_PROP_LIST);
58-
static $a4 = array(::foo::I => ArrayObject::STD_PROP_LIST);
59-
static $a5 = array(::foo::foo::I => ArrayObject::STD_PROP_LIST);
66+
static $a2 = array(foo\I => ArrayObject::STD_PROP_LIST);
67+
static $a3 = array(foo\foo::I => ArrayObject::STD_PROP_LIST);
68+
static $a4 = array(\foo\I => ArrayObject::STD_PROP_LIST);
69+
static $a5 = array(\foo\foo::I => ArrayObject::STD_PROP_LIST);
6070
static $a6 = array(ArrayObject::STD_PROP_LIST => ArrayObject::STD_PROP_LIST);
6171
static $a7 = array(E_ERROR => ArrayObject::STD_PROP_LIST);
6272
}
6373

6474
class bar5 {
6575
static $a1 = array(I => E_ERROR);
66-
static $a2 = array(foo::I => E_ERROR);
67-
static $a3 = array(foo::foo::I => E_ERROR);
68-
static $a4 = array(::foo::I => E_ERROR);
69-
static $a5 = array(::foo::foo::I => E_ERROR);
76+
static $a2 = array(foo\I => E_ERROR);
77+
static $a3 = array(foo\foo::I => E_ERROR);
78+
static $a4 = array(\foo\I => E_ERROR);
79+
static $a5 = array(\foo\foo::I => E_ERROR);
7080
static $a6 = array(ArrayObject::STD_PROP_LIST => E_ERROR);
7181
static $a7 = array(E_ERROR => E_ERROR);
7282
}
7383

84+
echo "first\n";
7485
echo C;
86+
echo foo\C;
87+
echo foo\foo::C;
7588
echo foo::C;
76-
echo foo::foo::C;
77-
echo ::foo::C;
78-
echo ::foo::foo::C;
89+
echo \foo\foo::C;
7990
echo ArrayObject::STD_PROP_LIST . "\n";
8091
echo E_ERROR . "\n";
8192

82-
echo foo::foo::C1;
83-
echo foo::foo::C2;
84-
echo foo::foo::C3;
85-
echo foo::foo::C4;
86-
echo foo::foo::C5;
87-
echo foo::foo::C6 . "\n";
88-
echo foo::foo::C7 . "\n";
93+
echo "second\n";
94+
echo \foo\foo::C1;
95+
echo \foo\foo::C2;
96+
echo \foo\foo::C3;
97+
echo \foo\foo::C4;
98+
echo \foo\foo::C5;
99+
echo \foo\foo::C6 . "\n";
100+
echo \foo\foo::C7 . "\n";
89101

90102
print_r(bar1::$a1);
91103
print_r(bar1::$a2);
@@ -126,20 +138,24 @@ print_r(bar5::$a4);
126138
print_r(bar5::$a5);
127139
print_r(bar5::$a6);
128140
print_r(bar5::$a7);
141+
function oops($a = array(foo\unknown)){}
142+
oops();
129143
?>
130-
--EXPECT--
131-
foo::C
132-
foo::C
133-
foo::foo::C
134-
foo::C
135-
foo::foo::C
144+
--EXPECTF--
145+
first
146+
foo\C
147+
foo\foo\C
148+
foo\foo\foo::C
149+
foo\foo::C
150+
foo\foo::C
136151
1
137152
1
138-
foo::C
139-
foo::C
140-
foo::foo::C
141-
foo::C
142-
foo::foo::C
153+
second
154+
foo\C
155+
foo\foo\C
156+
foo\foo\foo::C
157+
foo\C
158+
foo\foo::C
143159
1
144160
1
145161
Array
@@ -148,11 +164,11 @@ Array
148164
)
149165
Array
150166
(
151-
[11] => 0
167+
[12] => 0
152168
)
153169
Array
154170
(
155-
[22] => 0
171+
[32] => 0
156172
)
157173
Array
158174
(
@@ -176,11 +192,11 @@ Array
176192
)
177193
Array
178194
(
179-
[11] => 11
195+
[12] => 11
180196
)
181197
Array
182198
(
183-
[22] => 11
199+
[32] => 11
184200
)
185201
Array
186202
(
@@ -200,43 +216,43 @@ Array
200216
)
201217
Array
202218
(
203-
[11] => 11
219+
[11] => 12
204220
)
205221
Array
206222
(
207-
[11] => 11
223+
[12] => 12
208224
)
209225
Array
210226
(
211-
[22] => 11
227+
[32] => 12
212228
)
213229
Array
214230
(
215-
[11] => 11
231+
[11] => 12
216232
)
217233
Array
218234
(
219-
[22] => 11
235+
[22] => 12
220236
)
221237
Array
222238
(
223-
[1] => 11
239+
[1] => 12
224240
)
225241
Array
226242
(
227-
[1] => 11
243+
[1] => 12
228244
)
229245
Array
230246
(
231247
[11] => 1
232248
)
233249
Array
234250
(
235-
[11] => 1
251+
[12] => 1
236252
)
237253
Array
238254
(
239-
[22] => 1
255+
[32] => 1
240256
)
241257
Array
242258
(
@@ -260,11 +276,11 @@ Array
260276
)
261277
Array
262278
(
263-
[11] => 1
279+
[12] => 1
264280
)
265281
Array
266282
(
267-
[22] => 1
283+
[32] => 1
268284
)
269285
Array
270286
(
@@ -282,3 +298,5 @@ Array
282298
(
283299
[1] => 1
284300
)
301+
302+
Fatal error: Undefined constant 'foo\foo\unknown' in %sbug42819.php on line %d

Zend/tests/bug42820.phpt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ const ok = 0;
77
class foo {
88
const ok = 0;
99
}
10-
var_dump(defined('ns::ok'));
11-
var_dump(defined('ns::bug'));
12-
var_dump(defined('::ns::ok'));
13-
var_dump(defined('::ns::bug'));
14-
var_dump(defined('ns::foo::ok'));
15-
var_dump(defined('ns::foo::bug'));
16-
var_dump(defined('::ns::foo::ok'));
17-
var_dump(defined('::ns::foo::bug'));
18-
var_dump(defined('ns::bar::bug'));
19-
var_dump(defined('::ns::bar::bug'));
10+
var_dump(defined('ns\\ok'));
11+
var_dump(defined('ns\\bug'));
12+
var_dump(defined('\\ns\\ok'));
13+
var_dump(defined('\\ns\\bug'));
14+
var_dump(defined('ns\\foo::ok'));
15+
var_dump(defined('ns\\foo::bug'));
16+
var_dump(defined('\\ns\\foo::ok'));
17+
var_dump(defined('\\ns\\foo::bug'));
18+
var_dump(defined('ns\\bar::bug'));
19+
var_dump(defined('\\ns\\bar::bug'));
2020
--EXPECT--
2121
bool(true)
2222
bool(false)

Zend/tests/bug42859.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Bug #42859 (import always conflicts with internal classes)
55
namespace Foo;
66
class Ex {}
77

8-
use Blah::Exception;
9-
use Blah::Ex;
8+
use Blah\Exception;
9+
use Blah\Ex;
1010
?>
1111
--EXPECTF--
12-
Fatal error: Cannot use Blah::Ex as Ex because the name is already in use in %sbug42859.php on line 6
12+
Fatal error: Cannot use Blah\Ex as Ex because the name is already in use in %sbug42859.php on line 6

Zend/tests/bug43183.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Bug #43183 ("use" of the same class in difference scripts results in a fatal err
33
--FILE--
44
<?php
55
namespace Test;
6-
use Test::Foo;
6+
use Test\Foo;
77
class Foo {}
88
class Bar {}
9-
use Test::Bar;
9+
use Test\Bar;
1010
echo "ok\n";
1111
--EXPECT--
1212
ok

Zend/tests/bug43332_1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ $foo = new foo;
1212
$foo->bar($foo); // Ok!
1313
$foo->bar(new stdclass); // Error, ok!
1414
--EXPECTF--
15-
Catchable fatal error: Argument 1 passed to foobar::foo::bar() must be an instance of foobar::foo, instance of stdClass given, called in %sbug43332_1.php on line 10 and defined in %sbug43332_1.php on line 5
15+
Catchable fatal error: Argument 1 passed to foobar\foo::bar() must be an instance of foobar\foo, instance of stdClass given, called in %sbug43332_1.php on line 10 and defined in %sbug43332_1.php on line 5

Zend/tests/bug43332_2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Bug #43332.2 (self and parent as type hint in namespace)
55
namespace foobar;
66

77
class foo {
8-
public function bar(::self $a) { }
8+
public function bar(\self $a) { }
99
}
1010

1111
$foo = new foo;
1212
$foo->bar($foo); // Ok!
1313
$foo->bar(new stdclass); // Error, ok!
1414
--EXPECTF--
15-
Fatal error: '::self' is a wrong class name in %sbug43332_2.php on line 5
15+
Fatal error: 'self' is an invalid class name in %sbug43332_2.php on line 5

Zend/tests/bug43343.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ $foo = 'bar';
88
var_dump(new namespace::$foo);
99
?>
1010
--EXPECTF--
11-
Fatal error: Cannot use 'namespace' as a class name in %sbug43343.php on line 5
11+
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting T_NS_SEPARATOR in %sbug43343.php on line 5

0 commit comments

Comments
 (0)