Legacy code: <script language="php"> not recognised

Hi everyone,

I've been given the wonderful task of bug fixing some legacy PHP code that is wrapped in <script language="php"></script> tags. Unfortunately PhpStorm doesn't seem to recognise these, so my code is not syntax highlighted, todo tags aren't detected and the whole development experience isn't quite what I've come to expect from this excellent software. Does anyone know how to get PhpStorm to recognise these tags? Is it possible? Please say yes!

Thanks,
-James

11 comments
Comment actions Permalink

Hi James,

I think the answer will be the same as in this question: http://devnet.jetbrains.net/thread/294104

I thought, maybe it is possible to achieve this by using custom Language Injection rule, but there is no option to use PHP as Injected Language.

0
Comment actions Permalink

Thanks Andriy,

I wonder why it doesn't detect legacy tags for php? Surely lots of developer still work with old code like this. Maybe something to be added for version 3....

0
Comment actions Permalink

Well, PhpStorm officially supports PHP v5.3.x only. The only place where I have seen this syntax (<script language="php">) was PHP manual -- have not seen it myself in any library or real project so far. So the answer to "why" may be found in keywords "legacy" and "very rarely used". Those are my thoughts on why it is not supported.

Maybe you can update your project to use <?php & ?> tags? "Search | Replace in Path..." can do such replacement very quickly.

Maybe something to be added for version 3....

You may submit this as feature request here: http://youtrack.jetbrains.net/issues/WI#newissue=yes

0
Comment actions Permalink

No I've never seen that syntax used until this current project either.

I'll check with them whether they would be happy for me to change all the tags....sometimes the original developers can be funny about these things.

Thanks for your help.

0
Comment actions Permalink

Why <script language="php"></script> are legacy? I don't see any word that they are deprecated in the manual: http://www.php.net/manual/en/language.basic-syntax.phpmode.php
That's why I think they shuld be supported. Also, I guess this case http://www.php.net/manual/en/language.basic-syntax.phpmode.php#97113 should be supported as well.

0
Comment actions Permalink

Hi Dmitriy, I see your point. I should not have referred to it as legacy code, I just have only ever seen it used in really old code so perhaps it is a style which has fallen out of fashion in recent years. I hope JetBrains agree with you and add it the product soon!
-James

0
Comment actions Permalink

Sorry to necro this thread. I guess this was never implemented? Debugging ancient code that is riddled with horrible opening tags like this is pretty difficult, and unfortunately (or fortunately) phpStorm, out of the 20 IDE's I tested, is the only IDE that can handle huge mix-language projects.

0
Comment actions Permalink

@Bradley

It was not implemented.

PHP 7 does not support such tags any more ( http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.php-tags ) .. and AFAIK it was decided to not to implement it at all (not that particular ticket but related: https://youtrack.jetbrains.com/issue/WI-18304)

0
Comment actions Permalink

Weird, it's not like people are only using PHP7.  Nobody chooses to edit ancient code, it's just technical debt that all companies have at least some of. Is there anyway to modify the language schemas to create your own tags then?

 

0
Comment actions Permalink

@Bradley

>Weird, it's not like people are only using PHP7. 

True. But PHP 7 is much faster/better than PHP 5.x .. that you can find it even on shared hosting plans now (just an example -- one of the projects that I maintain -- 1.5 years ago PHP 5.2 was the max version; now 5.3 is the minimal there)

I know nothing about your code base ... but I believe that refactoring the code to use only <?php ?> tags should be possible if such task would be allocated (as long as there are no other technologies that rely on such currently used tags).

>Is there anyway to modify the language schemas to create your own tags then?

I'm not JB dev and do not know the internals .. but I doubt that it can easily be done from user end. I mean -- you can go and look inside compiled PHP plugin internals .. and maybe you can make some changes if you have qualification .. but it's definitely does not have any "add this here to get support for this new functionality" options for end user.

---

I personally 100% sure that support for such legacy now tags will not be implemented. This IDE was created with PHP 5.3 as minimal supported version (Language Level) .. and even 5.2 that was still had quite a bit of usage those days was never supported (I mean -- treating 5.3 features as invalid: namespaces etc)

If you will not get any response from devs or support team -- feel free to ask them directly (e.g. "Submit a Request" link on the top of this page ... or maybe even by creating a ticket on Issue Tracker) ... but I strongly believe that the response will be similar -- "declined/no plans at all to implement legacy-now feature".

0
Comment actions Permalink

Oh I'm just talking about actual real life work situations, yknow, commerce, where people are paid to migrate/upgrade/maintain ancient code bases. The point is choice, some people don't have a choice and are compelled by the nature of their job to use legacy scripts. Not comparing legacy PHP with PHP 7, which is much faster and supports awesome features. Trust me, nobody _wants_ to debug ancient horrible code, but that's a large part of "industry", and this is an "industry" tool.

Anyway you're right, the best approach would be to see if I can modify the language schema to include support for extended tags. Thanks :)

0

Please sign in to leave a comment.