Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Zend/tests/ast/gh21072.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
(unset) cast must not be allowed in constant expressions
--FILE--
<?php
try {
class C {
public $p = (unset) C::class;
}
new C;
} catch (Error $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
Fatal error: The (unset) cast is no longer supported in %s on line %d
3 changes: 3 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -12565,6 +12565,9 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
return;
case ZEND_AST_CAST:
zend_eval_const_expr(&ast->child[0]);
if (ast->attr == IS_NULL) {
zend_error_noreturn(E_COMPILE_ERROR, "The (unset) cast is no longer supported");
}
if (ast->child[0]->kind == ZEND_AST_ZVAL
&& zend_try_ct_eval_cast(&result, ast->attr, zend_ast_get_zval(ast->child[0]))) {
break;
Expand Down
Loading