Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/InvalidDeserializedData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Lendable\Json;

class InvalidDeserializedData extends \RuntimeException implements Failure
final class InvalidDeserializedData extends \RuntimeException implements Failure
{
public function __construct(string $unexpectedType)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
final readonly class Serializer
{
/**
* @phpstan-param array<mixed> $data
* @param array<mixed> $data
*
* @throws SerializationFailed
*/
Expand All @@ -26,7 +26,7 @@ public function serialize(array $data): string
* @throws DeserializationFailed
* @throws InvalidDeserializedData
*
* @phpstan-return array<mixed>
* @return array<mixed>
*/
public function deserialize(string $json): array
{
Expand All @@ -37,7 +37,7 @@ public function deserialize(string $json): array
}

if (!\is_array($data)) {
throw new InvalidDeserializedData(\gettype($data));
throw new InvalidDeserializedData(\get_debug_type($data));
}

return $data;
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ public function it_throws_when_deserializing_if_the_result_is_not_an_array(strin
*/
public static function provideNonArrayRoots(): iterable
{
yield 'true' => ['true', 'boolean'];
yield 'false' => ['false', 'boolean'];
yield 'null' => ['null', 'NULL'];
yield 'integer' => ['5', 'integer'];
yield 'float' => ['1.5', 'double'];
yield 'true' => ['true', 'bool'];
yield 'false' => ['false', 'bool'];
yield 'null' => ['null', 'null'];
yield 'integer' => ['5', 'int'];
yield 'float' => ['1.5', 'float'];
yield 'string' => ['"foo"', 'string'];
}

Expand Down
Loading