Merge branch 'PHP-7.2' into PHP-7.3

This commit is contained in:
Nikita Popov 2019-01-04 09:53:30 +01:00
commit 1ed20669c5
2 changed files with 25 additions and 4 deletions

View File

@ -0,0 +1,23 @@
--TEST--
Use of self::class inside a constant in an unknown scope
--FILE--
<?php
class Test {
public function foobar() {
eval("
const FOO = self::class;
var_dump(FOO);
");
}
}
(new Test)->foobar();
// This should error, but doesn't
const BAR = self::class;
var_dump(BAR);
?>
--EXPECT--
string(4) "Test"
string(0) ""

View File

@ -1499,7 +1499,7 @@ static zend_bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_a
switch (fetch_type) {
case ZEND_FETCH_CLASS_SELF:
if (constant || (CG(active_class_entry) && zend_is_scope_known())) {
if (CG(active_class_entry) && zend_is_scope_known()) {
ZVAL_STR_COPY(zv, CG(active_class_entry)->name);
} else {
ZVAL_NULL(zv);
@ -8086,9 +8086,7 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */
zend_ast *ast = *ast_ptr;
/* Other cases already resolved by constant folding */
ZEND_ASSERT(ast->attr == T_CLASS_C &&
CG(active_class_entry) &&
(CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) != 0);
ZEND_ASSERT(ast->attr == T_CLASS_C);
zend_ast_destroy(ast);
*ast_ptr = zend_ast_create(ZEND_AST_CONSTANT_CLASS);