Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
e259b515
Commit
e259b515
authored
Jan 10, 2017
by
Bo Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix generated code when there is no namespace but there is enum definition.
parent
83fb8c7d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
6 deletions
+19
-6
generated_class_test.php
php/tests/generated_class_test.php
+8
-3
test_no_namespace.proto
php/tests/proto/test_no_namespace.proto
+6
-1
php_generator.cc
src/google/protobuf/compiler/php/php_generator.cc
+5
-2
No files found.
php/tests/generated_class_test.php
View file @
e259b515
<?php
require_once
(
'generated/NoNameSpace.php'
);
require_once
(
'generated/NoNameSpaceEnum.php'
);
require_once
(
'generated/NoNameSpaceMessage.php'
);
require_once
(
'test_util.php'
);
use
Google\Protobuf\Internal\RepeatedField
;
...
...
@@ -601,10 +602,14 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase
}
#########################################################
# Test
oneof field
.
# Test
message/enum without namespace
.
#########################################################
public
function
testMessageWithoutNamespace
()
{
$m
=
new
NoNameSpace
();
$m
=
new
NoNameSpaceMessage
();
}
public
function
testEnumWithoutNamespace
()
{
$m
=
new
NoNameSpaceEnum
();
}
}
php/tests/proto/test_no_namespace.proto
View file @
e259b515
syntax
=
"proto3"
;
message
NoNameSpace
{
message
NoNameSpace
Message
{
int32
a
=
1
;
}
enum
NoNameSpaceEnum
{
VALUE_A
=
0
;
VALUE_B
=
1
;
}
src/google/protobuf/compiler/php/php_generator.cc
View file @
e259b515
...
...
@@ -757,12 +757,15 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
std
::
string
fullname
=
FilenameToClassname
(
filename
);
int
lastindex
=
fullname
.
find_last_of
(
"
\\
"
);
GenerateEnumDocComment
(
&
printer
,
en
);
if
(
lastindex
!=
string
::
npos
)
{
if
(
!
file
->
package
().
empty
())
{
printer
.
Print
(
"namespace ^name^;
\n\n
"
,
"name"
,
fullname
.
substr
(
0
,
lastindex
));
}
GenerateEnumDocComment
(
&
printer
,
en
);
if
(
lastindex
!=
string
::
npos
)
{
printer
.
Print
(
"class ^name^
\n
"
"{
\n
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment