aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/src/Google/Protobuf/Internal/MapField.php
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@gmail.com>2018-06-25 15:52:29 -0700
committerGravatar GitHub <noreply@github.com>2018-06-25 15:52:29 -0700
commitd6f346b4d55ae5112934297593ec1c56c3d178a5 (patch)
tree021b5476160e465a20ef7d4ae4c0524351667233 /php/src/Google/Protobuf/Internal/MapField.php
parent3d603f481ed142d0be5e8e4dd6d1cb4457a51405 (diff)
parent82d3d7d250645322f8a7343188e5ae6246a76414 (diff)
Merge pull request #4827 from acozzette/merge-3-6-x
Merge 3.6.x branch into master
Diffstat (limited to 'php/src/Google/Protobuf/Internal/MapField.php')
-rw-r--r--php/src/Google/Protobuf/Internal/MapField.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/php/src/Google/Protobuf/Internal/MapField.php b/php/src/Google/Protobuf/Internal/MapField.php
index 38736dad..f7d7b710 100644
--- a/php/src/Google/Protobuf/Internal/MapField.php
+++ b/php/src/Google/Protobuf/Internal/MapField.php
@@ -58,7 +58,11 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* @ignore
*/
- private $value_klass;
+ private $klass;
+ /**
+ * @ignore
+ */
+ private $legacy_klass;
/**
* Constructs an instance of MapField.
@@ -75,6 +79,17 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
$this->key_type = $key_type;
$this->value_type = $value_type;
$this->klass = $klass;
+
+ if ($this->value_type == GPBType::MESSAGE) {
+ $pool = DescriptorPool::getGeneratedPool();
+ $desc = $pool->getDescriptorByClassName($klass);
+ if ($desc == NULL) {
+ new $klass; // No msg class instance has been created before.
+ $desc = $pool->getDescriptorByClassName($klass);
+ }
+ $this->klass = $desc->getClass();
+ $this->legacy_klass = $desc->getLegacyClass();
+ }
}
/**
@@ -102,6 +117,14 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
}
/**
+ * @ignore
+ */
+ public function getLegacyValueClass()
+ {
+ return $this->legacy_klass;
+ }
+
+ /**
* Return the element at the given key.
*
* This will also be called for: $ele = $arr[$key]