File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function getParameters(
2424
2525 foreach ($ parameters as $ index => $ parameter ) {
2626 \assert ($ parameter instanceof \ReflectionParameter);
27- if ($ parameter ->isOptional ()) {
27+ if ($ parameter ->isDefaultValueAvailable ()) {
2828 try {
2929 $ resolvedParameters [$ index ] = $ parameter ->getDefaultValue ();
3030 } 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()
192192 }
193193
194194 /**
195+ * @see https://github.com/PHP-DI/Slim-Bridge/issues/37
195196 * @test
196197 */
197198 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
203204 $ this ->assertNull ($ result );
204205 }
205206
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+
206222 /**
207223 * @test
208224 */
You can’t perform that action at this time.
0 commit comments