Larastan: Call to undefined method loginUsingId()

Created on 29 Apr 2020  Â·  10Comments  Â·  Source: nunomaduro/larastan

  • Larastan Version: 0.5.5
  • --level used: 5

Description

 ------ ----------------------------------------------
  Line   LoginController.php
 ------ ----------------------------------------------
  62     Call to an undefined method
         Illuminate\Auth\AuthManager::loginUsingId().
 ------ ----------------------------------------------

Laravel code where the issue was found

auth()->loginUsingId($user->id);
bug

Most helpful comment

Yep, this looks like a bug. Thanks for reporting @nmfzone

AuthManager has the magic __call method which forwards method calls to guards. We might need a new extension for this behavior.

All 10 comments

Could you try auth()->login($user); ?

@szepeviktor Ah nice solution. But how about that?
I know maybe it's weird, since we already had a $user. But, it's should works, right?

[Update]
Your solution isn't working, still got undefined method.

May not be related, but make sure you update for the latest version.

@nunomaduro Yeah, updated to the latest version. Still the same.

For anyone who faced this issue, maybe we can just ignore those error for now:

phpstan.neon

parameters:
    ignoreErrors:
        - '#Call to an undefined method Illuminate\Auth\AuthManager::login()#'
        - '#Call to an undefined method Illuminate\Auth\AuthManager::loginUsingId()#'

Yep, this looks like a bug. Thanks for reporting @nmfzone

AuthManager has the magic __call method which forwards method calls to guards. We might need a new extension for this behavior.

@canvural Sure, thanks. Keep a good work guys âš¡

I am not sure if it is related to the fix:
I am on v0.5.8
It is not working properly when auth() helper is called for a custom guard.
For example, I have a custom guard 'employee' and the model is Employee which has the function latest_pending_leave_request.
when I call auth('employee')->user()->latest_pending_leave_request(), larastan says Call to an undefined method Illuminate\Contracts\Auth\Authenticatable::latest_pending_leave_request()

@devfaysal Although custom guards are not supported in Larastan, I believe your issue will be fixed in the next release. You can try to pull the master branch and check now if you want.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spaceemotion picture spaceemotion  Â·  4Comments

JeroenVanOort picture JeroenVanOort  Â·  3Comments

bogdankharchenko picture bogdankharchenko  Â·  4Comments

hailwood picture hailwood  Â·  4Comments

szepeviktor picture szepeviktor  Â·  4Comments