xref: /php-src/ext/ffi/tests/deprecations.phpt (revision 4acf0084)
1--TEST--
2Test calling the deprecated signature of FFI::new(), FFI::type(), FFI::cast()
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9
10$p1 = FFI::new("uint8_t[2]");
11
12set_error_handler(function ($severity, $message, $file, $line) {
13    throw new Exception($message);
14});
15try {
16    FFI::new("uint8_t[2]");
17} catch (Exception $e) {
18    echo $e->getMessage() . "\n";
19}
20set_error_handler(null);
21
22var_dump($p1);
23
24$t1 = FFI::type("uint16_t[2]");
25
26set_error_handler(function ($severity, $message, $file, $line) {
27    throw new Exception($message);
28});
29try {
30    FFI::type("uint16_t[2]");
31} catch (Exception $e) {
32    echo $e->getMessage() . "\n";
33}
34set_error_handler(null);
35
36$p = FFI::cast("uint8_t[2]", $p1);
37set_error_handler(function ($severity, $message, $file, $line) {
38    throw new Exception($message);
39});
40try {
41    FFI::cast("uint8_t[2]", $p1);
42} catch (Exception $e) {
43    echo $e->getMessage() . "\n";
44}
45
46?>
47--EXPECTF--
48Deprecated: Calling FFI::new() statically is deprecated in %s on line %d
49Calling FFI::new() statically is deprecated
50object(FFI\CData:uint8_t[2])#1 (2) {
51  [0]=>
52  int(0)
53  [1]=>
54  int(0)
55}
56
57Deprecated: Calling FFI::type() statically is deprecated in %s on line %d
58Calling FFI::type() statically is deprecated
59
60Deprecated: Calling FFI::cast() statically is deprecated in %s on line %d
61Calling FFI::cast() statically is deprecated
62