The coding standard documentation currently makes no mention of the alternative control structure syntax for template files (see http://www.php.net/manual/control-structures.alternative-syntax.php), although there is a related comment http://drupal.org/coding-standards#comment-5433408. The documentation should be updated to include this variation with examples such as:

<?php if (!empty($item)): ?>
  <p><?php print $item; ?></p>
<?php endif; ?>

and

<?php foreach ($items as $item): ?>
  <p><?php print $item; ?></p>
<?php endforeach; ?>

The documentation should also indicate that there should not be a space between the closing parenthesis and the colon as mentioned in #999040: Coding standards: Alternative control structure syntax in theme templates.

Comments

jhodgdon’s picture

Project: Documentation » Drupal core
Version: » 8.x-dev
Component: Missing documentation » documentation

We normally discuss coding standards on a Drupal Core issue.

BassistJimmyJam’s picture

My mistake, thank you for moving it to the correct location.

jhodgdon’s picture

Status: Active » Fixed

Ah, just noticed you had linked to this other issue #999040: Coding standards: Alternative control structure syntax in theme templates where the coding standard was discussed.

Given that the standard has been agreed to, I went ahead an edited the coding standards page to add this to the Control Structures section:
http://drupal.org/coding-standards#controlstruct

Automatically closed -- issue fixed for 2 weeks with no activity.