I came across this problem multiple times as I made a new PHP file but the Phpstorm couldn’t recognize it. I searched the solution on the internet and came upon many but the best solution I found was to override the file type.

To do this Right click on the file -> Override file type -> Set as PHP

I hope this simple solution helps you as well.