How to check code with short opening tags? #415
-
I have code that uses short PHP tags, like this: <?php
function example() {
echo "Example";
?><span><a href="<?= 'test' ?>>Example</a></span><?
echo "More PHP code";
} However everything after a short opening tag gets identified as HTML:
While the above code parses correctly, my codebase ends up crashing phpcbf because of this issue:
I tried to enable short tags by putting this in my ruleset XML file: <ini name="short_open_tag" value="On"/> However it made no difference. How can I get phpcbf to correctly handle short opening tags without changing my global PHP settings? (I don't want to change my global PHP settings because I don't want to enable short tags for my own code, but I am using pbpcbf to check someone else's legacy codebase.) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
That's not a PHPCS issue, but a characteristic of how PHP parses the code when
You can't. As per the short_open_tags documentation, the value of Not sure if changing the short open tags to long tags was on the menu for cleaning up the codebase too, but if so, the Once the short tags have been fixed to long tags, everything else should start working properly. |
Beta Was this translation helpful? Give feedback.
-
FYI: While it doesn't directly address this issue, PR #447 is a proposal to improve the help screens, including improved information on the help screen about what PHP ini options are changeable via PHPCS itself. Reviews and testing of that PR would be appreciated. |
Beta Was this translation helpful? Give feedback.
Also see: #416 ;-)