Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Space before colon required in phtml files when using alternative syntax for control structures? #118

Copy link
Copy link
Closed
@hostep

Description

@hostep
Issue body actions

Description

Hi

This is more a question or a start of a discusion around the fact that currently a space is required before a colon in phtml files when using the alternative syntax for control structures.

So currently Magento code standards expects us to use this format in phtml files:

<?php if ($something) : ?>
    <!-- do something -->
<?php else : ?>
    <!-- do something else -->
<?php endif; ?>

I'm wondering why this is required at this moment? Was there a reason for requiring it like this? Or did it just happen because it is the default setting of the PHP_CodeSniffer project?
Because it looks very ugly (personal opinion), other php projects don't enforce this syntax, a lot of php tutorials/samples don't use it, and it's also not part of any php coding standard as far as I'm aware?

I would rather see this format:

<?php if ($something): ?>
    <!-- do something -->
<?php else: ?>
    <!-- do something else -->
<?php endif; ?>

This could be changed with this option:
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#squizcontrolstructurescontrolsignature

I'm seeing a lot of files being changed recently in the 2.3-develop branch whereas in Magento 2.3.2 this syntax wasn't being enforced yet. So it feels like somebody made this decision to enforce this but I can't find the reasoning behind it.

Not sure if this would make a chance to get changed?
No big deal if not, just wanted to bring this up 🙂

Thanks!

ytorbyk, ihor-sviziev and Sharkozp

Metadata

Metadata

Assignees

Labels

acceptedNew rule is acceptedNew rule is acceptedenhancementImprovements to existing rulesImprovements to existing rules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.