xref: /PHP-7.4/ext/ffi/tests/033.phpt (revision e089d506)
1--TEST--
2FFI 033: FFI::new(), FFI::free(), FFI::type(), FFI::typeof(), FFI::arrayType()
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9$p1 = FFI::new("uint8_t[2]");
10$p2 = FFI::new("uint16_t[2]", true, true);
11var_dump($p1, $p2);
12
13$t1 = FFI::typeof($p1);
14var_dump($t1);
15
16$p4 = FFI::new($t1);
17var_dump($p4);
18
19$t2 = FFI::type("uint16_t[2]");
20var_dump($t2);
21$p4 = FFI::new($t2);
22var_dump($p4);
23
24$t2 = FFI::type("uint32_t");
25var_dump($t2);
26$t3 = FFI::arrayType($t2, [2, 2]);
27var_dump($t3);
28?>
29--EXPECTF--
30object(FFI\CData:uint8_t[2])#%d (2) {
31  [0]=>
32  int(0)
33  [1]=>
34  int(0)
35}
36object(FFI\CData:uint16_t[2])#%d (2) {
37  [0]=>
38  int(0)
39  [1]=>
40  int(0)
41}
42object(FFI\CType:uint8_t[2])#%d (0) {
43}
44object(FFI\CData:uint8_t[2])#%d (2) {
45  [0]=>
46  int(0)
47  [1]=>
48  int(0)
49}
50object(FFI\CType:uint16_t[2])#%d (0) {
51}
52object(FFI\CData:uint16_t[2])#%d (2) {
53  [0]=>
54  int(0)
55  [1]=>
56  int(0)
57}
58object(FFI\CType:uint32_t)#%d (0) {
59}
60object(FFI\CType:uint32_t[2][2])#%d (0) {
61}
62