aboutsummaryrefslogtreecommitdiff
path: root/php/src/Google/Protobuf/Internal/MapFieldIter.php
diff options
context:
space:
mode:
authorYilun Chong <chongyilun250@sina.com>2017-06-30 17:38:50 -0700
committerGitHub <noreply@github.com>2017-06-30 17:38:50 -0700
commite82ba0b8026eb16c40ceba861f02c643c36e8232 (patch)
tree2aa89a917c6091923682221026507aa9eea1aba4 /php/src/Google/Protobuf/Internal/MapFieldIter.php
parent726ba33d98cd06c268f88b7dedf2a9a7916d978d (diff)
parentecca6ea95d56a6f70ff7b223ec3f904758acc8b1 (diff)
downloadprotobuf-e82ba0b8026eb16c40ceba861f02c643c36e8232.tar.gz
protobuf-e82ba0b8026eb16c40ceba861f02c643c36e8232.tar.bz2
protobuf-e82ba0b8026eb16c40ceba861f02c643c36e8232.zip
Merge branch 'master' into ConformanceTestYilunChong
Diffstat (limited to 'php/src/Google/Protobuf/Internal/MapFieldIter.php')
-rw-r--r--php/src/Google/Protobuf/Internal/MapFieldIter.php14
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
+}