xref: /php-src/ext/ffi/tests/017.phpt (revision 4acf0084)
1--TEST--
2FFI 017: Structure constraints & tags cleanup
3--EXTENSIONS--
4ffi
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--
27Deprecated: Calling FFI::new() statically is deprecated in %s on line %d
28FFI\ParserException: function type is not allowed at line 1
29
30Deprecated: Calling FFI::new() statically is deprecated in %s on line %d
31FFI\ParserException: Struct/union can't contain an instance of itself at line 1
32
33Deprecated: Calling FFI::new() statically is deprecated in %s on line %d
34object(FFI\CData:struct X)#%d (1) {
35  ["ptr"]=>
36  NULL
37}
38ok
39