Drop php closing tags

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Drop php closing tags

Post by Oleg » Fri Mar 12, 2010 9:12 pm

Closing php tags (?>) are not required when they are at the end of file. There are multiple reasons to not have them:

1. No worries about outputting whitespace before headers by accident.
2. At least the 'patch' utility adds newline at end of file when applying patches.
3. Various utilities such as sed add newline at end of file, when php files are processed with them.
4. Diffs without newlines at end of file have an additional line stating the absence of newline.

There are several posts on the net advocating against using closing php tags:

http://phpstarter.net/2009/01/omit-the-php-closing-tag/
http://choosetheforce.blogspot.com/2008 ... p-tag.html

Zend Framework prohibits closing php tags.

I propose removing all closing php tags at the ends of php files immediately.

User avatar
ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: Drop php closing tags

Post by ToonArmy » Fri Mar 12, 2010 9:48 pm

Yes I'd like to see this changed I'm not sure about 3.0 but having to configure editors to drop the end new line is a PITA and not actually required by PHP it's any subsequent new lines that cause problems. I'm not sure if we'll do this in 3.0 but it'd be a bigger pain to have 3.1 and 3.0 using different end of file standards imo so I'd advocate to do this for 3.0.8 the only problem is it would mean every single file is modified.
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Drop php closing tags

Post by Oleg » Fri Mar 12, 2010 10:28 pm

Are you referring to modifications in source control or release packages?

The former is I think a moot point, since changes are going to be at the very end they should be unlikely to conflict with anything.

The latter has already happened with 3.0.7-pl1, which changed every single php file due to dropping svn keywords, and that was a patch release.

User avatar
A_Jelly_Doughnut
Registered User
Posts: 1780
Joined: Wed Jun 04, 2003 4:23 pm

Re: Drop php closing tags

Post by A_Jelly_Doughnut » Sat Mar 13, 2010 12:47 am

First, all other things being equal, I would say that it is absurd to open a "tag" and not close it. But, as pointed out, various tools wrongly add new lines to the end of a file, which can cause problems once in a great while.

If I ruled the world, I'd leave phpBB as it is and tell GNU to fix their tools. Rule the world I do not, so altering phpBB as a solution to the problem is acceptable. However, as discussed previously, it cannot happen for 3.0.x because MODs rely on finding ?>

(whereas the $Id$ keyword was completely ignored as a practical manner)
A_Jelly_Doughnut

User avatar
ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: Drop php closing tags

Post by ToonArmy » Sat Mar 13, 2010 1:41 am

A_Jelly_Doughnut wrote:If I ruled the world, I'd leave phpBB as it is and tell GNU to fix their tools. Rule the world I do not, so altering phpBB as a solution to the problem is acceptable. However, as discussed previously, it cannot happen for 3.0.x because MODs rely on finding ?>
GNU tools aren't broken. In PHP "?>\n" works absolutely fine, and it's the customary way for any file to end with a new line. The problem arises when you add anything, even another new line, after that last new line. Hence we trim all white space off, as a kind of over zealous paranoia. It's really annoying imo as most non PHP tools don't usually work like that.
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image

User avatar
igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Drop php closing tags

Post by igorw » Sat Mar 13, 2010 10:51 am

I am in favor of dropping the closing tag. I'd also like to see a newline at the end of every file, since many editors (VIM) add this by default, and any unix-like environment expects it.

However, I don't think changing this in 3.0 is a good idea, for following reason mentioned by Josh:
A_Jelly_Doughnut wrote:it cannot happen for 3.0.x because MODs rely on finding ?>
Changing it for 3.1 would seems like a good idea to me. MODX/AutoMOD would need to be adjusted to support finding the end-of-file, but that should be trivial.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: Drop php closing tags

Post by imkingdavid » Sat Mar 20, 2010 8:38 pm

eviL3 wrote:I am in favor of dropping the closing tag. I'd also like to see a newline at the end of every file, since many editors (VIM) add this by default, and any unix-like environment expects it.

However, I don't think changing this in 3.0 is a good idea, for following reason mentioned by Josh:
A_Jelly_Doughnut wrote:it cannot happen for 3.0.x because MODs rely on finding ?>
Changing it for 3.1 would seems like a good idea to me. MODX/AutoMOD would need to be adjusted to support finding the end-of-file, but that should be trivial.
I agree with this; I have seen MODs that look for ?> because that will always occur in the file and allow the FIND to work. But I think it wouldn't hurt to do this for 3.1 and onward. :)
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Drop php closing tags

Post by MichaelC » Mon Mar 22, 2010 12:26 pm

I agree with evil. Its good idea but MODs and hacks and code snippets use the ?> to use in the FIND in MODs
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Drop php closing tags

Post by igorw » Fri Jun 25, 2010 10:34 am

A huge amount of MODs depends on this in the language files. I don't think phpBB 3.0 MODs will be able to install on phpBB 3.1 directly in the first place. So if we simply drop the tags, adjust MODX to support going to end-of-file and provide a conversion script (for MODs from 3.0 to 3.1), that script could simply convert all "find ?>" actions to "find eof".

An alternative solution would be to have the 3.1 AutoMOD and MODX XSL adjusted so they display "find ?>" as "find eof".

I personally would prefer the first solution. Please comment quickly, so I can update the ticket with the according subtasks.

User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Re: Drop php closing tags

Post by nickvergessen » Fri Jun 25, 2010 10:28 pm

eviL3 wrote:An alternative solution would be to have the 3.1 AutoMOD and MODX XSL adjusted so they display "find ?>" as "find eof".
That would be really odd, as there are some files which contain more than one ?>
Member of the Development-TeamNo Support via PM

Post Reply