1--TEST-- 2DCE 009: Foreach over empty array is a no-op 3--INI-- 4opcache.enable=1 5opcache.enable_cli=1 6opcache.optimization_level=-1 7opcache.opt_debug_level=0x20000 8opcache.preload= 9zend_test.observer.enabled=0 10--EXTENSIONS-- 11opcache 12--FILE-- 13<?php 14class Loop { 15 const VALUES = []; 16 public static function test() { 17 echo "Start\n"; 18 $y = []; 19 foreach ($y as $x) { 20 } 21 echo "Done\n"; 22 } 23 public static function test2() { 24 foreach (self::VALUES as $x) { 25 } 26 } 27 public static function test3() { 28 foreach ([] as $k => &$v) { 29 } 30 } 31} 32Loop::test(); 33Loop::test2(); 34Loop::test3(); 35?> 36--EXPECTF-- 37$_main: 38 ; (lines=7, args=0, vars=0, tmps=0) 39 ; (after optimizer) 40 ; %sdce_009.php:1-24 410000 INIT_STATIC_METHOD_CALL 0 string("Loop") string("test") 420001 DO_UCALL 430002 INIT_STATIC_METHOD_CALL 0 string("Loop") string("test2") 440003 DO_UCALL 450004 INIT_STATIC_METHOD_CALL 0 string("Loop") string("test3") 460005 DO_UCALL 470006 RETURN int(1) 48 49Loop::test: 50 ; (lines=3, args=0, vars=0, tmps=0) 51 ; (after optimizer) 52 ; %sdce_009.php:4-10 530000 ECHO string("Start 54") 550001 ECHO string("Done 56") 570002 RETURN null 58 59Loop::test2: 60 ; (lines=1, args=0, vars=0, tmps=0) 61 ; (after optimizer) 62 ; %sdce_009.php:11-14 630000 RETURN null 64 65Loop::test3: 66 ; (lines=3, args=0, vars=0, tmps=1) 67 ; (after optimizer) 68 ; %sdce_009.php:15-18 690000 V0 = FE_RESET_RW array(...) 0001 700001 FE_FREE V0 710002 RETURN null 72Start 73Done 74