From: Dmitry Stogov Date: Mon, 12 Nov 2007 17:53:36 +0000 (+0000) Subject: better error messages X-Git-Tag: RELEASE_2_0_0a1~1386 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6963efdda2709785b4e8f4cff907c3e2c5511b0;p=php better error messages --- diff --git a/Zend/tests/bug42859.phpt b/Zend/tests/bug42859.phpt index 475c583465..9998e1b602 100755 --- a/Zend/tests/bug42859.phpt +++ b/Zend/tests/bug42859.phpt @@ -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 diff --git a/Zend/tests/ns_029.phpt b/Zend/tests/ns_029.phpt index 1b82b052e5..d719e9e7cf 100755 --- a/Zend/tests/ns_029.phpt +++ b/Zend/tests/ns_029.phpt @@ -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 diff --git a/Zend/tests/ns_030.phpt b/Zend/tests/ns_030.phpt index 83a86b1fd1..8aa3223f7e 100755 --- a/Zend/tests/ns_030.phpt +++ b/Zend/tests/ns_030.phpt @@ -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 diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 588159aea4..f674cd4b25 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3241,7 +3241,7 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod if (tmp_len != lcname_len || memcmp(tmp.v, lcname.v, UG(unicode)?UBYTES(lcname_len):lcname_len)) { - zend_error(E_COMPILE_ERROR, "Class name '%R' conflicts with import name", Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant)); + zend_error(E_COMPILE_ERROR, "Cannot declare class %R because the name is already in use", Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant)); } efree(tmp.v); } @@ -5197,7 +5197,7 @@ void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */ ZEND_U_EQUAL(Z_TYPE_P(name), lcname, lcname_len, "self", sizeof("self")-1)) || ((lcname_len == sizeof("parent")-1) && ZEND_U_EQUAL(Z_TYPE_P(name), lcname, lcname_len, "parent", sizeof("parent")-1))) { - zend_error(E_COMPILE_ERROR, "Cannot use '%R' as import name", Z_TYPE_P(name), Z_UNIVAL_P(name)); + zend_error(E_COMPILE_ERROR, "Cannot use %R as %R because '%R' is a special class name", Z_TYPE_P(ns), Z_UNIVAL_P(ns), Z_TYPE_P(name), Z_UNIVAL_P(name), Z_TYPE_P(name), Z_UNIVAL_P(name)); } if (CG(current_namespace)) { @@ -5222,7 +5222,7 @@ void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */ if (tmp_len != ns_name_len + 2 + lcname_len || memcmp(tmp.v, ns_name.v, UG(unicode)?UBYTES(tmp_len):tmp_len)) { - zend_error(E_COMPILE_ERROR, "Import name '%R' conflicts with defined class", Z_TYPE_P(name), Z_STRVAL_P(name)); + zend_error(E_COMPILE_ERROR, "Cannot use %R as %R because the name is already in use", Z_TYPE_P(ns), Z_UNIVAL_P(ns), Z_TYPE_P(name), Z_UNIVAL_P(name)); } efree(tmp.v); } @@ -5233,13 +5233,13 @@ void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */ if (tmp_len != lcname_len || memcmp(tmp.v, lcname.v, UG(unicode)?UBYTES(tmp_len):tmp_len)) { - zend_error(E_COMPILE_ERROR, "Import name '%R' conflicts with defined class", Z_TYPE_P(name), Z_UNIVAL_P(name)); + zend_error(E_COMPILE_ERROR, "Cannot use %R as %R because the name is already in use", Z_TYPE_P(ns), Z_UNIVAL_P(ns), Z_TYPE_P(name), Z_UNIVAL_P(name)); } efree(tmp.v); } 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 use %R as %R because the name is already in use", Z_TYPE_P(ns), Z_UNIVAL_P(ns), Z_TYPE_P(name), Z_UNIVAL_P(name)); } if (warn) { zend_error(E_WARNING, "The use statement with non-compound name '%R' has no effect", Z_TYPE_P(name), Z_UNIVAL_P(name));