Skip to content

Commit 79eb561

Browse files
committed
Treat namespaced names as single token
1 parent 613a56d commit 79eb561

17 files changed

+128
-41
lines changed

Zend/tests/attributes/019_variable_attribute_name.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ class A {}
88

99
?>
1010
--EXPECTF--
11-
Parse error: syntax error, unexpected '$x' (T_VARIABLE), expecting identifier (T_STRING) or static (T_STATIC) or namespace (T_NAMESPACE) or \\ (T_NS_SEPARATOR) in %s on line %d
11+
Parse error: syntax error, unexpected '$x' (T_VARIABLE) in %s on line %d

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-
Parse error: %s error%sexpecting%sT_NS_SEPARATOR%sin %sbug43343.php on line 5
11+
Parse error: syntax error, unexpected 'namespace' (T_NAMESPACE) in %s on line %d

Zend/tests/bug55086.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace N2 {
2626
echo $a->hello(), PHP_EOL;
2727
echo $a->foo(), PHP_EOL;
2828
try {
29-
} catch(namespace \Foo $e)
29+
} catch (namespace\Foo $e)
3030
{
3131
}
3232
}

Zend/tests/grammar/regression_010.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ Test to check regressions on T_IMPLEMENTS followed by a T_NS_SEPARATOR
55

66
interface A{}
77

8+
// No longer considered legal in PHP 8.
89
class B implements\A {}
910

1011
echo "Done", PHP_EOL;
11-
--EXPECT--
12-
Done
12+
13+
?>
14+
--EXPECTF--
15+
Parse error: syntax error, unexpected 'implements\A' (T_NAME_QUALIFIED), expecting '{' in %s on line %d
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Cannot use "namespace" as namespace name, due to conflict with ns-relative names
3+
--FILE--
4+
<?php
5+
6+
namespace NAMEspace;
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot use 'NAMEspace' as namespace name in %s on line %d
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Cannot use "namespace\xyz" as namespace name, due to conflict with ns-relative names
3+
--FILE--
4+
<?php
5+
6+
namespace NAMEspace\xyz;
7+
8+
?>
9+
--EXPECTF--
10+
Parse error: syntax error, unexpected 'NAMEspace\xyz' (T_NAME_RELATIVE), expecting '{' in %s on line %d
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Reserved keywords in namespace name
3+
--FILE--
4+
<?php
5+
6+
namespace iter\fn {
7+
function test() {
8+
echo __FUNCTION__, "\n";
9+
}
10+
}
11+
12+
namespace fn {
13+
function test() {
14+
echo __FUNCTION__, "\n";
15+
}
16+
}
17+
18+
namespace self {
19+
function test() {
20+
echo __FUNCTION__, "\n";
21+
}
22+
}
23+
24+
namespace {
25+
use iter\fn;
26+
use function fn\test as test2;
27+
use function self\test as test3;
28+
fn\test();
29+
test2();
30+
test3();
31+
}
32+
33+
?>
34+
--EXPECT--
35+
iter\fn\test
36+
fn\test
37+
self\test
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Whitespace between namespace separators is no longer allowed
3+
--FILE--
4+
<?php
5+
6+
Foo \ Bar \ Baz;
7+
8+
?>
9+
--EXPECTF--
10+
Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR) in %s on line %d

Zend/tests/ns_096.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use Foo\Bar\{\Baz};
77

88
?>
99
--EXPECTF--
10-
Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR), expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) in %s on line 3
10+
Parse error: syntax error, unexpected '\Baz' (T_NAME_FULLY_QUALIFIED), expecting identifier (T_STRING) or namespaced name (T_NAME_QUALIFIED) or function (T_FUNCTION) or const (T_CONST) in %s on line %d

Zend/tests/ns_trailing_comma_error_01.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Group use declarations mustn't be empty
55
use Baz\{};
66
?>
77
--EXPECTF--
8-
Parse error: syntax error, unexpected '}', expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) in %s on line %d
8+
Parse error: syntax error, unexpected '}', expecting identifier (T_STRING) or namespaced name (T_NAME_QUALIFIED) or function (T_FUNCTION) or const (T_CONST) in %s on line %d

0 commit comments

Comments
 (0)