File tree 3 files changed +22
-1
lines changed 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -822,7 +822,7 @@ protected function isArrayOfType($strType)
822
822
823
823
/**
824
824
* Returns true if accessor is a method and has only one parameter
825
- * which is variadic.
825
+ * which is variadic ("...$args") .
826
826
*
827
827
* @param ReflectionMethod|ReflectionProperty|null $accessor accessor
828
828
* to set value
Original file line number Diff line number Diff line change @@ -527,6 +527,20 @@ public function testMapArrayFromVariadicFunctionWithObjectType()
527
527
$ this ->assertSame ('2014-01-02 ' , $ variadicArray [0 ]->format ('Y-m-d ' ));
528
528
$ this ->assertSame ('2014-05-07 ' , $ variadicArray [1 ]->format ('Y-m-d ' ));
529
529
}
530
+
531
+ /**
532
+ * Test the "if (count($parameters) !== 1) {" condition in "hasVariadicArrayType()"
533
+ */
534
+ public function testMapArrayVariadicMethodWithMultipleParams ()
535
+ {
536
+ $ jm = new JsonMapper ();
537
+ $ sn = $ jm ->map (
538
+ json_decode ('{"multipleParams":[23]} ' ),
539
+ new JsonMapperTest_VariadicArray ()
540
+ );
541
+
542
+ $ this ->assertSame ([23 ], $ sn ->multipleParamsVal );
543
+ }
530
544
}
531
545
532
546
?>
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ class JsonMapperTest_VariadicArray
30
30
*/
31
31
private $ variadicInt ;
32
32
33
+ public $ multipleParamsVal ;
34
+
33
35
/**
34
36
* @param DateTime[] $items
35
37
*
@@ -69,5 +71,10 @@ public function setVariadicInt(int ...$items): self
69
71
70
72
return $ this ;
71
73
}
74
+
75
+ public function setMultipleParams (array $ param , int ...$ dummy )
76
+ {
77
+ $ this ->multipleParamsVal = $ param ;
78
+ }
72
79
}
73
80
?>
You can’t perform that action at this time.
0 commit comments