Skip to content

Call to undefined method detected by Larastan #24

@k1rana

Description

@k1rana

Describe the bug
Larastan reports a “Call to an undefined method” error on a class or interface that doesn’t natively provide that method.

 ------ ------------------------------------------------------------------------------------ 
  Line   Http/Controllers/Image/ImageController.php                                          
 ------ ------------------------------------------------------------------------------------ 
  :82    Call to an undefined method Illuminate\Contracts\Routing\ResponseFactory::image().  
         🪪  method.notFound                                                                 
 ------ ------------------------------------------------------------------------------------ 

Code Example
Yeah, simply add this to controller.

return response()->image(
    $image,
    $format,
    quality: 90,
);

Expected behavior
PHPStan/Larastan should recognize dynamically added methods if properly documented.

Images
Image

Environment :

  • PHP Version: PHP 8.3.21 (cli) (built: May 21 2025 23:17:35) (NTS)
  • OS: MacOS 15.4.1 (24E263)
  • Intervention Image Version: 1.5.6
  • GD or Imagick: GD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions