coding-standards
coding-standards copied to clipboard
Support for alternative syntax
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; ?>
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.
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 (...) "
That error message is coming from the ControlSignatureSniff.