[php-src] Issue #7866: Ability to pick PHP value by reference in FFI.

From: Date: Sat, 01 Jan 2022 18:31:20 +0000
Subject: [php-src] Issue #7866: Ability to pick PHP value by reference in FFI.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238703@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7866 Comment Author: userqq And it would be great to have possibility to achive something like: ```php $data = fread($h, $packetLength); // No data copied, $packet is reference to $data $packet = FFI::represent('struct { int64_t messageId; int32_t length; char payload[]; }', &$data, $packetLength); var_dump($packet->length); // Lets imagine payload is also binary packed struct $message = FFI::represent('struct { int32_t messageTypeId; int32_t magic; int32_t signature; ... }', &$packet->payload, FFI::sizeof($packet->payload)); var_dump($message->messageTypeId); // $message is reference to $packet, which is reference to $data // Modification of $message should affect $data value $message->magic = 200; ```

« previous php.bugs (#238703) next »