Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mick79's avatar

Method should not be called statically....

Can someone please put something to bed for me. I see this error message a lot:

"Non-static method 'find' should not be called statically less... (⌃F1) Dynamic class method called as static."

However what I'm trying to do works.

Here is one example of where this error flags up:

$meal = Meal::find($meal_id);
$mealname = $meal->meal_name;

The above works just fine. But that error is screaming at me.

Thanks

0 likes
9 replies
rin4ik's avatar

with this?

$meal = Meal::where('id', $meal_id)->firstOrFail();
1 like
Mick79's avatar

I can see that your solution would work, but I was asking why mine is "wrong"?

I use the quote marks around "wrong" because although my IDE is screaming at me, it works just fine.

Thanks for taking the time to answer.

Mick79's avatar

Hi thanks for that, it still doesn't work but at least I now know that I'm not mad, and that many many others are frustrated by the same issue.

Cronix's avatar

It also happens for a lot of laravels "magic" methods that IDE's can't figure out bc the methods don't actually exist, but they get called via php's magic __get() method.

Things like Model::whereName('some-name') cause issues instead of Model::where('name', 'some-name'), because there isn't an actual whereName method but there is a where method.

It is annoying, so I don't use any of them.

1 like
Mick79's avatar

@Cronix at some point I'll go through and refactor, because it does genuinely annoy me. However right now I just need to get shit out of the door :-)

Please or to participate in this conversation.