1--TEST-- 2FFI 027: Incomplete and variable length arrays 3--EXTENSIONS-- 4ffi 5--INI-- 6ffi.enable=1 7--FILE-- 8<?php 9$ffi = FFI::cdef(); 10 11try { 12 $p = $ffi->new("int[*]"); 13 echo "ok\n"; 14} catch (Throwable $e) { 15 echo get_class($e) . ": " . $e->getMessage()."\n"; 16} 17try { 18 FFI::cdef("static int (*foo)[*];"); 19 echo "ok\n"; 20} catch (Throwable $e) { 21 echo get_class($e) . ": " . $e->getMessage()."\n"; 22} 23try { 24 FFI::cdef("typedef int foo[*];"); 25 echo "ok\n"; 26} catch (Throwable $e) { 27 echo get_class($e) . ": " . $e->getMessage()."\n"; 28} 29try { 30 FFI::cdef("static void foo(int[*][*]);"); 31 echo "ok\n"; 32} catch (Throwable $e) { 33 echo get_class($e) . ": " . $e->getMessage()."\n"; 34} 35try { 36 var_dump(FFI::sizeof($ffi->new("int[0]"))); 37} catch (Throwable $e) { 38 echo get_class($e) . ": " . $e->getMessage()."\n"; 39} 40try { 41 var_dump(FFI::sizeof($ffi->new("int[]"))); 42} catch (Throwable $e) { 43 echo get_class($e) . ": " . $e->getMessage()."\n"; 44} 45try { 46 var_dump(FFI::sizeof($ffi->cast("int[]", $ffi->new("int[2]")))); 47} catch (Throwable $e) { 48 echo get_class($e) . ": " . $e->getMessage()."\n"; 49} 50try { 51 FFI::cdef("struct _x {int a; int b[];};"); 52 echo "ok\n"; 53} catch (Throwable $e) { 54 echo get_class($e) . ": " . $e->getMessage()."\n"; 55} 56try { 57 $f = FFI::cdef("typedef int(*foo)[];"); 58 echo "ok\n"; 59} catch (Throwable $e) { 60 echo get_class($e) . ": " . $e->getMessage()."\n"; 61} 62try { 63 $f = FFI::cdef("typedef int foo[][2];"); 64 echo "ok\n"; 65} catch (Throwable $e) { 66 echo get_class($e) . ": " . $e->getMessage()."\n"; 67} 68try { 69 $f = FFI::cdef("typedef int foo[];"); 70 echo "ok\n"; 71} catch (Throwable $e) { 72 echo get_class($e) . ": " . $e->getMessage()."\n"; 73} 74try { 75 $f = FFI::cdef("static int foo(int[]);"); 76 echo "ok\n"; 77} catch (Throwable $e) { 78 echo get_class($e) . ": " . $e->getMessage()."\n"; 79} 80?> 81--EXPECT-- 82FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1 83FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1 84FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1 85ok 86FFI\Exception: Cannot instantiate FFI\CData of zero size 87FFI\ParserException: "[]" is not allowed at line 1 88FFI\ParserException: "[]" is not allowed at line 1 89ok 90ok 91ok 92ok 93ok 94