Multi Line comments in javascript aore marked as error
Hallo,
since I have updated to PHPStorm 2016 all multi line comments (/* comment */) in a javascript block nested in a file ending with .php are marked as error.
Is there any suggestion?
Regards
Claus
Please sign in to leave a comment.
Hi there,
Please provide sample code (ideally not as copy-paste text but as a downloadable file).
Please also state your exact IDE version.
Hallo Andriy
I could find out a little more details. But it is very strange
When I create a new PHP file test.php and insert this code
<?php
/**
* Created by PhpStorm.
* User: xxx
* Date: 22.09.16
* Time: 08:17
*/
?>
<script type="javascript">
/* Test */
</script>
everything works finde. But if I create a new file named test.js.php (which I use to determine if JS is used in this php file) and use the same contents, it get the error. It is very easy to reproduce.
Regards
Claus
Thanks for clarification.
It's not a bug but expected behaviour. And the issue is not about comments .. but actual <script> tags -- you do not need them in such file (if you remove them your comments will be treated properly).
What is ".php" file (from IDE point of view)? It's a file where PHP code is allowed/supported and outside them is a HTML context.
In your case you have double extension -- ".js.php". Here IDE does what users have asked to do (see original WI-24237 ticket) -- to have JavaScript as outer language context instead of default HTML. Basically -- IDE treats this file as ".js" file (where you do not need any <script> tags and write JavaScript straight away) with PHP code support. Before (few versions back -- like v8 and earlier) to have that done, you had to go into "Template Data Languages" settings page, find such file and associate JavaScript language manually -- now it's done automatically based on the file extensions.
To sum it up:
If you want to have "original" behaviour -- where file is treated as HTML with possible PHP code in it (as any .php file would be) you have few options:
Hallo Andriy,
thanks for the fast reply and explanation.
Claus