We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 22c618e commit ec69fbcCopy full SHA for ec69fbc
Zend/tests/ast/gh21072.phpt
@@ -0,0 +1,15 @@
1
+--TEST--
2
+(unset) cast must not be allowed in constant property initializer
3
+--FILE--
4
+<?php
5
+try {
6
+ class C {
7
+ public $p = (unset) C::class;
8
+ }
9
+ new C;
10
+} catch (Error $e) {
11
+ echo $e->getMessage();
12
+}
13
+?>
14
+--EXPECT--
15
+Invalid cast in constant expression
Zend/zend_ast.c
@@ -814,6 +814,11 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
814
case IS_OBJECT:
815
zend_cast_zval_to_object(result, &op1, IS_VAR);
816
break;
817
+ case IS_NULL:
818
+ zend_throw_error(NULL,
819
+ "Invalid cast in constant expression");
820
+ ret = FAILURE;
821
+ break;
822
EMPTY_SWITCH_DEFAULT_CASE();
823
}
824
zval_ptr_dtor_nogc(&op1);
0 commit comments