rfc:deprecations_php_7_1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:deprecations_php_7_1 [2016/02/18 13:00] – typos nikicrfc:deprecations_php_7_1 [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: Deprecations for PHP 7.1 ====== ====== PHP RFC: Deprecations for PHP 7.1 ======
-  * Date: 2015-12-28 
-  * Author: Nikita Popov <nikic@php.net> 
-  * Status: Under Discussion 
  
-===== Introduction ===== +Superseded by [[https://wiki.php.net/rfc/deprecations_php_7_2]].
- +
-This is a draft RFC for multiple deprecations targeting PHP 7.1. The RFC proposes to deprecate the listed functionality in PHP 7.1 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()'' +
-  * ''rand()'' and ''srand()'' +
- +
-===== Proposal ===== +
- +
-==== __autoload ==== +
- +
-The magic [[http://php.net/__autoload|__autoload]] function has been superseded by [[http://php.net/spl_autoload_register|spl_autoload_register]] in PHP 5.1 and its use discouraged in the documentation. One primary advantage of ''spl_autoload_register()'' is the ability to provide multiple chained autoloaders, thus easing library interoperability. Both mechanism are mutually exclusive, i.e. code using ''%%__autoload()%%'' cannot interoperate with code using ''spl_autoload_register()''. As the latter is much more commonly used and also employed by Composer, the ''%%__autoload()%%'' mechanism has only very limited applicability nowadays. +
- +
-Proposed action: A deprecation notice is thrown when a global function with name ''%%__autoload()%%'' is encountered during compilation. +
- +
-==== $php_errormsg ==== +
- +
-The [[http://php.net/manual/en/reserved.variables.phperrormsg.php|$php_errormsg]] variable is created in the local scope whenever a non-fatal error is thrown, if the ''track_errors'' ini setting is enabled (disabled by default) and the error has not been consumed by an error handler. +
- +
-Apart from being ini-dependent language behavior, this behavior is highly magic and the [[http://php.net/error_get_last|error_get_last]] function provides a cleaner way of retrieving the last error. Since PHP 7 additionally the [[http://php.net/manual/en/function.error-clear-last.php|error_clear_last]] function is available, thus covering the last possible use-cases for ''$php_errormsg'' without magic scope manipulation. +
- +
-Proposed action: A deprecation notice is thrown if the ''track_errors'' ini setting is enabled. +
- +
-==== create_function() ==== +
- +
-[[http://php.net/create_function|create_function()]] is a thin wrapper around the ''eval()'' language construct, allowing the creation of a function with a generated function name and the argument list and body code provided as string arguments. Before the introduction of closures in PHP 5.3 it provided a way to create something akin to lambda functions. +
- +
-Due to the nature of its operation ''create_function()'', apart from being a potential source of security issues, has very bad performance and memory usage characteristics and the use of real closures is in every way preferable. +
- +
-Proposed action: Mark the function as deprecated, thus issuing a deprecation notice on every call. +
- +
-==== rand() and srand() ==== +
- +
-The [[http://php.net/rand|rand()]] and [[http://php.net/srand|srand()]] functions expose the libc random number generator (and its seeding functionality) to PHP. The output and quality of this random number generator is system dependent. Notably, on Windows rand() can only generate at most 32767 unique values for any value range (if the value range includes more than 32767 numbers, some numbers will never be returned). Furthermore Windows uses a very low quality linear congruential generator with bad statistical properties (it's so bad you can see the non-uniformity with the naked eye). +
- +
-As alternatives to these functions, PHP provides [[http://php.net/mt_rand|mt_rand()]] and [[http://php.net/mt_srand|mt_srand()]], which are based on a 32-bit MT19937 algorithm. While not ideal (it generates at most 2147483647 unique values, even on 64-bit platforms), mt_rand() is strictly superior to rand() and does not have a platform dependence. It should always be preferred over rand(). +
- +
-Proposed action: Mark these functions as deprecated, thus issuing a deprecation notice on every call. +
- +
-===== Backward Incompatible Changes ===== +
- +
-For PHP 7.1 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). +
- +
-===== 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://php.net/manual/en/reserved.variables.httpresponseheader.php|$http_repsonse_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 [[http://php.net/get_headers|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()''.+
rfc/deprecations_php_7_1.1455800405.txt.gz · Last modified: 2017/09/22 13:28 (external edit)