diff options
| author | Igor Wiedler <igor@wiedler.ch> | 2013-08-25 15:08:26 +0200 |
|---|---|---|
| committer | Igor Wiedler <igor@wiedler.ch> | 2013-08-25 15:08:26 +0200 |
| commit | 84c8aa36910f58033d475efa7f7c808c83539621 (patch) | |
| tree | 130f64d2935ca67bfb95fa410545cd788818eea7 | |
| parent | bc473228c83a6163350e0362ff3b0722f73b068c (diff) | |
| download | php-git-84c8aa36910f58033d475efa7f7c808c83539621.tar.gz | |
self and parent are valid function and const names (nikic)
| -rw-r--r-- | Zend/tests/use_const/self_parent.phpt | 12 | ||||
| -rw-r--r-- | Zend/tests/use_function/self_parent.phpt | 12 | ||||
| -rw-r--r-- | Zend/zend_compile.c | 7 |
3 files changed, 24 insertions, 7 deletions
diff --git a/Zend/tests/use_const/self_parent.phpt b/Zend/tests/use_const/self_parent.phpt new file mode 100644 index 0000000000..b71f2ecc81 --- /dev/null +++ b/Zend/tests/use_const/self_parent.phpt @@ -0,0 +1,12 @@ +--TEST-- +Allow self and parent in use const statement +--FILE-- +<?php + +namespace { + use const self as foo; + use const parent as bar; +} + +?> +--EXPECT-- diff --git a/Zend/tests/use_function/self_parent.phpt b/Zend/tests/use_function/self_parent.phpt new file mode 100644 index 0000000000..f1e1fa84f1 --- /dev/null +++ b/Zend/tests/use_function/self_parent.phpt @@ -0,0 +1,12 @@ +--TEST-- +Allow self and parent in use function statement +--FILE-- +<?php + +namespace { + use function self as foo; + use function parent as bar; +} + +?> +--EXPECT-- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 29d0760f60..b2367cbd24 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7181,13 +7181,6 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, const lcname = zend_str_tolower_dup(Z_STRVAL_P(name), Z_STRLEN_P(name)); - if (((Z_STRLEN_P(name) == sizeof("self")-1) && - !memcmp(lcname, "self", sizeof("self")-1)) || - ((Z_STRLEN_P(name) == sizeof("parent")-1) && - !memcmp(lcname, "parent", sizeof("parent")-1))) { - 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)); - } - if (CG(current_namespace)) { /* Prefix import name with current namespace name to avoid conflicts with classes */ char *c_ns_name = emalloc(Z_STRLEN_P(CG(current_namespace)) + 1 + Z_STRLEN_P(name) + 1); |
