Use message name as defined in php runtime.

This commit is contained in:
Bo Yang 2017-08-21 13:39:15 -07:00
parent 26ac3e8e24
commit dd5190980b
5 changed files with 25 additions and 1 deletions

View File

@ -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;
}

View File

@ -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()) {

View File

@ -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;
}
}

View File

@ -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');

View File

@ -192,3 +192,10 @@ message TestReverseFieldOrder {
repeated int32 a = 2;
string b = 1;
}
message testLowerCaseMessage {
}
enum testLowerCaseEnum {
VALUE = 0;
}