背景由于项目中正在使用protocolbuffers,整个项目中使用到的扩展基本都已经支持php7,只有protocolbuffers这个还不支持php7,原作者已经停止维护了该扩展,无奈只能自己开始研究如何将protocolbuffers扩展的5.x版本升级到php7。目前该扩展可以通过编译。github
make test结果如下:number of tests : 144 144tests skipped : 0 ( 0.0%) --------tests warned : 0 ( 0.0%) ( 0.0%)tests failed : 67 ( 46.5%) ( 46.5%)expected fail : 0 ( 0.0%) ( 0.0%)tests passed : 77 ( 53.5%) ( 53.5%)
遇到的问题以下为测试代码:
setvalue(0);$obj = protocolbuffers::decode(tutorial_integer32, $bytes);var_dump($obj);if ($obj instanceof tutorial_integer32) { var_dump($obj->getvalue()); if ($obj->getvalue() == 0) { echo ok . php_eol; } else { var_dump($obj); }} else { var_dump($obj);}ini_set(protocolbuffers.native_scalars, 1);$obj = protocolbuffers::decode(tutorial_integer32, $bytes);if ($obj instanceof tutorial_integer32) { var_dump($obj->getvalue()); if ($obj->getvalue() === 0) { echo ok . php_eol; } else { var_dump($obj); }} else { var_dump($obj);}
输出结果如下:
object(tutorial_integer32)#2 (2) { [_properties:protected]=> array(0) { } [value:protected]=> string(1) 0}nulloknullobject(tutorial_integer32)#3 (2) { [_properties:protected]=> array(0) { } [value:protected]=> int(0)}
问题总结:在protocolbuffers::decode时,能够返回被解析的对象,但是对象的属性无法读取。求解中。。。
回复内容: 背景由于项目中正在使用protocolbuffers,整个项目中使用到的扩展基本都已经支持php7,只有protocolbuffers这个还不支持php7,原作者已经停止维护了该扩展,无奈只能自己开始研究如何将protocolbuffers扩展的5.x版本升级到php7。目前该扩展可以通过编译。github
make test结果如下:number of tests : 144 144tests skipped : 0 ( 0.0%) --------tests warned : 0 ( 0.0%) ( 0.0%)tests failed : 67 ( 46.5%) ( 46.5%)expected fail : 0 ( 0.0%) ( 0.0%)tests passed : 77 ( 53.5%) ( 53.5%)
遇到的问题以下为测试代码:
setvalue(0);$obj = protocolbuffers::decode(tutorial_integer32, $bytes);var_dump($obj);if ($obj instanceof tutorial_integer32) { var_dump($obj->getvalue()); if ($obj->getvalue() == 0) { echo ok . php_eol; } else { var_dump($obj); }} else { var_dump($obj);}ini_set(protocolbuffers.native_scalars, 1);$obj = protocolbuffers::decode(tutorial_integer32, $bytes);if ($obj instanceof tutorial_integer32) { var_dump($obj->getvalue()); if ($obj->getvalue() === 0) { echo ok . php_eol; } else { var_dump($obj); }} else { var_dump($obj);}
输出结果如下:
object(tutorial_integer32)#2 (2) { [_properties:protected]=> array(0) { } [value:protected]=> string(1) 0}nulloknullobject(tutorial_integer32)#3 (2) { [_properties:protected]=> array(0) { } [value:protected]=> int(0)}
问题总结:在protocolbuffers::decode时,能够返回被解析的对象,但是对象的属性无法读取。求解中。。。