Skip to content

Commit f6dee97

Browse files
committed
handle case with throws from ArrayDenormalizer
1 parent c23a29b commit f6dee97

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

Lines 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

Lines 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

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy