rfc:deprecate_php_short_tags

PHP RFC: Deprecate PHP Short open tags

Introduction

PHP has provided over the years different ways to indicate the beginning of PHP code other than the standard <?php ... ?> open tags. Most of these opening tags have been removed with PHP 7.0.01), however, PHP's short open tags still remain.

Proposal

Deprecate and disable short_open_tag in PHP 7.4 and remove PHP's short open tags in PHP 8.0.

Reasoning

  • The PHP documentation discourages their usage.
  • PHP's short open tags clash with XML <?xml ?> and can mean two different things depending on the INI configuration.
  • PHP's short open tags depend on an INI directive and as such are non-portable.
  • As such source code may leak if PHP relying on the short open tags is executed on a configuration where this isn't enabled.
  • PHP's parser simplification.

Backward Incompatible Changes

Every script which currently uses the discouraged short <? open tag will need to convert to the standard <?php open tag.
This can be automatically achieved by using the “full_opening_tag” fixer from PHP-CS-Fixer.

Proposed PHP Version(s)

Deprecation notice and default value changed to Off in PHP 7.4 and removal in PHP 8.0.

RFC Impact

To SAPIs

None.

To Existing Extensions

Readline and Tokenizer have been updated in the implementations patches.

To Opcache

None to my understanding.

php.ini Defaults

Change short_open_tag from “1” to “0”.

Unaffected PHP Functionality

The <?= short tag is unaffected because as of PHP 5.4 it is always available.

Feedback

Facebook poll 2) created by Peter Kokot: 73 for, 2 against.

Proposed Voting Choices

Yes/No for boths votes.

Vote

Primary vote: Deprecate PHP's short open tags in PHP 7.4.
Requires a 2/3 majority.

Secondary vote: Remove PHP's short open tags in PHP 8.0.
Requires a 2/3 majority.

Voting started on 2019-04-10 at 10:40 UTC and ran until 2019-04-24 11:20 UTC (for two (2) weeks)

Deprecate PHP short open tags in PHP 7.4?
Real name Yes No
ashnazg (ashnazg)  
bishop (bishop)  
bwoebi (bwoebi)  
carusogabriel (carusogabriel)  
colinodell (colinodell)  
cpriest (cpriest)  
danack (danack)  
daverandom (daverandom)  
derick (derick)  
diegopires (diegopires)  
duncan3dc (duncan3dc)  
emir (emir)  
galvao (galvao)  
gasolwu (gasolwu)  
girgias (girgias)  
guilhermeblanco (guilhermeblanco)  
heiglandreas (heiglandreas)  
jasny (jasny)  
jbnahan (jbnahan)  
jhdxr (jhdxr)  
kalle (kalle)  
kelunik (kelunik)  
kguest (kguest)  
kinncj (kinncj)  
klaussilveira (klaussilveira)  
krakjoe (krakjoe)  
kriscraig (kriscraig)  
laruence (laruence)  
levim (levim)  
malukenho (malukenho)  
marcio (marcio)  
mariano (mariano)  
mbeccati (mbeccati)  
mcmic (mcmic)  
mike (mike)  
narf (narf)  
nikic (nikic)  
ocramius (ocramius)  
pauloelr (pauloelr)  
peehaa (peehaa)  
petk (petk)  
pmjones (pmjones)  
pmmaga (pmmaga)  
pollita (pollita)  
rasmus (rasmus)  
reywob (reywob)  
rtheunissen (rtheunissen)  
salathe (salathe)  
santiagolizardo (santiagolizardo)  
sebastian (sebastian)  
sergey (sergey)  
stas (stas)  
svpernova09 (svpernova09)  
thekid (thekid)  
trowski (trowski)  
yunosh (yunosh)  
Final result: 38 18
This poll has been closed.
Remove PHP short open tags in PHP 8.0?
Real name Yes No
ashnazg (ashnazg)  
bwoebi (bwoebi)  
carusogabriel (carusogabriel)  
colinodell (colinodell)  
cpriest (cpriest)  
danack (danack)  
daverandom (daverandom)  
derick (derick)  
diegopires (diegopires)  
duncan3dc (duncan3dc)  
emir (emir)  
galvao (galvao)  
gasolwu (gasolwu)  
girgias (girgias)  
guilhermeblanco (guilhermeblanco)  
heiglandreas (heiglandreas)  
jasny (jasny)  
jbnahan (jbnahan)  
jhdxr (jhdxr)  
kalle (kalle)  
kelunik (kelunik)  
kguest (kguest)  
kinncj (kinncj)  
klaussilveira (klaussilveira)  
krakjoe (krakjoe)  
kriscraig (kriscraig)  
laruence (laruence)  
levim (levim)  
malukenho (malukenho)  
marcio (marcio)  
mariano (mariano)  
mbeccati (mbeccati)  
mcmic (mcmic)  
mike (mike)  
narf (narf)  
nikic (nikic)  
ocramius (ocramius)  
pauloelr (pauloelr)  
peehaa (peehaa)  
petk (petk)  
pmjones (pmjones)  
pmmaga (pmmaga)  
pollita (pollita)  
rasmus (rasmus)  
reywob (reywob)  
rtheunissen (rtheunissen)  
salathe (salathe)  
sammyk (sammyk)  
santiagolizardo (santiagolizardo)  
sebastian (sebastian)  
sergey (sergey)  
stas (stas)  
svpernova09 (svpernova09)  
thekid (thekid)  
trowski (trowski)  
yunosh (yunosh)  
zeev (zeev)  
Final result: 42 15
This poll has been closed.

Patches and Tests

https://github.com/php/php-src/pull/3972 PHP 7.4 Deprecation Notice Implementation
https://github.com/php/php-src/pull/3975 PHP 8.0 Removal Implementation
TBD Documentation patch

Implementation

After the project is implemented, this section should contain

  1. the version(s) it was merged into
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature
  4. a link to the language specification section (if any)

References

rfc/deprecate_php_short_tags.txt · Last modified: 2019/04/24 11:23 by girgias