mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.3'
This commit is contained in:
commit
03094c7af3
2 changed files with 25 additions and 4 deletions
23
Zend/tests/self_class_const_in_unknown_scope.phpt
Normal file
23
Zend/tests/self_class_const_in_unknown_scope.phpt
Normal 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) ""
|
|
@ -1388,7 +1388,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);
|
||||
|
@ -8002,9 +8002,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue