Hello, (I'm writing to the internals list because I don't think that at this point, FFI usage is wide-spread enough to get an opinion on other venues)
maybe I'm just stupid, but I think there has been a slight oversight in the API design for the FFI interface. My problem is with functions that return a pointer to a struct as an out parameter. So in C, it would look like this: Error* err; func(&err); if (err != NULL){ do_error_handling(); } If I translate this to PHP FFI, I would do $err = $ffi->new("Error*"); $ffi->func(FFI::addr($err)); if I `var_dump` $err, I do see a public {0} property be set to NULL or to actual error data. My issue is though: How do I check whether err* as been assgined to? isset($err) $err[0] != null -> is always true, regardless of whether func as assigned an error or not isset($err->{0}) isset($err[0]) -> Cannot use object of type FFI\CData as array $err->{0} != NULL; -> FFI\Exception: NULL pointer dereference $err[0]; -> segfault I'm sure I must be doing something wrong, but I don't know what. Also, the documentation could do with an example on how to achieve the desired result and, TBH, I think some of the various attempts produce a somewhat unexpected output. Any comments? Philip var_dump(isset($r->{0})); -> Error: Cannot use object of type FFI\CData as array $a = '{0}'; var_dump(isset($r->$a)); -> Error: Cannot use object of type FFI\CData as array var_dump(isset($r[0])); var_dump($r[0]);