File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
tests/src/integration/defaults Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ impl<'a> Arg<'a> {
168
168
)
169
169
. ok_or ( Error :: InvalidCString ) ?,
170
170
default_value : match & self . default_value {
171
+ Some ( val) if val. as_str ( ) == "None" => CString :: new ( "null" ) ?. into_raw ( ) ,
171
172
Some ( val) => CString :: new ( val. as_str ( ) ) ?. into_raw ( ) ,
172
173
None => ptr:: null ( ) ,
173
174
} ,
Original file line number Diff line number Diff line change 4
4
assert (test_defaults_integer (12 ) === 12 );
5
5
assert (test_defaults_nullable_string () === null );
6
6
assert (test_defaults_nullable_string ('test ' ) === 'test ' );
7
+ assert (test_defaults_multiple_option_arguments () === 'Default ' );
8
+ assert (test_defaults_multiple_option_arguments (a: 'a ' ) === 'a ' );
9
+ assert (test_defaults_multiple_option_arguments (b: 'b ' ) === 'b ' );
Original file line number Diff line number Diff line change @@ -12,10 +12,20 @@ pub fn test_defaults_nullable_string(a: Option<String>) -> Option<String> {
12
12
a
13
13
}
14
14
15
+ #[ php_function]
16
+ #[ php( defaults( a = None , b = None ) ) ]
17
+ pub fn test_defaults_multiple_option_arguments (
18
+ a : Option < String > ,
19
+ b : Option < String > ,
20
+ ) -> PhpResult < String > {
21
+ Ok ( a. or ( b) . unwrap_or_else ( || "Default" . to_string ( ) ) )
22
+ }
23
+
15
24
pub fn build_module ( builder : ModuleBuilder ) -> ModuleBuilder {
16
25
builder
17
26
. function ( wrap_function ! ( test_defaults_integer) )
18
27
. function ( wrap_function ! ( test_defaults_nullable_string) )
28
+ . function ( wrap_function ! ( test_defaults_multiple_option_arguments) )
19
29
}
20
30
21
31
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments