Skip to content

Rule: Curly braces should not be used in PHTML files  #16

Closed
@renttek

Description

@renttek

Curly braces should not be used in PHTML files.

Bad:

<?php
if ($block->getFooList()) {
    foreach ($block->getFooList() as $foo) {
?>
        <!-- Template stuff -->
<?php
    }
}
?>

Better (Proposal 1):

<?php
if ($block->getFooList()):
    foreach ($block->getFooList() as $foo):
?>
        <!-- Template stuff -->
<?php
    endforeach;
endif;
?>

Better (Proposal 2):

<?php if ($block->getFooList()) ?>
    <?php foreach ($block->getFooList() as $foo): ?>
        <!-- Template stuff -->
    <?php endforeach; ?>
<?php endif; ?>

(Source: https://twitter.com/jissereitsma/status/990301162090975232)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions