Add PHPStan stub for ResponseFactory::image() macro#28
Open
k1rana wants to merge 1 commit intoIntervention:developfrom
Open
Add PHPStan stub for ResponseFactory::image() macro#28k1rana wants to merge 1 commit intoIntervention:developfrom
k1rana wants to merge 1 commit intoIntervention:developfrom
Conversation
Adds a PHPStan stub file and extension.neon to resolve Larastan reporting 'Call to an undefined method' for the image() response macro registered at runtime by the ServiceProvider. Fixes Intervention#24
olivervogel
requested changes
Mar 9, 2026
Member
olivervogel
left a comment
There was a problem hiding this comment.
Thank you. I wonder if this could be solved more easily with a hint in a comment without having to go through phpstan. I also have a few questions.
Member
There was a problem hiding this comment.
The name of this file is very ambiguous. Could you make it more clear, that this file belongs to phpstan?
| "Image": "Intervention\\Image\\Laravel\\Facades\\Image" | ||
| } | ||
| }, | ||
| "phpstan": { |
Member
There was a problem hiding this comment.
I wonder if this will cause problems, since phpstan is part of the dependencies. Also: Where is It's included in phpstan defined in the composer.json schema? I can't find anything about it.extra, I missed that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #24
Larastan reports
Call to an undefined method Illuminate\Contracts\Routing\ResponseFactory::image()because theimage()macro is registered at runtime viaServiceProvider::boot(), which static analysis tools cannot detect.This PR adds a PHPStan stub and extension config so PHPStan/Larastan recognizes the
image()method on ResponseFactoryChanges
stubs/ResponseFactory.stub— Declaresimage()via@methodPHPDoc onIlluminate\Contracts\Routing\ResponseFactory, matching the macro signature inServiceProvider.phpextra.phpstan.includesfor auto-discovery (zero user config needed)Verification
Expected Result