cvs: ZendEngine2 / zend_compile.c /tests ns_033.phpt
| From: | Dmitry Stogov | Date: | Thu, 26 Jul 2007 08:57:52 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c /tests ns_033.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-5929@lists.php.net to get a copy of this message | ||
dmitry Thu Jul 26 08:57:52 2007 UTC
Added files:
/ZendEngine2/tests ns_033.phpt
Modified files:
/ZendEngine2 zend_compile.c
Log:
Added warning for useless import statement
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.757&r2=1.758&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.757 ZendEngine2/zend_compile.c:1.758
--- ZendEngine2/zend_compile.c:1.757 Thu Jul 26 08:32:51 2007
+++ ZendEngine2/zend_compile.c Thu Jul 26 08:57:52 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.757 2007/07/26 08:32:51 dmitry Exp $ */
+/* $Id: zend_compile.c,v 1.758 2007/07/26 08:57:52 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -4910,6 +4910,7 @@
unsigned int lcname_len;
zstr lcname;
zval *name, *ns, tmp;
+ zend_bool warn = 0;
if (!CG(current_import)) {
CG(current_import) = emalloc(sizeof(HashTable));
@@ -4929,6 +4930,7 @@
} else {
*name = *ns;
zval_copy_ctor(name);
+ warn = 1;
}
} else {
char *p = zend_memrchr(Z_STRVAL_P(ns), ':', Z_STRLEN_P(ns));
@@ -4937,6 +4939,7 @@
} else {
*name = *ns;
zval_copy_ctor(name);
+ warn = 1;
}
}
}
@@ -4955,7 +4958,10 @@
}
if (zend_u_hash_add(CG(current_import), Z_TYPE_P(name), lcname, lcname_len+1, &ns,
sizeof(zval*), NULL) != SUCCESS) {
- zend_error(E_COMPILE_ERROR, "Cannot reuse import name");
+ zend_error(E_COMPILE_ERROR, "Cannot reuse import name");
+ }
+ if (warn) {
+ zend_error(E_WARNING, "The import statement with non-compound name '%R' has no
effect", Z_TYPE_P(name), Z_UNIVAL_P(name));
}
efree(lcname.v);
zval_dtor(name);
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_033.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_033.phpt
+++ ZendEngine2/tests/ns_033.phpt
--TEST--
033: Import statement with non-compound name
--FILE--
<?php
import A;
--EXPECTF--
Warning: The import statement with non-compound name 'A' has no effect in %sns_033.php on
line 2