017.phpt 743 B

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