Larastan: Failed to recognise Laravels Macro functions

Created on 6 May 2020  路  5Comments  路  Source: nunomaduro/larastan

  • Laravel Version: 7.10.2
  • Larastan Version: 0.5.7
  • --level 5 used: (but already breaks on --level 2

Description

Since upgrading to v0.5.5 => v0.5.7 it seems it doesn't recognise Laravels Macro functionality and returns the below error.

 ------ ------------------------------------------------------------------ 
  Line   Exceptions/Handler.php                                            
 ------ ------------------------------------------------------------------ 
  51     Call to an undefined method                                       
         Illuminate\Contracts\Routing\ResponseFactory::unauthenticated().  
  54     Call to an undefined method                                       
         Illuminate\Contracts\Routing\ResponseFactory::unauthenticated().  
  57     Call to an undefined method                                       
         Illuminate\Contracts\Routing\ResponseFactory::notFound().         
  63     Call to an undefined method                                       
         Illuminate\Contracts\Routing\ResponseFactory::tooManyRequests().  
 ------ ------------------------------------------------------------------ 

Laravel code where the issue was found

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Response;
use Illuminate\Support\ServiceProvider;

class ResponseServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     */
    public function boot(): void
    {
        Response::macro('noContent', function () {
            return Response::json('', 204);
        });

        Response::macro('deleted', function () {
            return Response::noContent();
        });

        Response::macro('resetContent', function () {
            return Response::json([], 205);
        });
    }

    /**
     * Register the application services.
     */
    public function register(): void
    {
        //
    }
}
bug

Most helpful comment

Hi,

This might be fixed with #570 Can you try with the master branch and see if the issue still continues?

All 5 comments

Thank you for your report.

Could you retry with yesterday's release? https://github.com/nunomaduro/larastan/releases

@nunomaduro Is it really a Draft release?

@szepeviktor Yeah, it's still a draft. It's not released yet.

But I doubt the new release will fix these macro issues. We have to take a look at it.

Hi,

This might be fixed with #570 Can you try with the master branch and see if the issue still continues?

The master branch fixed this issue :)! Looking forward to 0.5.9! Thank you very much. This is 1 of my favorite packages which makes code cleanup fun in a game-like way.

Thank you for kind words! Glad it fixed the issue.

BTW, the next version will be 0.6 Because there might be some small breaking changes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fico7489 picture fico7489  路  3Comments

hailwood picture hailwood  路  4Comments

fgilio picture fgilio  路  4Comments

iNviNho picture iNviNho  路  3Comments

JeroenVanOort picture JeroenVanOort  路  3Comments