psalm / psalm-plugin-laravel

A Psalm plugin for Laravel
MIT License
307 stars 72 forks source link

Collection stub. Missing reduce definition #237

Closed Legion112 closed 1 year ago

Legion112 commented 2 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

Legion112 commented 2 years ago

Should be something like that

    /**
     * Reduce the collection to a single value.
     * @template TReturn
     * @template TInit
     * @param  callable(TInit, TValue):TReturn  $callback
     * @param  TInit  $initial
     * @return TReturn
     */
    public function reduce(callable $callback, $initial = null);
alies-dev commented 1 year ago

Hey @Legion112 Which Laravel version do you use? In modern Laravel 9 collections already have right syntax:


    /**
     * Reduce the collection to a single value.
     *
     * @template TReduceInitial
     * @template TReduceReturnType
     *
     * @param  callable(TReduceInitial|TReduceReturnType, TValue, TKey): TReduceReturnType  $callback
     * @param  TReduceInitial  $initial
     * @return TReduceReturnType
     */
    public function reduce(callable $callback, $initial = null);
Legion112 commented 1 year ago

Laravel 6 or something

alies-dev commented 1 year ago

@Legion112

Oh, this is ancient Laravel version. We don't support it anymore, but you are free to create a PR for it. Everything you need:

We will appropriate any help on this repository ❤️

alies-dev commented 1 year ago

closing as outdated (I highly recommend to use a new version 2.5 of the plugin BTW)