Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getSupportedTypes(?string $format): array
*/
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): array
{
if (null === $this->denormalizer) {
if (!isset($this->denormalizer)) {
throw new BadMethodCallException('Please set a denormalizer before calling denormalize()!');
}
if (!\is_array($data)) {
Expand Down Expand Up @@ -72,7 +72,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a

public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
{
if (null === $this->denormalizer) {
if (!isset($this->denormalizer)) {
throw new BadMethodCallException(sprintf('The nested denormalizer needs to be set to allow "%s()" to be used.', __METHOD__));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ public function testSupportsNoArray()
)
);
}

public function testDenormalizeWithoutDenormalizer()
{
$arrayDenormalizer = new ArrayDenormalizer();

$this->expectException(\BadMethodCallException::class);
$arrayDenormalizer->denormalize([], 'string[]');
}

public function testSupportsDenormalizationWithoutDenormalizer()
{
$arrayDenormalizer = new ArrayDenormalizer();

$this->expectException(\BadMethodCallException::class);
$arrayDenormalizer->supportsDenormalization([], 'string[]');
}
}

class ArrayDummy
Expand Down