mirror of
https://github.com/php/php-src.git
synced 2024-12-18 22:41:20 +08:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
a09da43888
14
Zend/tests/declare_already_in_use.phpt
Normal file
14
Zend/tests/declare_already_in_use.phpt
Normal file
@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
Cannot declare class, because the name is already in use
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function test() {
|
||||
class A {}
|
||||
}
|
||||
test();
|
||||
test();
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot declare class A, because the name is already in use in %s on line %d
|
@ -1057,12 +1057,9 @@ ZEND_API int do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */
|
||||
zv = zend_hash_find_ex(EG(class_table), Z_STR_P(rtd_key), 1);
|
||||
|
||||
if (UNEXPECTED(!zv)) {
|
||||
/* If we're in compile time, in practice, it's quite possible
|
||||
* that we'll never reach this class declaration at runtime,
|
||||
* so we shut up about it. This allows the if (!defined('FOO')) { return; }
|
||||
* approach to work.
|
||||
*/
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s, because the name is already in use", Z_STRVAL_P(lcname));
|
||||
ce = zend_hash_find_ptr(EG(class_table), Z_STR_P(lcname));
|
||||
ZEND_ASSERT(ce && "Class with lcname should be registered");
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(ce->name));
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user