Skip to content

Commit

Permalink
fix: add static types to Serializer facade
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed Jun 19, 2024
1 parent 1578cd9 commit 434e73b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
16 changes: 11 additions & 5 deletions config/serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

declare(strict_types=1);

use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
use WayOfDev\Serializer\Contracts\EncoderRegistrationStrategy;
use WayOfDev\Serializer\Contracts\NormalizerRegistrationStrategy;
use WayOfDev\Serializer\DefaultEncoderRegistrationStrategy;
use WayOfDev\Serializer\DefaultNormalizerRegistrationStrategy;

/**
* @return array{
* default: string,
* debug: bool,
* normalizerRegistrationStrategy: class-string<WayOfDev\Serializer\Contracts\NormalizerRegistrationStrategy>,
* encoderRegistrationStrategy: class-string<WayOfDev\Serializer\Contracts\EncoderRegistrationStrategy>,
* metadataLoader: class-string<Symfony\Component\Serializer\Mapping\Loader\LoaderInterface>|null,
* normalizerRegistrationStrategy: class-string<NormalizerRegistrationStrategy>,
* encoderRegistrationStrategy: class-string<EncoderRegistrationStrategy>,
* metadataLoader: class-string<LoaderInterface>|null,
* }
*/
return [
Expand Down Expand Up @@ -38,7 +44,7 @@
* Allows you to specify the strategy class for registering your normalizers.
* Default is 'WayOfDev\Serializer\DefaultNormalizerRegistrationStrategy'.
*/
'normalizerRegistrationStrategy' => WayOfDev\Serializer\DefaultNormalizerRegistrationStrategy::class,
'normalizerRegistrationStrategy' => DefaultNormalizerRegistrationStrategy::class,

/*
* Allows you to register your custom encoders.
Expand All @@ -53,7 +59,7 @@
* You can replace the default encoders with your custom ones by implementing
* your own registration strategy.
*/
'encoderRegistrationStrategy' => WayOfDev\Serializer\DefaultEncoderRegistrationStrategy::class,
'encoderRegistrationStrategy' => DefaultEncoderRegistrationStrategy::class,

/*
* Allows you to register your custom metadata loader.
Expand Down
18 changes: 18 additions & 0 deletions src/Bridge/Laravel/Facades/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,26 @@

namespace WayOfDev\Serializer\Bridge\Laravel\Facades;

use ArrayObject;
use Illuminate\Support\Facades\Facade;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

/**
* @method static string serialize(mixed $data, string $format, array $context = [])
* @method static mixed deserialize(string $data, string $type, string $format, array $context = [])
* @method static array|string|int|float|bool|ArrayObject|null normalize(mixed $data, string $format, array $context = [])
* @method static mixed denormalize(mixed $data, string $type, ?string $format = null, array $context = [])
* @method static array getSupportedTypes(?string $format)
* @method static bool supportsNormalization(mixed $data, ?string $format = null, array $context = [])
* @method static bool supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = [])
* @method static NormalizerInterface|null getNormalizer(mixed $data, ?string $format, array $context)
* @method static DenormalizerInterface|null getDenormalizer(mixed $data, string $type, ?string $format, array $context)
* @method static string encode(mixed $data, string $format, array $context = [])
* @method static mixed decode(string $data, string $type, string $format, array $context = [])
* @method static bool supportsEncoding(string $format, array $context = [])
* @method static bool supportsDecoding(string $format, array $context = [])
*/
class Serializer extends Facade
{
protected static function getFacadeAccessor(): string
Expand Down

0 comments on commit 434e73b

Please sign in to comment.