com php-src: Change the error message for colliding class/interface/trait names to be a little more clearer.: Zend/tests/class_alias_ 002.phpt
Zend/tests/class_alias_004.phpt Zend/tests/class_alias_010.phpt Zend/tests/cla ss_alias_019.phpt Zend/tests/errmsg_026 .phpt Zend/tests/inter_06.phpt
Zend/zend_builti n_functions.c Zend/zend_compile.c ext/opcache/tests /bug67215.phpt ext/opcache/zend_accelerator_u til_funcs.c
| From: | Kalle Sommer Nielsen | Date: | Thu, 26 Mar 2015 00:44:23 +0000 |
| Subject: | com php-src: Change the error message for colliding class/interface/trait names to be a little more clearer.: Zend/tests/class_alias_ 002.phpt Zend/tests/class_alias_004.phpt Zend/tests/class_alias_010.phpt Zend/tests/cla ss_alias_019.phpt Zend/tests/errmsg_026 .phpt Zend/tests/inter_06.phpt Zend/zend_builti n_functions.c Zend/zend_compile.c ext/opcache/tests /bug67215.phpt ext/opcache/zend_accelerator_u til_funcs.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85881@lists.php.net to get a copy of this message | ||
Commit: 67b907f05901e972649be17c511536e1fca5aa2e
Author: Kalle Sommer Nielsen <kalle@php.net> Thu, 26 Mar 2015 01:44:23 +0100
Parents: 2cd07c377d5753637a7d12dffb24a9ced06bd242
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=67b907f05901e972649be17c511536e1fca5aa2e
Log:
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
Changed paths:
M Zend/tests/class_alias_002.phpt
M Zend/tests/class_alias_004.phpt
M Zend/tests/class_alias_010.phpt
M Zend/tests/class_alias_019.phpt
M Zend/tests/errmsg_026.phpt
M Zend/tests/inter_06.phpt
M Zend/zend_builtin_functions.c
M Zend/zend_compile.c
M ext/opcache/tests/bug67215.phpt
M ext/opcache/zend_accelerator_util_funcs.c
Diff:
diff --git a/Zend/tests/class_alias_002.phpt b/Zend/tests/class_alias_002.phpt
index 9601cb2..7a6eb12 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 b9370dd..f99152c 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 0eff174..3e52f5f 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 a0dd249..ace349e 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 1954122..90fa87d 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 1987c24..aba8ba4 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 ecb9078..b378f93 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 f8ac526..de8a89d 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 e9919d1..24842b4 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 bd373d9..9aefa51 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__