1
0
mirror of https://github.com/php/php-src.git synced 2026-03-31 12:42:29 +02:00
Files
archived-php-src/ext/ffi/tests/045.phpt
Dmitry Stogov 0128f6eb84 Merge branch 'PHP-7.4'
* PHP-7.4:
  NEWS entry, test and minor cleanup for FFI::isNull()
  add FFI::isNull() to check whether a FFI\CData is a null pointer
2019-09-10 11:34:08 +03:00

28 lines
614 B
PHP

--TEST--
FFI 045: FFI::isNull()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--INI--
ffi.enable=1
--FILE--
<?php
var_dump(FFI::isNull(FFI::new("int*")));
$i = FFI::new("int");
var_dump(FFI::isNull(FFI::addr($i)));
try {
var_dump(FFI::isNull(null));
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
var_dump(FFI::isNull(FFI::new("int[0]")));
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECTF--
bool(true)
bool(false)
TypeError: FFI::isNull() expects parameter 1 to be FFI\CData, null given
FFI\Exception: FFI\Cdata is not a pointer