045.phpt 621 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. FFI 045: FFI::isNull()
  3. --EXTENSIONS--
  4. ffi
  5. --INI--
  6. ffi.enable=1
  7. --FILE--
  8. <?php
  9. var_dump(FFI::isNull(FFI::new("int*")));
  10. $i = FFI::new("int");
  11. var_dump(FFI::isNull(FFI::addr($i)));
  12. try {
  13. var_dump(FFI::isNull(null));
  14. } catch (Throwable $e) {
  15. echo get_class($e) . ": " . $e->getMessage()."\n";
  16. }
  17. try {
  18. var_dump(FFI::isNull(FFI::new("int[0]")));
  19. } catch (Throwable $e) {
  20. echo get_class($e) . ": " . $e->getMessage()."\n";
  21. }
  22. ?>
  23. --EXPECT--
  24. bool(true)
  25. bool(false)
  26. TypeError: FFI::isNull(): Argument #1 ($ptr) must be of type FFI\CData, null given
  27. FFI\Exception: Cannot instantiate FFI\CData of zero size