You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (1 === \count($keys) && '[]' === substr($keys[0], -2)) {
752
-
thrownewInvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but one of the elements is of type "%s".', $option, $this->formatValue($value), implode('" or "', $this->allowedTypes[$option]), $keys[0]));
760
+
if (is_array($value) && $allowedContainsArrayType) {
761
+
thrownewInvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but one of the elements is of type "%s".', $option, $fmtActualValue, $fmtAllowedTypes, $fmtProvidedTypes));
753
762
}
754
763
755
-
thrownewInvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but is of type "%s".', $option, $this->formatValue($value), implode('" or "', $this->allowedTypes[$option]), implode('|', array_keys($invalidTypes))));
764
+
thrownewInvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but is of type "%s".', $option, $fmtActualValue, $fmtAllowedTypes, $fmtProvidedTypes));
756
765
}
757
766
}
758
767
@@ -852,43 +861,43 @@ private function verifyTypes($type, $value, array &$invalidTypes)
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "stdClass[]".
510
+
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "stdClass|array|DateTime".
@@ -569,6 +570,11 @@ public function provideInvalidTypes()
569
570
[42, 'string', 'The option "option" with value 42 is expected to be of type "string", but is of type "integer".'],
570
571
[null, 'string', 'The option "option" with value null is expected to be of type "string", but is of type "NULL".'],
571
572
['bar', '\stdClass', 'The option "option" with value "bar" is expected to be of type "\stdClass", but is of type "string".'],
573
+
[['foo', 12], 'string[]', 'The option "option" with value array is expected to be of type "string[]", but one of the elements is of type "integer".'],
574
+
[123, ['string[]', 'string'], 'The option "option" with value 123 is expected to be of type "string[]" or "string", but is of type "integer".'],
575
+
[[null], ['string[]', 'string'], 'The option "option" with value array is expected to be of type "string[]" or "string", but one of the elements is of type "NULL".'],
576
+
[['string', null], ['string[]', 'string'], 'The option "option" with value array is expected to be isValueValidTypeof type "string[]" or "string", but one of the elements is of type "NULL".'],
577
+
[[\stdClass::class], ['string'], 'The option "option" with value array is expected to be of type "string", but is of type "array".'],
572
578
];
573
579
}
574
580
@@ -619,6 +625,7 @@ public function testResolveSucceedsIfTypedArray()
619
625
new \DateTime(),
620
626
],
621
627
];
628
+
622
629
$result = $this->resolver->resolve($data);
623
630
$this->assertEquals($data, $result);
624
631
}
@@ -1637,7 +1644,7 @@ public function testNested2Arrays()
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "integer[][][][]".
1647
+
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "integer".
1641
1648
*/
1642
1649
publicfunctiontestNestedArraysException()
1643
1650
{
@@ -1659,7 +1666,7 @@ public function testNestedArraysException()
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean[][]".
1669
+
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean|string|array".
1663
1670
*/
1664
1671
publicfunctiontestNestedArrayException1()
1665
1672
{
@@ -1674,7 +1681,7 @@ public function testNestedArrayException1()
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean[][]".
1684
+
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean|string|array".
1678
1685
*/
1679
1686
publicfunctiontestNestedArrayException2()
1680
1687
{
@@ -1689,7 +1696,7 @@ public function testNestedArrayException2()
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string[][]".
1699
+
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string|integer".
1693
1700
*/
1694
1701
publicfunctiontestNestedArrayException3()
1695
1702
{
@@ -1704,7 +1711,7 @@ public function testNestedArrayException3()
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "integer[][][]".
1714
+
* @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "integer".
1708
1715
*/
1709
1716
publicfunctiontestNestedArrayException4()
1710
1717
{
@@ -1720,7 +1727,7 @@ public function testNestedArrayException4()
0 commit comments