Problem/Motivation
In the TemplateControlStructureSniffer.php file, Coder Sniffer currently adds an error for all control structures in .tpl.php files that do not use the alternate (colon) syntax. This is not consistent with the Drupal coding standards published at https://www.drupal.org/coding-standards, which state:
In templates, the alternate control statement syntax using : instead of brackets is allowed.
Coder Sniffer should either use a warning, or as in the attached patch, only add an error if the content of the control statement contains a closing tag ?>.
Proposed resolution
Ignore curly-brace control structures if they don't contain closing tags.
Remaining tasks
Review patch, write tests.
User interface changes
It might be a good idea to update the error message as well, but it isn't necessary.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | coder-relax_TemplateControlStructureSniff-2530884-2.patch | 1.06 KB | tedfordgif |
Comments
Comment #1
tedfordgif commentedComment #2
tedfordgif commentedPatch against 7.x-2.x.
Comment #4
klausiHm, so if the alternative syntax in templates is not a requirement at all we should drop the sniff completely, committed that to 8.x-2.x which can also be used to check D7 code.
Comment #5
klausiCoder 7.x is frozen now and will not receive updates. Coder 8.x-2.x can be used to check code for any Drupal version, Coder 8.x-2.x also supports the phpcbf command to automatically fix conding standard errors. Please check if this issue is still relevant and reopen against that version if necessary.