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