php-fig/per-coding-style

Opening PHP tag in uppercase

Closed this issue ยท 7 comments

None of the PSRs for Coding Standards, nor PER-CS, explicitly indicate whether the opening tag for PHP should be in lowercase, though this is very much implied in PSR-1 - see https://www.php-fig.org/psr/psr-1/#1-overview

It probably should be explicitly stated in the next version of PER-CS.

Also, it should be noted that php-cs-fixer does force the opening tag to be in lowercase, whilst phpcs does not.

Also, it should be noted that php-cs-fixer does force the opening tag to be in lowercase, whilst phpcs does not.

I know Greg was always very very strict about enforcing the PSRs to the letter (and nothing else). I also know he often asked for clarification in the FIG Google group/mailing list. ;-)

Good idea.

In my opinion it doesn't really benefit readability to specify a casing for PHP tags so we should leave it unspecified.

The intent of a style guide isn't just readability, but consistency. I don't recall the last time I saw a capitalized PHP open tag. So making it required that everyone do what everyone is already doing seems reasonable.

vjik commented

PER CS, 2.1 Basic Coding Standard:

Code MUST follow all rules outlined in PSR-1.

PSR-1, 1. Overview

Files MUST use only <?php and <?= tags.

I think, PSR-1 explicitly defines <?php only usage, and any changes in PER CS not need.

@vjik As far as I know, that rule is about the type of open tags and basically forbids the use of <?, <%[=] (ASP-style, PHP < 7.0) and <script language="php"... (PHP < 7.0) tags. It does not explicit say anything about the case of the <php open tag.

Keep in mind that PSR1 was published in the PHP 5 era.

vjik commented

It does not explicit say anything about the case of the <php open tag.

<?PHP is not equals <?php. In my interpretations Files MUST use only <?php and <?= tags. allows to use strictly only <?php or <?=.

But if it is not obvious and can be misleading, then better explicitly state it.