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

Stefano Kowalke blueduck at gmx.net
Mon Oct 22 15:49:11 CEST 2012


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

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