File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,16 @@ static inline zend_bool may_have_side_effects(
242
242
}
243
243
return 0 ;
244
244
case ZEND_BIND_STATIC :
245
+ if (op_array -> static_variables
246
+ && (opline -> extended_value & ZEND_BIND_REF ) != 0 ) {
247
+ zval * value =
248
+ (zval * )((char * )op_array -> static_variables -> arData +
249
+ (opline -> extended_value & ~ZEND_BIND_REF ));
250
+ if (Z_TYPE_P (value ) == IS_CONSTANT_AST ) {
251
+ /* AST may contain undefined constants */
252
+ return 1 ;
253
+ }
254
+ }
245
255
return 0 ;
246
256
default :
247
257
/* For everything we didn't handle, assume a side-effect */
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Keep BIND_STATIC when initial value refer to unresolved constants
3
+ --INI--
4
+ opcache.enable=1
5
+ opcache.enable_cli=1
6
+ opcache.optimization_level=-1
7
+ --SKIPIF--
8
+ <?php require_once ('skipif.inc ' ); ?>
9
+ --FILE--
10
+ <?php
11
+ function foo () {
12
+ static $ a = UNDEFINED_CONST ;
13
+ }
14
+ foo ();
15
+ ?>
16
+ OK
17
+ --EXPECTF--
18
+ Warning: Use of undefined constant UNDEFINED_CONST - assumed 'UNDEFINED_CONST' (this will throw an Error in a future version of PHP) in %s on line %d
19
+ OK
You can’t perform that action at this time.
0 commit comments