diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2017-01-27 13:17:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-27 13:17:54 -0800 |
commit | a323f1e65da2c512f971a2edf1918a0cca340015 (patch) | |
tree | 22ae538979fd53567f144a112b069ae2706a03e0 /php/src/Google | |
parent | 5af0b547de7aba6d6206943546262cb21fedc721 (diff) | |
download | protobuf-a323f1e65da2c512f971a2edf1918a0cca340015.tar.gz protobuf-a323f1e65da2c512f971a2edf1918a0cca340015.tar.bz2 protobuf-a323f1e65da2c512f971a2edf1918a0cca340015.zip |
Oneof accessor should return the field name that is actually set. (#2631)
Diffstat (limited to 'php/src/Google')
-rw-r--r-- | php/src/Google/Protobuf/Internal/Message.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php index 3d1f1598..031c82a2 100644 --- a/php/src/Google/Protobuf/Internal/Message.php +++ b/php/src/Google/Protobuf/Internal/Message.php @@ -163,6 +163,17 @@ class Message $oneof_field->setNumber($number); } + protected function whichOneof($oneof_name) + { + $oneof_field = $this->$oneof_name; + $number = $oneof_field->getNumber(); + if ($number == 0) { + return ""; + } + $field = $this->desc->getFieldByNumber($number); + return $field->getName(); + } + /** * @ignore */ |