--level used: 6Hello Guys,
I am getting these errors on level 6
------ ------------------------------------------------------------------------------------------------------
Line app/Http/Controllers/OauthController.php
------ ------------------------------------------------------------------------------------------------------
90 Access to private property $id of parent class Illuminate\Foundation\Auth\User.
96 Access to private property $pid of parent class Illuminate\Foundation\Auth\User.
104 Access to private property $email of parent class Illuminate\Foundation\Auth\User.
105 Access to private property $language of parent class Illuminate\Foundation\Auth\User.
106 Access to private property $currency of parent class Illuminate\Foundation\Auth\User.
113 Call to an undefined method
(Illuminate\Database\Eloquent\Collection&iterable<static(App\User)>)|static(App\User)::getLogInfo().
------ ------------------------------------------------------------------------------------------------------
The way i use these properties and the function is following...
$user = User::find($ID);
$user->id;
$user->pid;
$user->getLogInfo();
So to sum it up, object properties are not defined, but even if i define them or specify them as a @parameter docs it has no effect. I think that the problem lies in a User::find() method where a static analyzer thinks that this method should return a Illuminate\Foundation\Auth\User but in a real life it returns App\User class...
Do you have an idea how to fix these errors?
What is your use?
You can tell PHPStan that find returns App\User by doing
/** @var \App\User|null $user */
$user = User::find($ID);
That's a temporary solution. But I hope it'll get fixed with #324
Smal nitpick 馃槃 : technically this is \App\User|null, unless you would use findOrFail
Most helpful comment
You can tell PHPStan that
findreturnsApp\Userby doingThat's a temporary solution. But I hope it'll get fixed with #324