]> granicus.if.org Git - php/commitdiff
better error messages
authorDmitry Stogov <dmitry@php.net>
Mon, 12 Nov 2007 17:52:15 +0000 (17:52 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 12 Nov 2007 17:52:15 +0000 (17:52 +0000)
Zend/tests/bug42859.phpt
Zend/tests/ns_029.phpt
Zend/tests/ns_030.phpt
Zend/zend_compile.c

index 475c58346580e81dc52ca1a238b679ad423c6d88..9998e1b602441bf6c86fb11bf7aa6721f3144e7a 100755 (executable)
@@ -9,4 +9,4 @@ use Blah::Exception;
 use Blah::Ex;
 ?>
 --EXPECTF--
-Fatal error: Import name 'Ex' conflicts with defined class in %sbug42859.php on line 6
\ No newline at end of file
+Fatal error: Cannot use Blah::Ex as Ex because the name is already in use in %sbug42859.php on line 6
index 1b82b052e5f75f86d5e427e239854052ab481ef2..d719e9e7cfb359dc72af31c28e34365456acd83c 100755 (executable)
@@ -9,4 +9,4 @@ class Foo {
 
 new Foo();
 --EXPECTF--
-Fatal error: Class name 'Foo' conflicts with import name in %sns_029.php on line 4
+Fatal error: Cannot declare class Foo because the name is already in use in %sns_029.php on line 4
index 83a86b1fd1d875ce667c6424a3a649180bea416c..8aa3223f7e6e6aaa7a63d418f0015ad252e5cf3a 100755 (executable)
@@ -9,4 +9,4 @@ use A::B as Foo;
 
 new Foo();
 --EXPECTF--
-Fatal error: Import name 'Foo' conflicts with defined class in %sns_030.php on line 5
+Fatal error: Cannot use A::B as Foo because the name is already in use in %sns_030.php on line 5
index 15ed33ab054c91ab00eddf0626f10a117c5b8862..a16ec289cb7d152ee348283c1a68b3ed7399b993 100644 (file)
@@ -3019,7 +3019,7 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod
 
                if (Z_STRLEN_PP(ns_name) != Z_STRLEN(class_name->u.constant) ||
                        memcmp(tmp, lcname, Z_STRLEN(class_name->u.constant))) {
-                       zend_error(E_COMPILE_ERROR, "Class name '%s' conflicts with import name", Z_STRVAL(class_name->u.constant));
+                       zend_error(E_COMPILE_ERROR, "Cannot declare class %s because the name is already in use", Z_STRVAL(class_name->u.constant));
                }
                efree(tmp);
        }
@@ -4660,7 +4660,7 @@ void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
           !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 import name", Z_STRVAL_P(name));
+               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)) {
@@ -4676,7 +4676,7 @@ void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
 
                        if (Z_STRLEN_P(ns) != Z_STRLEN_P(CG(current_namespace)) + 2 + Z_STRLEN_P(name) ||
                                memcmp(tmp, ns_name, Z_STRLEN_P(ns))) {
-                               zend_error(E_COMPILE_ERROR, "Import name '%s' conflicts with defined class", Z_STRVAL_P(name));
+                               zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL_P(ns), Z_STRVAL_P(name));
                        }
                        efree(tmp);
                }
@@ -4686,13 +4686,13 @@ void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
 
                if (Z_STRLEN_P(ns) != Z_STRLEN_P(name) ||
                        memcmp(tmp, lcname, Z_STRLEN_P(ns))) {
-                       zend_error(E_COMPILE_ERROR, "Import name '%s' conflicts with defined class", Z_STRVAL_P(name));
+                       zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL_P(ns), Z_STRVAL_P(name));
                }
                efree(tmp);
        }
 
        if (zend_hash_add(CG(current_import), lcname, Z_STRLEN_P(name)+1, &ns, sizeof(zval*), NULL) != SUCCESS) {
-               zend_error(E_COMPILE_ERROR, "Cannot reuse import name");
+               zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL_P(ns), Z_STRVAL_P(name));
        }
        if (warn) {
                zend_error(E_WARNING, "The use statement with non-compound name '%s' has no effect", Z_STRVAL_P(name));