[php-src] Issue #8355: char CData can't be directly assigned a number

From: Date: Tue, 12 Apr 2022 19:58:18 +0000
Subject: [php-src] Issue #8355: char CData can't be directly assigned a number
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240909@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8355 Author: bwoebi ### Description The following code: ```php <?php $v = FFI::new("char[2]"); $v[0] = 65; var_dump($v); ``` Resulted in this output: ``` Fatal error: Uncaught FFI\Exception: Incompatible types when assigning to type 'char' from PHP 'int' in Command line code:1 Stack trace: #0 {main} thrown in Command line code on line 1 ``` But I expected this output instead: ``` object(FFI\CData:char[2])#1 (2) { [0]=> string(1) "A" [1]=> string(1) "" } ``` It's somewhat weird to have to type cast around, i.e. I could just do a FFI::cast to uint8_t * and it works. But for some reason, char is special. Seems like an arbitrary restriction to me, and it really should accept both. ### PHP Version master ### Operating System _No response_

« previous php.bugs (#240909) next »