1--TEST-- 2Constant expressions with null coalescing operator ?? 3--FILE-- 4<?php 5 6const A = [1 => [[]]]; 7 8// should produce deprecation notices 9const D_1 = null ?? A[1]{'undefined'}['index'] ?? 1; 10const D_2 = null ?? A['undefined']{'index'} ?? 2; 11const D_3 = null ?? A[1]{0}{2} ?? 3; // 2 deprecation notices 12const D_4 = A[1]{0} ?? 4; 13 14const T_1 = null ?? A[1]['undefined']['index'] ?? 1; 15const T_2 = null ?? A['undefined']['index'] ?? 2; 16const T_3 = null ?? A[1][0][2] ?? 3; 17const T_4 = A[1][0][2] ?? 4; 18const T_5 = null ?? __LINE__; 19const T_6 = __LINE__ ?? "bar"; 20 21var_dump(D_1); 22var_dump(D_2); 23var_dump(D_3); 24var_dump(D_4); 25 26var_dump(T_1); 27var_dump(T_2); 28var_dump(T_3); 29var_dump(T_4); 30var_dump(T_5); 31var_dump(T_6); 32 33var_dump((function(){ static $var = null ?? A[1]['undefined']['index'] ?? 1; return $var; })()); 34var_dump((function(){ static $var = null ?? A['undefined']['index'] ?? 2; return $var; })()); 35var_dump((function(){ static $var = null ?? A[1][0][2] ?? 3; return $var; })()); 36var_dump((function(){ static $var = A[1][0][2] ?? 4; return $var; })()); 37 38var_dump((new class { public $var = null ?? A[1]['undefined']['index'] ?? 1; })->var); 39var_dump((new class { public $var = null ?? A['undefined']['index'] ?? 2; })->var); 40var_dump((new class { public $var = null ?? A[1][0][2] ?? 3; })->var); 41var_dump((new class { public $var = A[1][0][2] ?? 4; })->var); 42 43?> 44--EXPECTF-- 45 46Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d 47 48Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d 49 50Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d 51 52Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d 53 54Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d 55int(1) 56int(2) 57int(3) 58array(0) { 59} 60int(1) 61int(2) 62int(3) 63int(4) 64int(%d) 65int(%d) 66int(1) 67int(2) 68int(3) 69int(4) 70int(1) 71int(2) 72int(3) 73int(4) 74