Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f6dee97

Browse filesBrowse files
committed
handle case with throws from ArrayDenormalizer
1 parent c23a29b commit f6dee97
Copy full SHA for f6dee97

File tree

3 files changed

+8
-2
lines changed
Filter options

3 files changed

+8
-2
lines changed

‎src/Symfony/Component/Serializer/Exception/InvalidArgumentException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Exception/InvalidArgumentException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
*
1717
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
1818
*/
19-
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
19+
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface, AggregableExceptionInterface
2020
{
2121
}

‎src/Symfony/Component/Serializer/Tests/Fixtures/CollectErrorsDummy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Fixtures/CollectErrorsDummy.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class CollectErrorsDummy
1919
*/
2020
public $arrayOfObjects;
2121

22+
/**
23+
* @var CollectErrorsArrayDummy[]
24+
*/
25+
public $stringArrayOfObjects;
26+
2227
/**
2328
* @var CollectErrorsObjectDummy
2429
*/

‎src/Symfony/Component/Serializer/Tests/SerializerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/SerializerTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,12 +640,13 @@ public function testDeserializeAndUnwrap()
640640

641641
public function testCollectDenormalizationErrors()
642642
{
643-
$jsonData = '{"int":"string","array":"string","arrayOfObjects":[{"date":"string"}],"object":{"foo":"1","bar":"1"},"variadicObject":{"foo":1,"args":[{"foo":"1"},{"foo":"1","args":1}]}}';
643+
$jsonData = '{"int":"string","array":"string","arrayOfObjects":[{"date":"string"}],"stringArrayOfObjects":"string","object":{"foo":"1","bar":"1"},"variadicObject":{"foo":1,"args":[{"foo":"1"},{"foo":"1","args":1}]}}';
644644

645645
$expected = static function () {
646646
yield 'int' => 'The type of the "int" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\CollectErrorsDummy" must be one of "int" ("string" given).';
647647
yield 'array' => 'The type of the "array" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\CollectErrorsDummy" must be one of "array" ("string" given).';
648648
yield 'arrayOfObjects.date' => 'DateTimeImmutable::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database';
649+
yield 'stringArrayOfObjects' => 'Data expected to be an array, string given.';
649650
yield 'object.foo' => 'The type of the "foo" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\CollectErrorsObjectDummy" must be one of "int" ("string" given).';
650651
yield 'object.bar' => 'The type of the "bar" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\CollectErrorsObjectDummy" must be one of "int" ("string" given).';
651652
yield 'object.baz' => 'Cannot create an instance of "Symfony\Component\Serializer\Tests\Fixtures\CollectErrorsObjectDummy" from serialized data because its constructor requires parameter "baz" to be present.';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.