Commit e416f5d2 authored by Jisi Liu's avatar Jisi Liu Committed by GitHub

Merge pull request #3537 from TeBoring/php-bug

Use message name as defined in php runtime.
parents 7273b3c6 dd519098
...@@ -270,7 +270,7 @@ class GPBUtil ...@@ -270,7 +270,7 @@ class GPBUtil
$name, $name,
$file_proto) $file_proto)
{ {
$classname = implode('_', array_map('ucwords', explode('.', $name))); $classname = implode('_', explode('.', $name));
return static::getClassNamePrefix($classname, $file_proto) . $classname; return static::getClassNamePrefix($classname, $file_proto) . $classname;
} }
......
...@@ -76,6 +76,9 @@ class Message ...@@ -76,6 +76,9 @@ class Message
} }
$pool = DescriptorPool::getGeneratedPool(); $pool = DescriptorPool::getGeneratedPool();
$this->desc = $pool->getDescriptorByClassName(get_class($this)); $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) { foreach ($this->desc->getField() as $field) {
$setter = $field->getSetter(); $setter = $field->getSetter();
if ($field->isMap()) { if ($field->isMap()) {
......
...@@ -14,6 +14,8 @@ use Foo\TestIncludePrefixMessage; ...@@ -14,6 +14,8 @@ use Foo\TestIncludePrefixMessage;
use Foo\TestMessage; use Foo\TestMessage;
use Foo\TestMessage_Sub; use Foo\TestMessage_Sub;
use Foo\TestReverseFieldOrder; use Foo\TestReverseFieldOrder;
use Foo\testLowerCaseMessage;
use Foo\testLowerCaseEnum;
use Php\Test\TestNamespace; use Php\Test\TestNamespace;
class GeneratedClassTest extends TestBase class GeneratedClassTest extends TestBase
...@@ -715,4 +717,14 @@ class GeneratedClassTest extends TestBase ...@@ -715,4 +717,14 @@ class GeneratedClassTest extends TestBase
$this->assertSame("abc", $m->getB()); $this->assertSame("abc", $m->getB());
$this->assertNotSame("abc", $m->getA()); $this->assertNotSame("abc", $m->getA());
} }
#########################################################
# Test Reverse Field Order.
#########################################################
public function testLowerCase()
{
$m = new testLowerCaseMessage();
$n = testLowerCaseEnum::VALUE;
}
} }
...@@ -23,6 +23,8 @@ require_once('generated/Foo/TestPhpDoc.php'); ...@@ -23,6 +23,8 @@ require_once('generated/Foo/TestPhpDoc.php');
require_once('generated/Foo/TestRandomFieldOrder.php'); require_once('generated/Foo/TestRandomFieldOrder.php');
require_once('generated/Foo/TestReverseFieldOrder.php'); require_once('generated/Foo/TestReverseFieldOrder.php');
require_once('generated/Foo/TestUnpackedMessage.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/Test.php');
require_once('generated/GPBMetadata/Proto/TestEmptyPhpNamespace.php'); require_once('generated/GPBMetadata/Proto/TestEmptyPhpNamespace.php');
require_once('generated/GPBMetadata/Proto/TestInclude.php'); require_once('generated/GPBMetadata/Proto/TestInclude.php');
......
...@@ -192,3 +192,10 @@ message TestReverseFieldOrder { ...@@ -192,3 +192,10 @@ message TestReverseFieldOrder {
repeated int32 a = 2; repeated int32 a = 2;
string b = 1; string b = 1;
} }
message testLowerCaseMessage {
}
enum testLowerCaseEnum {
VALUE = 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment