Skip to content

Commit

Permalink
Use message name as defined in php runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
TeBoring committed Aug 21, 2017
1 parent 26ac3e8 commit dd51909
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion php/src/Google/Protobuf/Internal/GPBUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public static function getClassNameWithoutPackage(
$name,
$file_proto)
{
$classname = implode('_', array_map('ucwords', explode('.', $name)));
$classname = implode('_', explode('.', $name));
return static::getClassNamePrefix($classname, $file_proto) . $classname;
}

Expand Down
3 changes: 3 additions & 0 deletions php/src/Google/Protobuf/Internal/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public function __construct($desc = NULL)
}
$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()) {
Expand Down
12 changes: 12 additions & 0 deletions php/tests/generated_class_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Foo\TestMessage;
use Foo\TestMessage_Sub;
use Foo\TestReverseFieldOrder;
use Foo\testLowerCaseMessage;
use Foo\testLowerCaseEnum;
use Php\Test\TestNamespace;

class GeneratedClassTest extends TestBase
Expand Down Expand Up @@ -715,4 +717,14 @@ public function testReverseFieldOrder()
$this->assertSame("abc", $m->getB());
$this->assertNotSame("abc", $m->getA());
}

#########################################################
# Test Reverse Field Order.
#########################################################

public function testLowerCase()
{
$m = new testLowerCaseMessage();
$n = testLowerCaseEnum::VALUE;
}
}
2 changes: 2 additions & 0 deletions php/tests/memory_leak_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
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');
Expand Down
7 changes: 7 additions & 0 deletions php/tests/proto/test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,10 @@ message TestReverseFieldOrder {
repeated int32 a = 2;
string b = 1;
}

message testLowerCaseMessage {
}

enum testLowerCaseEnum {
VALUE = 0;
}

0 comments on commit dd51909

Please sign in to comment.