HTML not recognised in PHP file

It's been few weeks that HTML code in my PHP files is not recognized anymore.

With a simple example in a test.php file : 

<!DOCTYPE html>

<html lang="<?= $lang ?>" data-version="<?= VERSION ?>">

</html>

DOCTYPE si underlined with the message "Unresolved variable or type DOCTYPE"

Note that this version don't work either : 

<?php 
$lang = 'test';
const VERSION = '1.0';
?>
<!DOCTYPE html>

<html lang="<?= $lang ?>" data-version="<?= VERSION ?>">

</html>

The only clue I have is that I may have messed up language injection at some point, but I don't know how to reset to the base language injections. The thing is that the the changes I made in language injection where done few months ago and I don't remember exactly what have been done.

Or it may not be related, I didn't needed to work in PHP for a while.

Some help will be greatly appreciated, since it's pretty difficult to work  without html recognition in .php files :/

I work on Linux, with a phpstorm snap package.

6 comments
Comment actions Permalink

Do you recall what specific injection rule have you changed? If you do, just let me know its name and I will share a default rule.

0
Comment actions Permalink

Thank you for your answer. Unfortunately, no, I don't remember. There is a screenshot of my injections : 


I may have removed one without paying attention... I don't know what could cause the bug I faces.

0
Comment actions Permalink

Hi there,

1. Does it work OK in another file? What about another project?

2. I personally don't think that this will be the Language Injection issue. Can you switch to the default light color scheme in the Editor and post a screenshot of such file (I'm more familiar with those colors that this dark one). Normally it should show some color hints if Language Injection is involved.

3. Show what you have at "Settings/Preferences | Languages & Frameworks | Template Data Languages"

1
Comment actions Permalink

Thank you very much !

Your comment helped me figuring out why and when it happens. My project is mainly a JavaScript project (NodeJS), and only some part of it have been writtin in PHP. Few months ago I refactored and cleaned up the project by creating à new project in PHPStorm, and I specified project language to JavaScript.

By adding a HTMLCompatible entry in "Settings/Preferences | Languages & Frameworks | Template Data Languages" for the folder where PHP code resides in, the IDE now recognize HTML in my php files again.

Again, thank you very much :) 

0
Comment actions Permalink

Glad to hear that you have resolved your issue.

By adding a HTMLCompatible entry in "Settings/Preferences | Languages & Frameworks | Template Data Languages" for the folder where PHP code resides in, the IDE now recognize HTML in my php files again.

Sounds like you have done something unnecessary there in the first place (over-configuration). Because you do not need to have anything there for HTML to be recognized in PHP files. Unless/Perhaps it was needed for your JavaScript files...

1
Comment actions Permalink

Sounds like you have done something unnecessary there in the first place (over-configuration). Because you do not need to have anything there for HTML to be recognized in PHP files.

Oh... yes. If I set Project language to <none> I can remove the HTMLCompatible entry, and all is fine. Thanks !

0

Please sign in to leave a comment.