Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong PHPDoc info for HasDownload::downloadResponseCallback #6670

Closed
alies-dev opened this issue Jan 15, 2025 · 1 comment
Closed

Wrong PHPDoc info for HasDownload::downloadResponseCallback #6670

alies-dev opened this issue Jan 15, 2025 · 1 comment
Labels
bug Verified bug by the Nova team fix incoming A fix is in review
Milestone

Comments

@alies-dev
Copy link

alies-dev commented Jan 15, 2025

  • Nova Version: latest 4, also v5.1.0

Description:

from \Laravel\Nova\Fields\HasDownload

    /**
     * The callback used to generate the download HTTP response.
     *
-    * @var (callable(\Laravel\Nova\Http\Requests\NovaRequest, \Laravel\Nova\Resource, ?string, ?string):(mixed))|null
+    * @var (callable(\Laravel\Nova\Http\Requests\NovaRequest, \Illuminate\Database\Eloquent\Model, ?string, ?string):(\Symfony\Component\HttpFoundation\Response|null)
     */
    public $downloadResponseCallback;

    /**
     * Specify the callback that should be used to create a download HTTP response.
     *
-    * @param  callable(\Laravel\Nova\Http\Requests\NovaRequest, \Laravel\Nova\Resource, ?string, ?string):mixed  $downloadResponseCallback
+    * @param  callable(\Laravel\Nova\Http\Requests\NovaRequest, \Illuminate\Database\Eloquent\Model, ?string, ?string):(\Symfony\Component\HttpFoundation\Response|null)  $downloadResponseCallback 
     * @return $this
     */
    public function download(callable $downloadResponseCallback)
    {
        $this->downloadResponseCallback = $downloadResponseCallback;

        return $this;
    }

The only place where downloadResponseCallback called is \Laravel\Nova\Fields\HasDownload::toDownloadResponse():

    /**
     * Create an HTTP response to download the underlying field.
     */
    public function toDownloadResponse(NovaRequest $request, Resource $resource): Response|StreamedResponse
    {
        return call_user_func(
            $this->downloadResponseCallback,
            $request,
            $resource->resource,
            $this->getStorageDisk(),
            $this->getStoragePath()
        );
    }

It will be also nice to utilize more generics syntax for Psalm/PHPStan, but it will be nice to have at least this minor fix

@crynobone crynobone added bug Verified bug by the Nova team fix incoming A fix is in review labels Jan 15, 2025
@crynobone crynobone added this to the 5.1.x milestone Jan 15, 2025
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified bug by the Nova team fix incoming A fix is in review
Projects
None yet
Development

No branches or pull requests

2 participants