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
54288a01
Unverified
Commit
54288a01
authored
Jun 21, 2019
by
Paul Yang
Committed by
GitHub
Jun 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename get/setXXXValue to get/setXXXUnwrapped (#6295)
parent
b7a5772c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
47 deletions
+47
-47
wrapper_type_setters_test.php
php/tests/wrapper_type_setters_test.php
+44
-44
php_generator.cc
src/google/protobuf/compiler/php/php_generator.cc
+3
-3
No files found.
php/tests/wrapper_type_setters_test.php
View file @
54288a01
...
...
@@ -60,26 +60,26 @@ class WrapperTypeSettersTest extends TestBase
public
function
gettersAndSettersDataProvider
()
{
return
[
[
TestWrapperSetters
::
class
,
DoubleValue
::
class
,
"setDoubleValue"
,
"setDoubleValue
Value"
,
"getDoubleValue"
,
"getDoubleValueValue
"
,
[
[
TestWrapperSetters
::
class
,
DoubleValue
::
class
,
"setDoubleValue"
,
"setDoubleValue
Unwrapped"
,
"getDoubleValue"
,
"getDoubleValueUnwrapped
"
,
[
[
1.1
,
new
DoubleValue
([
"value"
=>
1.1
])],
[
2.2
,
new
DoubleValue
([
"value"
=>
2.2
])],
[
null
,
null
],
[
0
,
new
DoubleValue
()],
]],
[
TestWrapperSetters
::
class
,
FloatValue
::
class
,
"setFloatValue"
,
"setFloatValue
Value"
,
"getFloatValue"
,
"getFloatValueValue
"
,
[
[
TestWrapperSetters
::
class
,
FloatValue
::
class
,
"setFloatValue"
,
"setFloatValue
Unwrapped"
,
"getFloatValue"
,
"getFloatValueUnwrapped
"
,
[
[
1.1
,
new
FloatValue
([
"value"
=>
1.1
])],
[
2.2
,
new
FloatValue
([
"value"
=>
2.2
])],
[
null
,
null
],
[
0
,
new
FloatValue
()],
]],
[
TestWrapperSetters
::
class
,
Int64Value
::
class
,
"setInt64Value"
,
"setInt64Value
Value"
,
"getInt64Value"
,
"getInt64ValueValue
"
,
[
[
TestWrapperSetters
::
class
,
Int64Value
::
class
,
"setInt64Value"
,
"setInt64Value
Unwrapped"
,
"getInt64Value"
,
"getInt64ValueUnwrapped
"
,
[
[
123
,
new
Int64Value
([
"value"
=>
123
])],
[
-
789
,
new
Int64Value
([
"value"
=>
-
789
])],
[
null
,
null
],
[
0
,
new
Int64Value
()],
[
5.5
,
new
Int64Value
([
"value"
=>
5
])],
// Test conversion from float to int
]],
[
TestWrapperSetters
::
class
,
UInt64Value
::
class
,
"setUInt64Value"
,
"setUInt64Value
Value"
,
"getUInt64Value"
,
"getUInt64ValueValue
"
,
[
[
TestWrapperSetters
::
class
,
UInt64Value
::
class
,
"setUInt64Value"
,
"setUInt64Value
Unwrapped"
,
"getUInt64Value"
,
"getUInt64ValueUnwrapped
"
,
[
[
123
,
new
UInt64Value
([
"value"
=>
123
])],
[
789
,
new
UInt64Value
([
"value"
=>
789
])],
[
null
,
null
],
...
...
@@ -87,14 +87,14 @@ class WrapperTypeSettersTest extends TestBase
[
5.5
,
new
UInt64Value
([
"value"
=>
5
])],
// Test conversion from float to int
[
-
7
,
new
UInt64Value
([
"value"
=>
-
7
])],
// Test conversion from -ve to +ve
]],
[
TestWrapperSetters
::
class
,
Int32Value
::
class
,
"setInt32Value"
,
"setInt32Value
Value"
,
"getInt32Value"
,
"getInt32ValueValue
"
,
[
[
TestWrapperSetters
::
class
,
Int32Value
::
class
,
"setInt32Value"
,
"setInt32Value
Unwrapped"
,
"getInt32Value"
,
"getInt32ValueUnwrapped
"
,
[
[
123
,
new
Int32Value
([
"value"
=>
123
])],
[
-
789
,
new
Int32Value
([
"value"
=>
-
789
])],
[
null
,
null
],
[
0
,
new
Int32Value
()],
[
5.5
,
new
Int32Value
([
"value"
=>
5
])],
// Test conversion from float to int
]],
[
TestWrapperSetters
::
class
,
UInt32Value
::
class
,
"setUInt32Value"
,
"setUInt32Value
Value"
,
"getUInt32Value"
,
"getUInt32ValueValue
"
,
[
[
TestWrapperSetters
::
class
,
UInt32Value
::
class
,
"setUInt32Value"
,
"setUInt32Value
Unwrapped"
,
"getUInt32Value"
,
"getUInt32ValueUnwrapped
"
,
[
[
123
,
new
UInt32Value
([
"value"
=>
123
])],
[
789
,
new
UInt32Value
([
"value"
=>
789
])],
[
null
,
null
],
...
...
@@ -102,12 +102,12 @@ class WrapperTypeSettersTest extends TestBase
[
5.5
,
new
UInt32Value
([
"value"
=>
5
])],
// Test conversion from float to int
[
-
7
,
new
UInt32Value
([
"value"
=>
-
7
])],
// Test conversion from -ve to +ve
]],
[
TestWrapperSetters
::
class
,
BoolValue
::
class
,
"setBoolValue"
,
"setBoolValue
Value"
,
"getBoolValue"
,
"getBoolValueValue
"
,
[
[
TestWrapperSetters
::
class
,
BoolValue
::
class
,
"setBoolValue"
,
"setBoolValue
Unwrapped"
,
"getBoolValue"
,
"getBoolValueUnwrapped
"
,
[
[
true
,
new
BoolValue
([
"value"
=>
true
])],
[
false
,
new
BoolValue
([
"value"
=>
false
])],
[
null
,
null
],
]],
[
TestWrapperSetters
::
class
,
StringValue
::
class
,
"setStringValue"
,
"setStringValue
Value"
,
"getStringValue"
,
"getStringValueValue
"
,
[
[
TestWrapperSetters
::
class
,
StringValue
::
class
,
"setStringValue"
,
"setStringValue
Unwrapped"
,
"getStringValue"
,
"getStringValueUnwrapped
"
,
[
[
"asdf"
,
new
StringValue
([
"value"
=>
"asdf"
])],
[
""
,
new
StringValue
([
"value"
=>
""
])],
[
null
,
null
],
...
...
@@ -117,7 +117,7 @@ class WrapperTypeSettersTest extends TestBase
[
-
7
,
new
StringValue
([
"value"
=>
"-7"
])],
// Test conversion from number to string
[
-
7.5
,
new
StringValue
([
"value"
=>
"-7.5"
])],
// Test conversion from number to string
]],
[
TestWrapperSetters
::
class
,
BytesValue
::
class
,
"setBytesValue"
,
"setBytesValue
Value"
,
"getBytesValue"
,
"getBytesValueValue
"
,
[
[
TestWrapperSetters
::
class
,
BytesValue
::
class
,
"setBytesValue"
,
"setBytesValue
Unwrapped"
,
"getBytesValue"
,
"getBytesValueUnwrapped
"
,
[
[
"asdf"
,
new
BytesValue
([
"value"
=>
"asdf"
])],
[
""
,
new
BytesValue
([
"value"
=>
""
])],
[
null
,
null
],
...
...
@@ -127,12 +127,12 @@ class WrapperTypeSettersTest extends TestBase
[
-
7
,
new
BytesValue
([
"value"
=>
"-7"
])],
// Test conversion from number to bytes
[
-
7.5
,
new
BytesValue
([
"value"
=>
"-7.5"
])],
// Test conversion from number to bytes
]],
[
TestWrapperSetters
::
class
,
DoubleValue
::
class
,
"setDoubleValueOneof"
,
"setDoubleValueOneof
Value"
,
"getDoubleValueOneof"
,
"getDoubleValueOneofValue
"
,
[
[
TestWrapperSetters
::
class
,
DoubleValue
::
class
,
"setDoubleValueOneof"
,
"setDoubleValueOneof
Unwrapped"
,
"getDoubleValueOneof"
,
"getDoubleValueOneofUnwrapped
"
,
[
[
1.1
,
new
DoubleValue
([
"value"
=>
1.1
])],
[
2.2
,
new
DoubleValue
([
"value"
=>
2.2
])],
[
null
,
null
],
[
0
,
new
DoubleValue
()],
]],[
TestWrapperSetters
::
class
,
StringValue
::
class
,
"setStringValueOneof"
,
"setStringValueOneof
Value"
,
"getStringValueOneof"
,
"getStringValueOneofValue
"
,
[
]],[
TestWrapperSetters
::
class
,
StringValue
::
class
,
"setStringValueOneof"
,
"setStringValueOneof
Unwrapped"
,
"getStringValueOneof"
,
"getStringValueOneofUnwrapped
"
,
[
[
"asdf"
,
new
StringValue
([
"value"
=>
"asdf"
])],
[
""
,
new
StringValue
([
"value"
=>
""
])],
[
null
,
null
],
...
...
@@ -157,47 +157,47 @@ class WrapperTypeSettersTest extends TestBase
public
function
invalidSettersDataProvider
()
{
return
[
[
TestWrapperSetters
::
class
,
"setDoubleValue
Value
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setDoubleValue
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setDoubleValue
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setDoubleValue
Value
"
,
new
DoubleValue
()],
[
TestWrapperSetters
::
class
,
"setDoubleValue
Unwrapped
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setDoubleValue
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setDoubleValue
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setDoubleValue
Unwrapped
"
,
new
DoubleValue
()],
[
TestWrapperSetters
::
class
,
"setFloatValue
Value
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setFloatValue
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setFloatValue
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setFloatValue
Value
"
,
new
FloatValue
()],
[
TestWrapperSetters
::
class
,
"setFloatValue
Unwrapped
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setFloatValue
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setFloatValue
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setFloatValue
Unwrapped
"
,
new
FloatValue
()],
[
TestWrapperSetters
::
class
,
"setInt64Value
Value
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setInt64Value
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setInt64Value
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setInt64Value
Value
"
,
new
Int64Value
()],
[
TestWrapperSetters
::
class
,
"setInt64Value
Unwrapped
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setInt64Value
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setInt64Value
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setInt64Value
Unwrapped
"
,
new
Int64Value
()],
[
TestWrapperSetters
::
class
,
"setUInt64Value
Value
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setUInt64Value
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setUInt64Value
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setUInt64Value
Value
"
,
new
UInt64Value
()],
[
TestWrapperSetters
::
class
,
"setUInt64Value
Unwrapped
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setUInt64Value
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setUInt64Value
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setUInt64Value
Unwrapped
"
,
new
UInt64Value
()],
[
TestWrapperSetters
::
class
,
"setInt32Value
Value
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setInt32Value
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setInt32Value
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setInt32Value
Value
"
,
new
Int32Value
()],
[
TestWrapperSetters
::
class
,
"setInt32Value
Unwrapped
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setInt32Value
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setInt32Value
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setInt32Value
Unwrapped
"
,
new
Int32Value
()],
[
TestWrapperSetters
::
class
,
"setUInt32Value
Value
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setUInt32Value
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setUInt32Value
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setUInt32Value
Value
"
,
new
UInt32Value
()],
[
TestWrapperSetters
::
class
,
"setUInt32Value
Unwrapped
"
,
"abc"
],
[
TestWrapperSetters
::
class
,
"setUInt32Value
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setUInt32Value
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setUInt32Value
Unwrapped
"
,
new
UInt32Value
()],
[
TestWrapperSetters
::
class
,
"setBoolValue
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setBoolValue
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setBoolValue
Value
"
,
new
BoolValue
()],
[
TestWrapperSetters
::
class
,
"setBoolValue
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setBoolValue
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setBoolValue
Unwrapped
"
,
new
BoolValue
()],
[
TestWrapperSetters
::
class
,
"setStringValue
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setStringValue
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setStringValue
Value
"
,
new
StringValue
()],
[
TestWrapperSetters
::
class
,
"setStringValue
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setStringValue
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setStringValue
Unwrapped
"
,
new
StringValue
()],
[
TestWrapperSetters
::
class
,
"setBytesValue
Value
"
,
[]],
[
TestWrapperSetters
::
class
,
"setBytesValue
Value
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setBytesValue
Value
"
,
new
BytesValue
()],
[
TestWrapperSetters
::
class
,
"setBytesValue
Unwrapped
"
,
[]],
[
TestWrapperSetters
::
class
,
"setBytesValue
Unwrapped
"
,
new
stdClass
()],
[
TestWrapperSetters
::
class
,
"setBytesValue
Unwrapped
"
,
new
BytesValue
()],
];
}
...
...
src/google/protobuf/compiler/php/php_generator.cc
View file @
54288a01
...
...
@@ -678,14 +678,14 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor,
field
->
name
());
}
// For wrapper types, generate an additional getXXX
Value
getter
// For wrapper types, generate an additional getXXX
Unwrapped
getter
if
(
!
field
->
is_map
()
&&
!
field
->
is_repeated
()
&&
field
->
cpp_type
()
==
FieldDescriptor
::
CPPTYPE_MESSAGE
&&
IsWrapperType
(
field
))
{
GenerateWrapperFieldGetterDocComment
(
printer
,
field
);
printer
->
Print
(
"public function get^camel_name^
Value
()
\n
"
"public function get^camel_name^
Unwrapped
()
\n
"
"{
\n
"
" $wrapper = $this->get^camel_name^();
\n
"
" return is_null($wrapper) ? null : $wrapper->getValue();
\n
"
...
...
@@ -798,7 +798,7 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor,
IsWrapperType
(
field
))
{
GenerateWrapperFieldSetterDocComment
(
printer
,
field
);
printer
->
Print
(
"public function set^camel_name^
Value
($var)
\n
"
"public function set^camel_name^
Unwrapped
($var)
\n
"
"{
\n
"
" $wrappedVar = is_null($var) ? null : new
\\
^wrapper_type^(['value' => $var]);
\n
"
" return $this->set^camel_name^($wrappedVar);
\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