xref: /PHP-7.4/ext/ffi/tests/045.phpt (revision 54ecf57f)
1--TEST--
2FFI 045: FFI::isNull()
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9var_dump(FFI::isNull(FFI::new("int*")));
10$i = FFI::new("int");
11var_dump(FFI::isNull(FFI::addr($i)));
12try {
13	var_dump(FFI::isNull(null));
14} catch (Throwable $e) {
15	echo get_class($e) . ": " . $e->getMessage()."\n";
16}
17try {
18	var_dump(FFI::isNull(FFI::new("int[0]")));
19} catch (Throwable $e) {
20	echo get_class($e) . ": " . $e->getMessage()."\n";
21}
22?>
23--EXPECTF--
24bool(true)
25bool(false)
26
27Warning: FFI::isNull() expects parameter 1 to be FFI\CData, null given in %s045.php on line %d
28NULL
29FFI\Exception: Cannot instantiate FFI\CData of zero size
30