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