Skip to content

Commit 1ed2066

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 07873fa + 41af1e6 commit 1ed2066

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Use of self::class inside a constant in an unknown scope
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
public function foobar() {
8+
eval("
9+
const FOO = self::class;
10+
var_dump(FOO);
11+
");
12+
}
13+
}
14+
(new Test)->foobar();
15+
16+
// This should error, but doesn't
17+
const BAR = self::class;
18+
var_dump(BAR);
19+
20+
?>
21+
--EXPECT--
22+
string(4) "Test"
23+
string(0) ""

Zend/zend_compile.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ static zend_bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_a
14991499

15001500
switch (fetch_type) {
15011501
case ZEND_FETCH_CLASS_SELF:
1502-
if (constant || (CG(active_class_entry) && zend_is_scope_known())) {
1502+
if (CG(active_class_entry) && zend_is_scope_known()) {
15031503
ZVAL_STR_COPY(zv, CG(active_class_entry)->name);
15041504
} else {
15051505
ZVAL_NULL(zv);
@@ -8086,9 +8086,7 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */
80868086
zend_ast *ast = *ast_ptr;
80878087

80888088
/* Other cases already resolved by constant folding */
8089-
ZEND_ASSERT(ast->attr == T_CLASS_C &&
8090-
CG(active_class_entry) &&
8091-
(CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) != 0);
8089+
ZEND_ASSERT(ast->attr == T_CLASS_C);
80928090

80938091
zend_ast_destroy(ast);
80948092
*ast_ptr = zend_ast_create(ZEND_AST_CONSTANT_CLASS);

0 commit comments

Comments
 (0)