Let's go through the steps to have PhpStorm recognize different languages in one file.
1. Rename the file so PhpStorm treats it as PHP & extension differs from *.php
2. Associate new file type with PHP (or other language)
We need to associate the new file type (*.js.php) with PHP (in our case) in Settings | File Types. If you do not want to use such custom extension, then you'll have to assign the full file name as a pattern, which is not recommended.
Please note that this setting is IDE-wide, so this file type association will affect all projects. Therefore, having a custom extension is the best way to proceed with it.
3. Set the Template Data Language through the project settings
Once the Template Data Language has been specified, PhpStorm recognizes both languages. Our IDE provides syntax highlighting, code completion, inspections, refactorings and so on.
We can do similar things with CSS and embedded PHP. Here's a .css.php file for which I've specified the Template Data Language as CSS. It features inspections for both the CSS part of the syntax as well as the embedded PHP.