1--TEST-- 2FFI 008: Array iteration 3--EXTENSIONS-- 4ffi 5--INI-- 6ffi.enable=1 7--FILE-- 8<?php 9$ffi = FFI::cdef(); 10 11$a = $ffi->new("int[3]"); 12$a[1] = 10; 13$a[2] = 20; 14var_dump(count($a)); 15foreach ($a as $key => $val) { 16 echo "$key => $val\n"; 17} 18 19$a = $ffi->new("struct {int x,y;}"); 20try { 21 var_dump(count($a)); 22} catch (Throwable $e) { 23 echo get_class($e) . ": " . $e->getMessage()."\n"; 24} 25 26try { 27 foreach ($a as $key => $val) { 28 echo "$key => $val\n"; 29 } 30} catch (Throwable $e) { 31 echo get_class($e) . ": " . $e->getMessage()."\n"; 32} 33?> 34--EXPECT-- 35int(3) 360 => 0 371 => 10 382 => 20 39FFI\Exception: Attempt to count() on non C array 40FFI\Exception: Attempt to iterate on non C array 41