diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2017-06-30 12:14:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-30 12:14:09 -0700 |
commit | ecca6ea95d56a6f70ff7b223ec3f904758acc8b1 (patch) | |
tree | 728f4aff0d5f00c78a741cf737ea6de58f4ba645 /php/src/Google/Protobuf/Internal/MapFieldIter.php | |
parent | 5a52b3588d35d2fa0b9ce4eda5630546966a26b4 (diff) | |
download | protobuf-ecca6ea95d56a6f70ff7b223ec3f904758acc8b1.tar.gz protobuf-ecca6ea95d56a6f70ff7b223ec3f904758acc8b1.tar.bz2 protobuf-ecca6ea95d56a6f70ff7b223ec3f904758acc8b1.zip |
Add json encode/decode for php. (#3226)
* Add json encode/decode for php.
* Fix php conformance test on 32-bit machines.
* Fix conformance test for c extension.
* Fix comments
Diffstat (limited to 'php/src/Google/Protobuf/Internal/MapFieldIter.php')
-rw-r--r-- | php/src/Google/Protobuf/Internal/MapFieldIter.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/php/src/Google/Protobuf/Internal/MapFieldIter.php b/php/src/Google/Protobuf/Internal/MapFieldIter.php index a0388d92..cb707955 100644 --- a/php/src/Google/Protobuf/Internal/MapFieldIter.php +++ b/php/src/Google/Protobuf/Internal/MapFieldIter.php @@ -54,11 +54,13 @@ class MapFieldIter implements \Iterator * * @param MapField The MapField instance for which this iterator is * created. + * @param GPBType Map key type. * @ignore */ - public function __construct($container) + public function __construct($container, $key_type) { $this->container = $container; + $this->key_type = $key_type; } /** @@ -88,7 +90,13 @@ class MapFieldIter implements \Iterator */ public function key() { - return key($this->container); + $key = key($this->container); + // PHP associative array stores bool as integer for key. + if ($this->key_type === GPBType::BOOL) { + return boolval($key); + } else { + return $key; + } } /** @@ -110,4 +118,4 @@ class MapFieldIter implements \Iterator { return key($this->container) !== null; } -}
\ No newline at end of file +} |