Community
Participate
Working Groups
this code: <style> <?php $str=''; foreach($errLines as $errLine){ $str.='pre ol li:nth-child('.$errLine.'), '; } $str=rtrim($str,', '); ?> </style> formats into: <style> <? php $str = ''; foreach ( $errLines as $errLine ) { $str .= 'pre ol li:nth-child(' . $errLine . '), '; } $ str =rtrim ( $str, ', ' ); ?> </style> - which is both ugly, and outright breaks the code, making it uncompilable (using the built-in "PHP Convention" formatter profile). Eclipse version: Version: Photon Milestone 2 (4.8.0M2) Build id: 20170922-0530 Eclipse PDT version: 5.2.0.2017091910
and even if you fix the obvious syntax errors, it subtly alters the behavior of the remaining code, thus the "importance level: Major"
Hi Hans, it seems that in <style> tags you have 2 formatters that conflicts: - the php formatter tries to format <?php ?> section first - afterwards there's some eclipse formatter that formats <style> tag content I have no solution yet, better never include other things than valid css content inside <style> tags, you should better do something like that: <?php echo "<style>\n"; $str=''; foreach($errLines as $errLine){ $str.='pre ol li:nth-child('.$errLine.'), '; } $str=rtrim($str,', '); echo "</style>\n"; ?> If I remember well, there was already a very old bug talking about this problem. Thierry.
> If I remember well, there was already a very old bug talking about this problem. i went looking for one before submitting this bugreport, but couldn't find it. and yeah, i ended up doing a workaround like that, // written this way because of eclipse formatter bugs, // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=528379 echo '<style>' . $str . ' {background-color:red;}</style>'; ?> <style> ~~
I found it again ;) It was (more or less) bug 493808.
New Gerrit change created: https://git.eclipse.org/r/155547
Gerrit change https://git.eclipse.org/r/155547 was merged to [master]. Commit: http://git.eclipse.org/c/pdt/org.eclipse.pdt.git/commit/?id=c2b024decada6e123f1f4977a32ba6626f53c509
Fixed. We simply don't use the CSS code formatter anymore inside <style> tags that contain some PHP code. This way the PHP code formatter will work as expected, but the rest of the CSS code will remain untouched. That's a little drawback, but probably the best we can (or should) do in this very specific case. Thierry.