nikic

Nikita Popov

Contents

PHP RFC: Deprecations for PHP 7.2

Introduction

This is a draft RFC for multiple deprecations targeting PHP 7.2. The RFC proposes to deprecate the listed functionality in PHP 7.2 and remove it no later than in PHP 8.0.

The following list provides a short overview of the functionality targeted for deprecation, while more detailed explanation is provided in the Proposal section:

  • __autoload
  • $php_errormsg
  • create_function()
  • mbstring.func_overload
  • (unset) cast
  • parse_str() without second argument
  • gmp_random()
  • each()
  • assert() with string argument
  • $errcontext argument of error handler

Proposal

Each feature proposed for deprecation is voted separately. Each vote requires a 2/3 majority, independently of whether it is a language or standard library change. All votes refer to deprecation in PHP 7.2 and removal in the next major version (presumably PHP 8.0).

(binary) cast and b"" literals

This deprecation has been extracted into a separate RFC: Binary String Deprecation RFC

Backward Incompatible Changes

For PHP 7.2 additional deprecation notices will appear. For PHP 8.0 the previously deprecated functionality will no longer be available.

Proposed Voting Choices

Each of the bullet points above will get a separate vote. All votes will require a 2/3 supermajority, independently of whether they are language changes or not.

Patches and Tests

The patches for these deprecations are for the most part trivial, as such they will be provided once the RFC is accepted (or portions of it).

Suggested deprecations

The following list contains various suggested deprecations that may or may not be included in this RFC (TODO section).

  • The "${varName}", "${varName['offset']}" and "${expr}" alternative string interpolation syntaxes. These can be replaced by the more obvious and consistent "{$varName}", "{$varName['offset']}" and "{${expr}}". (Maybe leave the latter? That one is a bit awkward.)
  • The alternative parameter order for implode(). Standard order is string, array, but array, string is also allowed for historic reasons.
  • fputcsv etc. have been suggested, because they don't conform to the CSV standard. I think it's better to improve the implementation instead.
  • convert_cyr_string, as the same can be done with mb_convert_encoding or iconv.
  • get_magic_quotes_gpc, as it's pretty useless by now.
  • allow_url_include ini option.
  • hebrevc as it's just hebrev + nl2br.
  • sizeof, which is an alias of count.
  • Second argument to spl_autoload.
  • The ticks mechanism, which is obsoleted by async signal handling.
  • php_sapi_name, phpversion and pi: These functions return constant values corresponding to PHP_SAPI, PHP_VERSION and M_PI.
  • The (real) cast and is_real() functions. real is an alias for float/double which sees significantly less use than the other two variants.

Rejected deprecations

The following section lists features that have been suggested for deprecation, but have not been included in this RFC for the outlined reasons.

$http_response_header

The $http_response_header variable is created in the local scope if an HTTP request is performed, for example through file_get_contents(). It contains an array of HTTP response headers.

The motivations for removing this functionality are similar to those of $php_errormsg, so it would seem reasonable to deprecate them at the same time. However, unlike $php_errormsg there exist no simple alternatives to $http_response_header. The get_headers function returns only the headers, but not the response body. Getting both requires, to my knowledge, a combination of fopen(), stream_get_contents() and reading the wrapper_data from stream_get_meta_data().

Votes

An option needs 2/3 votes to win

Deprecate and subsequently remove __autoload (97.1% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop Yes
bwoebi Yes
cmb Yes
colinodell Yes
davey Yes
dm Yes
frozenfire Yes
jhdxr Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mariano Yes
mbeccati Yes
mcmic Yes
nikic Yes
ocramius Yes
patrickallaert Yes
peehaa Yes
pierrick Yes
pollita No
sammyk Yes
sebastian Yes
sobak Yes
stas Yes
tpunt Yes
trowski Yes
yunosh Yes
zimt Yes
Deprecate and subsequently remove $php_errormsg (100% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop Yes
bwoebi Yes
cmb Yes
colinodell Yes
davey Yes
frozenfire Yes
jhdxr Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mbeccati Yes
mcmic Yes
nikic Yes
ocramius Yes
patrickallaert Yes
peehaa Yes
pollita Yes
sammyk Yes
sebastian Yes
stas Yes
tpunt Yes
trowski Yes
zimt Yes
Deprecate and subsequently remove create_function() (100% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop Yes
bwoebi Yes
cmb Yes
colinodell Yes
davey Yes
frozenfire Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mbeccati Yes
mcmic Yes
nikic Yes
ocramius Yes
patrickallaert Yes
peehaa Yes
pollita Yes
sammyk Yes
sebastian Yes
sobak Yes
stas Yes
tpunt Yes
trowski Yes
zimt Yes
Deprecate and subsequently remove mbstring.func_overload (100% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop Yes
bwoebi Yes
cmb Yes
davey Yes
frozenfire Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mbeccati Yes
mcmic Yes
nikic Yes
ocramius Yes
patrickallaert Yes
peehaa Yes
pollita Yes
sammyk Yes
sebastian Yes
sobak Yes
stas Yes
tpunt Yes
trowski Yes
zimt Yes
Deprecate and subsequently remove (unset) cast (96.6% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop Yes
bwoebi Yes
cmb Yes
colinodell Yes
davey Yes
frozenfire Yes
jhdxr Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mbeccati Yes
mcmic Yes
nikic Yes
ocramius Yes
patrickallaert Yes
peehaa Yes
pollita No
sammyk Yes
sebastian Yes
stas Yes
tpunt Yes
trowski Yes
zimt Yes
Deprecate and subsequently remove parse_str() without second argument (100% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop Yes
bwoebi Yes
cmb Yes
colinodell Yes
davey Yes
frozenfire Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mbeccati Yes
mcmic Yes
nikic Yes
ocramius Yes
patrickallaert Yes
peehaa Yes
pollita Yes
sammyk Yes
sebastian Yes
sobak Yes
stas Yes
tpunt Yes
trowski Yes
zimt Yes
Deprecate and subsequently remove gmp_random() (100% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop Yes
bwoebi Yes
cmb Yes
colinodell Yes
davey Yes
frozenfire Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mbeccati Yes
mcmic Yes
nikic Yes
ocramius Yes
patrickallaert Yes
peehaa Yes
pollita Yes
sammyk Yes
sebastian Yes
tpunt Yes
trowski Yes
zimt Yes
Deprecate and subsequently remove each() (75% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop No
bukka No
cmb Yes
davey Yes
kalle Yes
krakjoe Yes
lcobucci Yes
levim Yes
marcio Yes
mbeccati No
nikic Yes
ocramius Yes
patrickallaert No
peehaa Yes
pollita No
sammyk Yes
sebastian Yes
stas No
tpunt Yes
trowski Yes
zimt Yes
Deprecate and subsequently remove assert() with string argument (96.2% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop No
colinodell Yes
davey Yes
frozenfire Yes
jhdxr Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mbeccati Yes
mcmic Yes
nikic Yes
ocramius Yes
peehaa Yes
pollita Yes
sammyk Yes
sebastian Yes
stas Yes
tpunt Yes
trowski Yes
zimt Yes
Deprecate and subsequently remove $errcontext argument of error handler (88% approved)
User Vote
aharvey Yes
ajf Yes
ashnazg Yes
bishop No
bwoebi Yes
cmb Yes
davey Yes
frozenfire Yes
kalle Yes
krakjoe Yes
lcobucci Yes
leigh Yes
levim Yes
marcio Yes
mbeccati Yes
nikic Yes
ocramius Yes
peehaa Yes
pollita No
sammyk Yes
sebastian Yes
stas Yes
tpunt Yes
trowski Yes
zimt No