


protocol-buffer - Problems encountered when upgrading protocolbuffers extension to php7?
Background
Since protocolbuffers are being used in the project, the extensions used in the entire project basically support php7. Only protocolbuffers does not support php7. The original author has stopped maintaining the extension, and has no choice but to start researching how to extend protocolbuffers. Version 5.x is upgraded to php7. The extension currently compiles. github
The results of make test are as follows:
<code>Number of tests : 144 144 Tests 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%)</code>
Problems encountered
The following is the test code:
<code><?php require dirname(__FILE__) . DIRECTORY_SEPARATOR . "messages" . DIRECTORY_SEPARATOR . "field_int32.proto.php"; $bytes = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . "fixtures" . DIRECTORY_SEPARATOR . "001_int32_init.bin"); $u = new Tutorial_Integer32(); $u->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); } </code>
The output results are as follows:
<code>object(Tutorial_Integer32)#2 (2) { ["_properties":protected]=> array(0) { } ["value":protected]=> string(1) "0" } NULL OK NULL object(Tutorial_Integer32)#3 (2) { ["_properties":protected]=> array(0) { } ["value":protected]=> int(0) }</code>
Problem summary: When protocolbuffers::decode, the parsed object can be returned, but the properties of the object cannot be read. Solving. . .
Reply content:
Background
Since protocolbuffers are being used in the project, the extensions used in the entire project basically support php7. Only protocolbuffers does not support php7. The original author has stopped maintaining the extension, and has no choice but to start researching how to extend protocolbuffers. Version 5.x is upgraded to php7. The extension currently compiles. github
The results of make test are as follows:
<code>Number of tests : 144 144 Tests 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%)</code>
Problems encountered
The following is the test code:
<code><?php require dirname(__FILE__) . DIRECTORY_SEPARATOR . "messages" . DIRECTORY_SEPARATOR . "field_int32.proto.php"; $bytes = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . "fixtures" . DIRECTORY_SEPARATOR . "001_int32_init.bin"); $u = new Tutorial_Integer32(); $u->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); } </code>
The output results are as follows:
<code>object(Tutorial_Integer32)#2 (2) { ["_properties":protected]=> array(0) { } ["value":protected]=> string(1) "0" } NULL OK NULL object(Tutorial_Integer32)#3 (2) { ["_properties":protected]=> array(0) { } ["value":protected]=> int(0) }</code>
Problem summary: When protocolbuffers::decode, the parsed object can be returned, but the properties of the object cannot be read. Solving. . .

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
