coding-standards icon indicating copy to clipboard operation
coding-standards copied to clipboard

Support for alternative syntax

Open n9iels opened this issue 9 years ago • 3 comments

Is there currently a way to avoid errors when using a inline php syntax? Like this:

<?php if ($condition == true) : ?>
    <p>Yes</p>
<?php endif; ?>

n9iels avatar Aug 25 '15 13:08 n9iels

Change the InlineControlStructureSniff to allow it. Generally the only place it's allowed though is layout files. These files are exempted in the CMS (see https://github.com/joomla/joomla-cms/blob/staging/build/phpcs/Joomla/ruleset.xml#L138), so if you're using this ruleset in a project you'd need to tweak the ruleset a bit.

mbabker avatar Aug 25 '15 14:08 mbabker

Strange enough I don't get the error that is generated in this file (Inline control structures are not allowed). When taking this file for example https://github.com/joomla/joomla-cms/blob/staging/components/com_content/views/form/tmpl/edit.php#L61 codesniffer says: Expected "if (...)\n"; found "if (...) "

n9iels avatar Aug 25 '15 14:08 n9iels

That error message is coming from the ControlSignatureSniff.

vess avatar Aug 26 '15 12:08 vess