diff options
author | Jisi Liu <liujisi@google.com> | 2017-08-22 11:07:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-22 11:07:47 -0700 |
commit | e416f5d2d3fd9f0ce505ae25732eada12d636a12 (patch) | |
tree | 771c6b8951213d740d0b964fee1c8519530f7193 | |
parent | 7273b3c691cd46d609c5482e62f5b38f61281337 (diff) | |
parent | dd5190980b8a9205eaf292f0cd947c3657daaeb1 (diff) |
Merge pull request #3537 from TeBoring/php-bug
Use message name as defined in php runtime.
-rw-r--r-- | php/src/Google/Protobuf/Internal/GPBUtil.php | 2 | ||||
-rw-r--r-- | php/src/Google/Protobuf/Internal/Message.php | 3 | ||||
-rw-r--r-- | php/tests/generated_class_test.php | 12 | ||||
-rw-r--r-- | php/tests/memory_leak_test.php | 2 | ||||
-rw-r--r-- | php/tests/proto/test.proto | 7 |
5 files changed, 25 insertions, 1 deletions
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index 6fe36068..84e8ecf0 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -270,7 +270,7 @@ class GPBUtil $name, $file_proto) { - $classname = implode('_', array_map('ucwords', explode('.', $name))); + $classname = implode('_', explode('.', $name)); return static::getClassNamePrefix($classname, $file_proto) . $classname; } diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php index e1009f2f..8886e61a 100644 --- a/php/src/Google/Protobuf/Internal/Message.php +++ b/php/src/Google/Protobuf/Internal/Message.php @@ -76,6 +76,9 @@ class Message } $pool = DescriptorPool::getGeneratedPool(); $this->desc = $pool->getDescriptorByClassName(get_class($this)); + if (is_null($this->desc)) { + user_error(get_class($this) . "is not found in descriptor pool."); + } foreach ($this->desc->getField() as $field) { $setter = $field->getSetter(); if ($field->isMap()) { diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php index 86e68683..98918bce 100644 --- a/php/tests/generated_class_test.php +++ b/php/tests/generated_class_test.php @@ -14,6 +14,8 @@ use Foo\TestIncludePrefixMessage; use Foo\TestMessage; use Foo\TestMessage_Sub; use Foo\TestReverseFieldOrder; +use Foo\testLowerCaseMessage; +use Foo\testLowerCaseEnum; use Php\Test\TestNamespace; class GeneratedClassTest extends TestBase @@ -715,4 +717,14 @@ class GeneratedClassTest extends TestBase $this->assertSame("abc", $m->getB()); $this->assertNotSame("abc", $m->getA()); } + + ######################################################### + # Test Reverse Field Order. + ######################################################### + + public function testLowerCase() + { + $m = new testLowerCaseMessage(); + $n = testLowerCaseEnum::VALUE; + } } diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php index a92694d0..7c3a1801 100644 --- a/php/tests/memory_leak_test.php +++ b/php/tests/memory_leak_test.php @@ -23,6 +23,8 @@ require_once('generated/Foo/TestPhpDoc.php'); require_once('generated/Foo/TestRandomFieldOrder.php'); require_once('generated/Foo/TestReverseFieldOrder.php'); require_once('generated/Foo/TestUnpackedMessage.php'); +require_once('generated/Foo/testLowerCaseMessage.php'); +require_once('generated/Foo/testLowerCaseEnum.php'); require_once('generated/GPBMetadata/Proto/Test.php'); require_once('generated/GPBMetadata/Proto/TestEmptyPhpNamespace.php'); require_once('generated/GPBMetadata/Proto/TestInclude.php'); diff --git a/php/tests/proto/test.proto b/php/tests/proto/test.proto index a90f3d1d..56cba446 100644 --- a/php/tests/proto/test.proto +++ b/php/tests/proto/test.proto @@ -192,3 +192,10 @@ message TestReverseFieldOrder { repeated int32 a = 2; string b = 1; } + +message testLowerCaseMessage { +} + +enum testLowerCaseEnum { + VALUE = 0; +} |