Skip to content

Commit 530d80a

Browse files
committed
GreetingInputDenormalizer.php
Try to avoid "Call to function is_array() with array will always evaluate to true."
1 parent cd9c883 commit 530d80a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

code_samples/api/rest_api/src/Rest/Serializer/GreetingInputDenormalizer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
2626

2727
public function supportsDenormalization(mixed $data, string $type, ?string $format = null): bool
2828
{
29+
if (!is_array($data)) {
30+
return false;
31+
}
32+
2933
if ('json' === $format) {
3034
$data = $data[array_key_first($data)];
3135
}
3236
$data = array_change_key_case($data);
3337

34-
return Greeting::class === $type && is_array($data) &&
38+
return Greeting::class === $type &&
3539
(array_key_exists('salutation', $data) || array_key_exists('recipient', $data));
3640
}
3741
}

0 commit comments

Comments
 (0)