com php-src: self and parent are valid function and const names (nikic): Zend/tests/use_const/self_parent.phpt Zend/tests/use_
function/self_parent.phpt Zend/zend_compile.c

From: Date: Sun, 25 Aug 2013 13:08:26 +0000
Subject: com php-src: self and parent are valid function and const names (nikic): Zend/tests/use_const/self_parent.phpt Zend/tests/use_
function/self_parent.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74293@lists.php.net to get a copy of this message
Commit: 84c8aa36910f58033d475efa7f7c808c83539621 Author: Igor Wiedler <igor@wiedler.ch> Sun, 25 Aug 2013 15:08:26 +0200 Parents: bc473228c83a6163350e0362ff3b0722f73b068c Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=84c8aa36910f58033d475efa7f7c808c83539621 Log: self and parent are valid function and const names (nikic) Changed paths: A Zend/tests/use_const/self_parent.phpt A Zend/tests/use_function/self_parent.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/tests/use_const/self_parent.phpt b/Zend/tests/use_const/self_parent.phpt new file mode 100644 index 0000000..b71f2ec --- /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 0000000..f1e1fa8 --- /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 29d0760..b2367cbd 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);

« previous php.cvs (#74293) next »