Skip to content

Commit 84c8aa3

Browse files
committed
self and parent are valid function and const names (nikic)
1 parent bc47322 commit 84c8aa3

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Zend/tests/use_const/self_parent.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Allow self and parent in use const statement
3+
--FILE--
4+
<?php
5+
6+
namespace {
7+
use const self as foo;
8+
use const parent as bar;
9+
}
10+
11+
?>
12+
--EXPECT--
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Allow self and parent in use function statement
3+
--FILE--
4+
<?php
5+
6+
namespace {
7+
use function self as foo;
8+
use function parent as bar;
9+
}
10+
11+
?>
12+
--EXPECT--

Zend/zend_compile.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7181,13 +7181,6 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, const
71817181

71827182
lcname = zend_str_tolower_dup(Z_STRVAL_P(name), Z_STRLEN_P(name));
71837183

7184-
if (((Z_STRLEN_P(name) == sizeof("self")-1) &&
7185-
!memcmp(lcname, "self", sizeof("self")-1)) ||
7186-
((Z_STRLEN_P(name) == sizeof("parent")-1) &&
7187-
!memcmp(lcname, "parent", sizeof("parent")-1))) {
7188-
zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because '%s' is a special class name", Z_STRVAL_P(ns), Z_STRVAL_P(name), Z_STRVAL_P(name));
7189-
}
7190-
71917184
if (CG(current_namespace)) {
71927185
/* Prefix import name with current namespace name to avoid conflicts with classes */
71937186
char *c_ns_name = emalloc(Z_STRLEN_P(CG(current_namespace)) + 1 + Z_STRLEN_P(name) + 1);

0 commit comments

Comments
 (0)