Merge branch 'PHP-7.4'

This commit is contained in:
Nikita Popov 2019-09-11 17:05:07 +02:00
commit a09da43888
2 changed files with 17 additions and 6 deletions

View 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

View File

@ -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;
}