xref: /php-src/ext/ffi/tests/013.phpt (revision 4acf0084)
1--TEST--
2FFI 013: Declaration priorities and constrains
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9$ffi = FFI::cdef();
10
11$a = $ffi->new("int[1][2][3]");
12var_dump(count($a));
13var_dump(count($a[0]));
14var_dump(count($a[0][0]));
15
16try {
17    var_dump($ffi->new("void"));
18} catch (Throwable $e) {
19    echo get_class($e) . ": " . $e->getMessage()."\n";
20}
21
22try {
23    var_dump($ffi->new("void[1]"));
24} catch (Throwable $e) {
25    echo get_class($e) . ": " . $e->getMessage()."\n";
26}
27try {
28    FFI::cdef("static int foo(int)[5];");
29    echo "ok\n";
30} catch (Throwable $e) {
31    echo get_class($e) . ": " . $e->getMessage()."\n";
32}
33try {
34    FFI::cdef("static int foo[5](int);");
35    echo "ok\n";
36} catch (Throwable $e) {
37    echo get_class($e) . ": " . $e->getMessage()."\n";
38}
39try {
40    FFI::cdef("static int foo(int)(int);");
41    echo "ok\n";
42} catch (Throwable $e) {
43    echo get_class($e) . ": " . $e->getMessage()."\n";
44}
45try {
46    FFI::cdef("typedef int foo[2][];");
47    echo "ok\n";
48} catch (Throwable $e) {
49    echo get_class($e) . ": " . $e->getMessage()."\n";
50}
51try {
52    FFI::cdef("typedef int foo[][2];");
53    echo "ok\n";
54} catch (Throwable $e) {
55    echo get_class($e) . ": " . $e->getMessage()."\n";
56}
57?>
58--EXPECT--
59int(1)
60int(2)
61int(3)
62FFI\ParserException: void type is not allowed at line 1
63FFI\ParserException: void type is not allowed at line 1
64FFI\ParserException: Function returning array is not allowed at line 1
65FFI\ParserException: Array of functions is not allowed at line 1
66FFI\ParserException: Function returning function is not allowed at line 1
67FFI\ParserException: Only the leftmost array can be undimensioned at line 1
68ok
69