Fixing infinite indexing in PhpStorm

My work today has been interrupted by PhpStorm which was freezing every few seconds. It was consuming a lot of CPU and slowing down the whole system. I restarted the MacBook but it didn’t help.

Then I found https://youtrack.jetbrains.com/issue/WI-66681/202211-stuck-on-Updating-Indexes in which Jetbrains member suggested:

Run File > Invalidate Caches … > turn on Clear file system cache and Local History and Clear downloaded shared indexes, then hit Invalidate and Restart

Doing that fixed the issue for me.