aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/src
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2016-11-16 11:07:43 -0800
committerGravatar GitHub <noreply@github.com>2016-11-16 11:07:43 -0800
commit99564c3347223b92e49bd40f37b8c0d6fc6a3971 (patch)
tree4f5de7e413798a02a9a66847560de13c973090d1 /php/src
parentfc27ead10719f768eb990accac434f48efe10d16 (diff)
Rename Empty to GPBEmpty in php generated file.
In php, class name cannot be "Empty". Modified code generator to (#2375) generate GPBEmpty instead (for google.protobuf.Empty only). Also change runtime code to work with the new generated code accordingly.
Diffstat (limited to 'php/src')
-rw-r--r--php/src/Google/Protobuf/descriptor.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/php/src/Google/Protobuf/descriptor.php b/php/src/Google/Protobuf/descriptor.php
index e5cff0ba..ef6b9dcf 100644
--- a/php/src/Google/Protobuf/descriptor.php
+++ b/php/src/Google/Protobuf/descriptor.php
@@ -215,6 +215,18 @@ class Descriptor
return $desc;
}
}
+
+function addPrefixIfSpecial(
+ $name,
+ $package)
+{
+ if ($name === "Empty" && $package === "google.protobuf") {
+ return "GPBEmpty";
+ } else {
+ return $name;
+ }
+}
+
function getFullClassName(
$proto,
$containing,
@@ -224,7 +236,8 @@ function getFullClassName(
&$fullname)
{
// Full name needs to start with '.'.
- $message_name_without_package = $proto->getName();
+ $message_name_without_package =
+ addPrefixIfSpecial($proto->getName(), $package);
if ($containing !== "") {
$message_name_without_package =
$containing . "." . $message_name_without_package;