xref: /PHP-7.4/ext/ffi/tests/016.phpt (revision e089d506)
1--TEST--
2FFI 016: Structure constraints
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9try {
10	FFI::cdef("struct X {void x();};");
11	echo "ok\n";
12} catch (Throwable $e) {
13	echo get_class($e) . ": " . $e->getMessage()."\n";
14}
15try {
16	FFI::cdef("struct X {struct X x;};");
17	echo "ok\n";
18} catch (Throwable $e) {
19	echo get_class($e) . ": " . $e->getMessage()."\n";
20}
21try {
22	FFI::cdef("struct X {struct X *ptr;};");
23	echo "ok\n";
24} catch (Throwable $e) {
25	echo get_class($e) . ": " . $e->getMessage()."\n";
26}
27?>
28ok
29--EXPECT--
30FFI\ParserException: 'function' type is not allowed at line 1
31FFI\ParserException: struct/union can't contain an instance of itself at line 1
32ok
33ok
34