013.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. FFI 013: Declaration priorities and constrains
  3. --EXTENSIONS--
  4. ffi
  5. --INI--
  6. ffi.enable=1
  7. --FILE--
  8. <?php
  9. $a = FFI::new("int[1][2][3]");
  10. var_dump(count($a));
  11. var_dump(count($a[0]));
  12. var_dump(count($a[0][0]));
  13. try {
  14. var_dump(FFI::new("void"));
  15. } catch (Throwable $e) {
  16. echo get_class($e) . ": " . $e->getMessage()."\n";
  17. }
  18. try {
  19. var_dump(FFI::new("void[1]"));
  20. } catch (Throwable $e) {
  21. echo get_class($e) . ": " . $e->getMessage()."\n";
  22. }
  23. try {
  24. FFI::cdef("static int foo(int)[5];");
  25. echo "ok\n";
  26. } catch (Throwable $e) {
  27. echo get_class($e) . ": " . $e->getMessage()."\n";
  28. }
  29. try {
  30. FFI::cdef("static int foo[5](int);");
  31. echo "ok\n";
  32. } catch (Throwable $e) {
  33. echo get_class($e) . ": " . $e->getMessage()."\n";
  34. }
  35. try {
  36. FFI::cdef("static int foo(int)(int);");
  37. echo "ok\n";
  38. } catch (Throwable $e) {
  39. echo get_class($e) . ": " . $e->getMessage()."\n";
  40. }
  41. try {
  42. FFI::cdef("typedef int foo[2][];");
  43. echo "ok\n";
  44. } catch (Throwable $e) {
  45. echo get_class($e) . ": " . $e->getMessage()."\n";
  46. }
  47. try {
  48. FFI::cdef("typedef int foo[][2];");
  49. echo "ok\n";
  50. } catch (Throwable $e) {
  51. echo get_class($e) . ": " . $e->getMessage()."\n";
  52. }
  53. ?>
  54. --EXPECT--
  55. int(1)
  56. int(2)
  57. int(3)
  58. FFI\ParserException: void type is not allowed at line 1
  59. FFI\ParserException: void type is not allowed at line 1
  60. FFI\ParserException: Function returning array is not allowed at line 1
  61. FFI\ParserException: Array of functions is not allowed at line 1
  62. FFI\ParserException: Function returning function is not allowed at line 1
  63. FFI\ParserException: Only the leftmost array can be undimensioned at line 1
  64. ok