I feel like the answer to this must be obvious, but given the frequency of the words used to describe the issue, I'm having a hard time searching for a resolution to this.
Basically, when I have code such as this:
if ($a = 'b'):
All of the PHP that is within DOM nodes isn't recognized as PHP. PHPStorm thinks that it's HTML, despite the fact that it's enclosed in PHP tags.
PHP within the HTML tag itself, such as this:
works just fine. Only PHP between the opening and closing HTML tags causes a problem.