diff options
author | Kalle Sommer Nielsen <kalle@php.net> | 2015-03-26 01:44:23 +0100 |
---|---|---|
committer | Kalle Sommer Nielsen <kalle@php.net> | 2015-03-26 01:44:23 +0100 |
commit | 67b907f05901e972649be17c511536e1fca5aa2e (patch) | |
tree | 317c076d22d91ae7f0e1e0fdc57973c003115150 | |
parent | 2cd07c377d5753637a7d12dffb24a9ced06bd242 (diff) | |
download | php-git-67b907f05901e972649be17c511536e1fca5aa2e.tar.gz |
Change the error message for colliding class/interface/trait names to be a little more clearer.
C:\> php -r "interface stdClass { }"
Error: Cannot declare interface stdClass, because the name is already in use in Command Line Code on line 1
-rw-r--r-- | Zend/tests/class_alias_002.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/class_alias_004.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/class_alias_010.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/class_alias_019.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/errmsg_026.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/inter_06.phpt | 2 | ||||
-rw-r--r-- | Zend/zend_builtin_functions.c | 2 | ||||
-rw-r--r-- | Zend/zend_compile.c | 8 | ||||
-rw-r--r-- | ext/opcache/tests/bug67215.phpt | 2 | ||||
-rw-r--r-- | ext/opcache/zend_accelerator_util_funcs.c | 2 |
10 files changed, 13 insertions, 13 deletions
diff --git a/Zend/tests/class_alias_002.phpt b/Zend/tests/class_alias_002.phpt index 9601cb25e8..7a6eb126a9 100644 --- a/Zend/tests/class_alias_002.phpt +++ b/Zend/tests/class_alias_002.phpt @@ -9,4 +9,4 @@ class_alias('foo', 'FOO'); ?> --EXPECTF-- -Warning: Cannot redeclare class FOO in %s on line %d +Warning: Cannot declare class FOO, because the name is already in use in %s on line %d diff --git a/Zend/tests/class_alias_004.phpt b/Zend/tests/class_alias_004.phpt index b9370dde0e..f99152c96a 100644 --- a/Zend/tests/class_alias_004.phpt +++ b/Zend/tests/class_alias_004.phpt @@ -12,4 +12,4 @@ class_alias('foo', 'test'); ?> --EXPECTF-- -Warning: Cannot redeclare class test in %s on line %d
\ No newline at end of file +Warning: Cannot declare class test, because the name is already in use in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/class_alias_010.phpt b/Zend/tests/class_alias_010.phpt index 0eff174351..3e52f5ffc5 100644 --- a/Zend/tests/class_alias_010.phpt +++ b/Zend/tests/class_alias_010.phpt @@ -11,4 +11,4 @@ class b { } ?> --EXPECTF-- -Warning: Cannot redeclare interface b in %s on line %d +Warning: Cannot declare interface b, because the name is already in use in %s on line %d diff --git a/Zend/tests/class_alias_019.phpt b/Zend/tests/class_alias_019.phpt index a0dd249d55..ace349e9bd 100644 --- a/Zend/tests/class_alias_019.phpt +++ b/Zend/tests/class_alias_019.phpt @@ -14,4 +14,4 @@ class_alias('\foo', 'foo'); ?> --EXPECTF-- -Warning: Cannot redeclare class foo in %s on line %d +Warning: Cannot declare class foo, because the name is already in use in %s on line %d diff --git a/Zend/tests/errmsg_026.phpt b/Zend/tests/errmsg_026.phpt index 1954122900..90fa87d4f1 100644 --- a/Zend/tests/errmsg_026.phpt +++ b/Zend/tests/errmsg_026.phpt @@ -9,4 +9,4 @@ class stdclass { echo "Done\n"; ?> --EXPECTF-- -Fatal error: Cannot redeclare class stdclass in %s on line %d +Fatal error: Cannot declare class stdclass, because the name is already in use in %s on line %d diff --git a/Zend/tests/inter_06.phpt b/Zend/tests/inter_06.phpt index 1987c24a8b..aba8ba4fb4 100644 --- a/Zend/tests/inter_06.phpt +++ b/Zend/tests/inter_06.phpt @@ -7,4 +7,4 @@ interface stdClass { } ?> --EXPECTF-- -Fatal error: Cannot redeclare class stdClass in %s on line %d +Fatal error: Cannot declare interface stdClass, because the name is already in use in %s on line %d diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index ecb9078db0..b378f93f09 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1536,7 +1536,7 @@ ZEND_FUNCTION(class_alias) if (zend_register_class_alias_ex(alias_name, alias_name_len, ce) == SUCCESS) { RETURN_TRUE; } else { - zend_error(E_WARNING, "Cannot redeclare %s %s", zend_get_object_type(ce), alias_name); + zend_error(E_WARNING, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), alias_name); RETURN_FALSE; } } else { diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f8ac526456..de8a89d51f 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1002,7 +1002,7 @@ ZEND_API zend_class_entry *do_bind_class(const zend_op_array* op_array, const ze * so we shut up about it. This allows the if (!defined('FOO')) { return; } * approach to work. */ - zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s %s", zend_get_object_type(ce), ce->name->val); + zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ce->name->val); } return NULL; } else { @@ -1036,13 +1036,13 @@ ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array * so we shut up about it. This allows the if (!defined('FOO')) { return; } * approach to work. */ - zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s %s", zend_get_object_type(Z_OBJCE_P(op2)), Z_STRVAL_P(op2)); + zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(Z_OBJCE_P(op2)), Z_STRVAL_P(op2)); } return NULL; } if (zend_hash_exists(class_table, Z_STR_P(op2))) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s %s", zend_get_object_type(ce), ce->name->val); + zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ce->name->val); } zend_do_inheritance(ce, parent_ce); @@ -1051,7 +1051,7 @@ ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array /* Register the derived class */ if (zend_hash_add_ptr(class_table, Z_STR_P(op2), ce) == NULL) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s %s", zend_get_object_type(ce), ce->name->val); + zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ce->name->val); } return ce; } diff --git a/ext/opcache/tests/bug67215.phpt b/ext/opcache/tests/bug67215.phpt index e9919d1001..24842b4e04 100644 --- a/ext/opcache/tests/bug67215.phpt +++ b/ext/opcache/tests/bug67215.phpt @@ -25,4 +25,4 @@ unlink($file_c); unlink($file_p); ?> --EXPECTF-- -Fatal error: Cannot redeclare class c in %sbug67215.c.php on line %d +Fatal error: Cannot declare class c, because the name is already in use in %sbug67215.c.php on line %d diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index bd373d90d3..9aefa51778 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -755,7 +755,7 @@ failure: CG(in_compilation) = 1; zend_set_compiled_filename(ce1->info.user.filename); CG(zend_lineno) = ce1->info.user.line_start; - zend_error(E_ERROR, "Cannot redeclare %s %s", zend_get_object_type(ce1), ce1->name->val); + zend_error(E_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce1), ce1->name->val); } #ifdef __SSE2__ |