What is the problem with the upgrade from protocol-buffer-protocolbuffers to php7?

Source: Internet
Author: User
Background because protocolbuffers is being used in the project, all the extensions used in the project basically support php7. only protocolbuffers does not support php7. the original author has stopped maintaining the extension, instead, you can only start to study how to extend protocolbuffers. x... background

Because protocolbuffers is being used in the project, the extensions used in the entire project basically support php7. only protocolbuffers does not support php7, and the original author has stopped maintaining the extension, instead, you can only start to study how to extend protocolbuffers. upgrade PHP 7 to version x. Currently, this extension can be compiled. Github

The result of make test is as follows:
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%)
Problems encountered

The following is the test code:


  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);}

The output result is as follows:

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)}

Conclusion: in protocolbuffers: decode, the parsed object can be returned, but the object attributes cannot be read. Solving...

Reply content: Background

Because protocolbuffers is being used in the project, the extensions used in the entire project basically support php7. only protocolbuffers does not support php7, and the original author has stopped maintaining the extension, instead, you can only start to study how to extend protocolbuffers. upgrade PHP 7 to version x. Currently, this extension can be compiled. Github

The result of make test is as follows:
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%)
Problems encountered

The following is the test code:


  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);}

The output result is as follows:

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)}

Conclusion: in protocolbuffers: decode, the parsed object can be returned, but the object attributes cannot be read. Solving...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.