File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function getParameters(
24
24
25
25
foreach ($ parameters as $ index => $ parameter ) {
26
26
\assert ($ parameter instanceof \ReflectionParameter);
27
- if ($ parameter ->isOptional ()) {
27
+ if ($ parameter ->isDefaultValueAvailable ()) {
28
28
try {
29
29
$ resolvedParameters [$ index ] = $ parameter ->getDefaultValue ();
30
30
} catch (ReflectionException $ e ) {
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ public function should_invoke_callable_with_null_for_nullable_parameters()
192
192
}
193
193
194
194
/**
195
+ * @see https://github.com/PHP-DI/Slim-Bridge/issues/37
195
196
* @test
196
197
*/
197
198
public function should_invoke_callable_with_null_for_non_optional_nullable_parameters ()
@@ -203,6 +204,21 @@ public function should_invoke_callable_with_null_for_non_optional_nullable_param
203
204
$ this ->assertNull ($ result );
204
205
}
205
206
207
+ /**
208
+ * @see https://github.com/PHP-DI/PHP-DI/issues/562
209
+ * @test
210
+ */
211
+ public function should_invoke_callable_with_optional_parameter_before_required_parameter ()
212
+ {
213
+ $ result = $ this ->invoker ->call (function ($ baz = 'abc ' , $ foo ) {
214
+ return [$ baz , $ foo ];
215
+ }, [
216
+ 'foo ' => 'bar ' ,
217
+ ]);
218
+
219
+ $ this ->assertSame (['abc ' , 'bar ' ], $ result );
220
+ }
221
+
206
222
/**
207
223
* @test
208
224
*/
You can’t perform that action at this time.
0 commit comments