1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 10:43:30 +02:00
Files
archived-php-src/ext/ffi/tests/025.phpt
T
Dmitry Stogov 6738241aec Avoid usage of internal get/set object handlers. They are going to be removed in PHP-8.
Scalar FFI values now should be accessed through special "cdata" property.

    $x = FFI::new("int");
    $x = 42;

    should be changed into

    $x = FFI::new("int");
    $x->cdata = 42;
2019-05-28 17:08:35 +03:00

45 lines
632 B
PHP

--TEST--
FFI 025: direct work with primitive types
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--INI--
ffi.enable=1
--FILE--
<?php
$x = FFI::new("int");
$x->cdata = 5;
var_dump($x);
$x->cdata += 2;
var_dump($x);
echo "$x\n\n";
unset($x);
$x = FFI::new("char");
$x->cdata = 'a';
var_dump($x);
$x->cdata++;
var_dump($x);
echo "$x\n\n";
unset($x);
?>
--EXPECTF--
object(FFI\CData:int32_t)#%d (1) {
["cdata"]=>
int(5)
}
object(FFI\CData:int32_t)#%d (1) {
["cdata"]=>
int(7)
}
7
object(FFI\CData:char)#%d (1) {
["cdata"]=>
string(1) "a"
}
object(FFI\CData:char)#%d (1) {
["cdata"]=>
string(1) "b"
}
b