protocolbuffers/protobuf

PHP: better debug info for Message objects in protobuf C-extension

开放

#14,872 创建于 2023年11月28日

 (8 条评论) (3 个反应) (0 位负责人)C++ (16,128 个派生)batch import
help wantedphp

仓库指标

星标
 (71,223 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

See https://github.com/protocolbuffers/protobuf/issues/12714 and https://github.com/protocolbuffers/protobuf/pull/12718, which resolved this problem for the native library.

When the protobuf c-extension is enabled for PHP, calling var_dump on a protobuf message object does not output any useful information:

// Calling var_dump on a Protobuf message (extension enabled):
php > $timestamp = new Google\Protobuf\Timestamp();
php > $timestamp->setSeconds(12345);
php > var_dump($timestamp);
object(Google\Protobuf\Timestamp)#1 (0) {
}

Ideally this would output something like this:

object(Google\Protobuf\Timestamp)#12 (1) {
  ["seconds"]=>
  int(12345)
}

贡献者指南