mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
6738241aec
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;
35 lines
454 B
PHP
35 lines
454 B
PHP
--TEST--
|
|
FFI 026: Array iteration by reference
|
|
--SKIPIF--
|
|
<?php require_once('skipif.inc'); ?>
|
|
--INI--
|
|
ffi.enable=1
|
|
--FILE--
|
|
<?php
|
|
$a = FFI::new("int[3]");
|
|
$a[1] = 10;
|
|
$a[2] = 20;
|
|
var_dump($a);
|
|
foreach ($a as &$val) {
|
|
$val->cdata += 5;
|
|
}
|
|
var_dump($a);
|
|
?>
|
|
--EXPECTF--
|
|
object(FFI\CData:int32_t[3])#%d (3) {
|
|
[0]=>
|
|
int(0)
|
|
[1]=>
|
|
int(10)
|
|
[2]=>
|
|
int(20)
|
|
}
|
|
object(FFI\CData:int32_t[3])#%d (3) {
|
|
[0]=>
|
|
int(5)
|
|
[1]=>
|
|
int(15)
|
|
[2]=>
|
|
int(25)
|
|
}
|