char CData can't be directly assigned a number
オープン
まだ誰も着手していません。
Extension: ffi
Feature
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue の PHP FFI の例を再現し、char 型の CData 値への代入の処理を追跡します。関連する FFI の実装と既存の FFI テストを見つけ、整数を char に代入する場合のカバレッジを追加して、期待される文字値が生成されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100