[TYPO3-core] CGL proposal: Dropping the closing PHP tag

Ernesto Baschny [cron IT] ernst at cron-it.de
Tue Oct 23 11:20:19 CEST 2012


Hi Stefano,

long ago our .php files were indeed "XML" (PHP embedded in XHTML). This
is simply not the case anymore. Our PHP files are not embedded in XML,
we do *not* encourage to do that, because we separate them (for good
reasons, which I don't think you will argue).

So considering that we don't want to embedd PHP in XML, it sounds
strange that we need to enforce a XML rule onto PHP files.

I always found it beautiful to have the PHP tag closed at the end of the
file, but I also don't really see the need for it anymore. Most
Frameworks and IDEs by default don't do it as their "standard", and this
is becoming a "de-facto" standard, so why should we still wave the
"old-school flag" on that topic?

I am also +1 on removing the closing "?>" (or at least the check).

Cheers,
Ernesto

Stefano Kowalke schrieb am 22.10.2012 15:49:
> Hi,
> 
> as one of the PHP_CodeSniffer Leader who implements the CGL rules I want
> to give some background about this topic.
> 
> I assume that we agreed to common PHP opening and closing tags (<?php
> ?>). Not to the short (<? ?>) or asp (<% %>) variants.
> 
> By using these tags, you do using a so called XML Processing Instruction
> (PI)[1].
> 
> The normal syntax is <?PITARGET PICONTENT?> where PITARGET is in our
> case the string php, which is an directive for the XML parser and as
> every XML tag must be closed, these tags must closed too. (You can see
> this in the tag definition at [2])
> 
> Voting for not closing the php tag, you vote for an invalid XML syntax.
> If it hurts anyone, I have to say: "I don't know".
> 
> I believe that the rules in Zend or Drupal for remove the tag are only
> for lazy devs and for convenience to avoiding "header always sent"
> problems raised by a whitespace after the closing php tag.
> 
> Just my two cents.
> 
> @Steffen: We have to remove the rule, then we can remove the check.
> 
> [1] http://en.wikipedia.org/wiki/Processing_Instruction
> [2] http://www.w3.org/TR/REC-xml/#sec-pi
> 
> 
> Am 20.10.12 15:41, schrieb Andreas Wolf:
>> Hi,
>>
>> I'd like to propose a change to our CGL to get rid of the closing PHP tag.
>>
>> I don't see a good reason why it is there, but it creates a lot of
>> hazzle with our "no trailing newline" rule, especially when doing a
>> quick fix without an IDE (I don't control these settings in every
>> editor I use).
>>
>> Dropping the closing tag will make sure that no content in the PHP
>> file can slip into the output (which is AFAIK at least one main reason
>> why we have the "no newline"-rule).
>>
>> What's your opinion on that?
>>
>> Regards
>> Andreas
>>
> 



More information about the TYPO3-team-core mailing list