1--TEST-- 2JIT COUNT: 001 3--INI-- 4opcache.enable=1 5opcache.enable_cli=1 6opcache.file_update_protection=0 7;opcache.jit_debug=1 8--EXTENSIONS-- 9opcache 10--FILE-- 11<?php 12class ThrowsInDestructor { 13 public function __destruct() { 14 throw new RuntimeException("In destructor"); 15 } 16} 17class C { 18 public static function create_array(int $i): array { 19 return array_fill(0, $i, new stdClass()); 20 } 21 22 public static function foo() { 23 $x = [self::create_array(5)]; 24 echo count(self::create_array(0)), "\n"; 25 echo count(self::create_array(1)), "\n"; 26 echo count($x[0]), "\n"; 27 $a = []; 28 for ($i = 0; $i < 4; $i++) { 29 $a[] = $i; 30 echo count($a) . "\n"; 31 } 32 } 33 public static function count_ref(array &$ref): int { 34 return count($ref); 35 } 36 37 public static function count_throws(): int { 38 $result = count([new ThrowsInDestructor()]); 39 echo "Unreachable\n"; 40 return $result; 41 } 42} 43C::foo(); 44$x = ['x', 'y', 'z', 'a', new stdClass()]; 45echo C::count_ref($x), "\n"; 46for ($i = 0; $i < 5; $i++) { 47 try { 48 echo C::count_throws(), "\n"; 49 } catch (RuntimeException $e) { 50 printf("Caught %s\n", $e->getMessage()); 51 } 52} 53 54?> 55--EXPECT-- 560 571 585 591 602 613 624 635 64Caught In destructor 65Caught In destructor 66Caught In destructor 67Caught In destructor 68Caught In destructor