Can you provide a method to directly transfer to PHPArray?
What language does this apply to? If it's a proto syntax change, is it for proto2 or proto3? If it's about generated code change, what programming language?
Describe the problem you are trying to solve.

Describe the solution you'd like
Describe alternatives you've considered
Additional context
Add any other context or screenshots about the feature request here.
I think json_encode has performance loss. Can I use PHP Array directly?like :

Have you tried this?
$c2s = new XMan\Get\Request($C2S);
CentOS 9 + PHP 8.2.1 + protobuf 21.12
Get.proto
syntax = "proto3";
package Get;
option php_namespace = "XMan\\Get";
option php_metadata_namespace = "XMan\\Get\\pb";
message C2S
{
int32 uid = 1;
}
message Request
{
C2S c2s = 1;
}
php:
<?php
include(__DIR__ . '/../vendor/autoload.php');
function protobuf_autoloader($class){
if (strncmp($class, 'XMan\\', 5) === 0) {
include_once(__DIR__ . '/' . str_replace('\\', '/', $class) . '.php');
}
}
spl_autoload_register('protobuf_autoloader');
$C2S = array(
'c2s' => array(
'uid' => 2000
)
);
$c2s = new XMan\Get\Request($C2S);
/**Uncaught Exception: Expect XMan\Get\C2S. in /wwwroot/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBUtil.php:198
Stack trace:
#0 /wwwroot/tests/XMan/Get/Request.php(61): Google\Protobuf\Internal\GPBUtil::checkMessage()
#1 /wwwroot/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1080): XMan\Get\Request->setC2S()
#2 /wwwroot/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(79): Google\Protobuf\Internal\Message->mergeFromArray()
#3 /wwwroot/tests/XMan/Get/Request.php(32): Google\Protobuf\Internal\Message->__construct()
#4 /wwwroot/tests/zx.php(16): XMan\Get\Request->__construct()
#5 {main}
thrown in /wwwroot/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBUtil.php on line 198**/
die();
//The following code works fine
$c2s = new XMan\Get\Request();
$c2s->mergeFromJsonString(json_encode($C2S), true);
$C2S = $c2s->serializeToString();
$c2s = new XMan\Get\Request();
$c2s->mergeFromString($C2S);
$C2S = $c2s->serializeToJsonString(); //Can you provide a method like 'serializeToPHPArray' ?
$C2S = json_decode($C2S, true);
print_r($C2S);
It looks like the library is accepting the array, but it doesn't like the sub-array for the c2s field initializer.
It looks like you are using pure PHP. Does this example work with the Native C extension?
If so, we should fix the pure-PHP library to match.
It looks like the library is accepting the array, but it doesn't like the sub-array for the
c2sfield initializer.It looks like you are using pure PHP. Does this example work with the Native C extension?
If so, we should fix the pure-PHP library to match.
Neither "pure PHP" nor "Native C extension"
IN Native C extension:
PHP Fatal error: Uncaught TypeError: Given value is not an instance of XMan\Get\C2S. in /wwwroot/tests/XMan/Get/Request.php:32
Stack trace:
#0 /wwwroot/tests/XMan/Get/Request.php(32): Google\Protobuf\Internal\Message->__construct()
#1 /wwwroot/tests/zx.php(21): XMan\Get\Request->__construct()
#2 {main}
thrown in /wwwroot/tests/XMan/Get/Request.php on line 32
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.