FIle Type detection not using end extension

 My PHPStorm IDE suddenly started displaying errors on my php files when I have .json in the filename, it never used to.

Example.json.php seems to be parsed as a json file and is giving me an error on the opening <?php "<value> expected, unexpected end of file".

Shouldn't it be using the end extension to determine file type?

4 comments
Comment actions Permalink

Hello,

Please check if it's all clear in File | Settings (or PhpStorm | Preferences for Mac OS) | Editor | File Types and the *.json.php mask or the file name is not associated with JSON file type.

0
Comment actions Permalink

I checked all the associations (twice) and *.json.php is not present in any of them. I even tried adding *.json.php to the PHP association and it's still displaying the error.

0
Comment actions Permalink

Hi there,

Can you please provide a sample of such file (assuming it's not empty and starting with actual JSON code and not PHP)?

In general -- IDE treats files with certain double extensions in a special way -- e.g. "file.js.php" will have automatically JavaScript selected as outer language instead of default HTML (as in usual .php files). Same for "file.json.php" .. but here it (for some reason) creates some issues between JSON and PHP parsers.

https://youtrack.jetbrains.com/issue/WI-30092 -- it has been resolved recently. Either wait for 2016.2 .. or try EAP build (it should be there already)

0
Comment actions Permalink

Thanks Andriy, I'll remove the .json association for now and wait for 2016.2

0

Please sign in to leave a comment.