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> {
168168 )
169169 . ok_or ( Error :: InvalidCString ) ?,
170170 default_value : match & self . default_value {
171+ Some ( val) if val. as_str ( ) == "None" => CString :: new ( "null" ) ?. into_raw ( ) ,
171172 Some ( val) => CString :: new ( val. as_str ( ) ) ?. into_raw ( ) ,
172173 None => ptr:: null ( ) ,
173174 } ,
Original file line number Diff line number Diff line change 44assert (test_defaults_integer (12 ) === 12 );
55assert (test_defaults_nullable_string () === null );
66assert (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> {
1212 a
1313}
1414
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+
1524pub fn build_module ( builder : ModuleBuilder ) -> ModuleBuilder {
1625 builder
1726 . function ( wrap_function ! ( test_defaults_integer) )
1827 . function ( wrap_function ! ( test_defaults_nullable_string) )
28+ . function ( wrap_function ! ( test_defaults_multiple_option_arguments) )
1929}
2030
2131#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments