016.phpt 700 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. FFI 016: Structure constraints
  3. --EXTENSIONS--
  4. ffi
  5. --INI--
  6. ffi.enable=1
  7. --FILE--
  8. <?php
  9. try {
  10. FFI::cdef("struct X {void x();};");
  11. echo "ok\n";
  12. } catch (Throwable $e) {
  13. echo get_class($e) . ": " . $e->getMessage()."\n";
  14. }
  15. try {
  16. FFI::cdef("struct X {struct X x;};");
  17. echo "ok\n";
  18. } catch (Throwable $e) {
  19. echo get_class($e) . ": " . $e->getMessage()."\n";
  20. }
  21. try {
  22. FFI::cdef("struct X {struct X *ptr;};");
  23. echo "ok\n";
  24. } catch (Throwable $e) {
  25. echo get_class($e) . ": " . $e->getMessage()."\n";
  26. }
  27. ?>
  28. ok
  29. --EXPECT--
  30. FFI\ParserException: function type is not allowed at line 1
  31. FFI\ParserException: Struct/union can't contain an instance of itself at line 1
  32. ok
  33. ok