1--TEST-- 2FFI 047: FFI::CData->cdata meaning 3--EXTENSIONS-- 4ffi 5--INI-- 6ffi.enable=1 7--FILE-- 8<?php 9$x = FFI::cdef()->new("int"); 10$x->cdata = 42; 11var_dump($x); 12 13$x = FFI::cdef()->new("int*"); 14try { 15 $x->cdata = 42; 16 var_dump($x); 17} catch (Throwable $e) { 18 echo $e->getMessage() . "\n"; 19} 20 21$x = FFI::cdef()->new("struct {int cdata;}"); 22try { 23 $x->cdata = 42; 24 var_dump($x); 25} catch (Throwable $e) { 26 echo $e->getMessage() . "\n"; 27} 28?> 29--EXPECTF-- 30object(FFI\CData:int32_t)#%d (1) { 31 ["cdata"]=> 32 int(42) 33} 34Attempt to assign field 'cdata' of non C struct/union 35object(FFI\CData:struct <anonymous>)#%d (1) { 36 ["cdata"]=> 37 int(42) 38} 39