spatie / fractalistic

A framework agnostic, developer friendly wrapper around Fractal
https://freek.dev/644-a-developer-friendly-wrapper-around-fractal
MIT License
382 stars 32 forks source link

Replacing docblocks with type hints #67

Closed shahlin closed 1 year ago

shahlin commented 1 year ago

Hey, I was wondering if the docblocks in Fractal.php can be replaced with typehints. Example:

Change:

class Fractal implements JsonSerializable
{
    /** @var \League\Fractal\Manager */
    protected $manager;

    /** @var int */
    protected $recursionLimit = 10;

    /** @var string|\League\Fractal\Serializer\SerializerAbstract */
    protected $serializer;

    /** @var string|callable|\League\Fractal\TransformerAbstract */
    protected $transformer;

    /** @var \League\Fractal\Pagination\PaginatorInterface */
    protected $paginator;

    /** @var \League\Fractal\Pagination\CursorInterface */
    protected $cursor;

    /** @var array */
    protected $includes = [];

To:

class Fractal implements JsonSerializable
{
    protected Manager $manager;

    protected int $recursionLimit = 10;

    /** @var string|\League\Fractal\Serializer\SerializerAbstract */
    protected SerializerAbstract $serializer;

    /** @var string|callable|\League\Fractal\TransformerAbstract */
    protected $transformer;

    protected PaginatorInterface $paginator;

    protected CursorInterface $cursor;

    protected array $includes = [];

Would it also make sense to drop PHP 7.4 support for this and add union types where necessary?

Happy to work on the PR for this!

freekmurze commented 1 year ago

Sure, feel free to send a PR 👍