rfc:deprecations_php_7_3

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:deprecations_php_7_3 [2018/06/24 11:25]
nikic Remove case-insensitive constants from this RFC
rfc:deprecations_php_7_3 [2018/07/21 21:50] (current)
nikic Implemented
Line 2: Line 2:
   * Date: 2017-08-02   * Date: 2017-08-02
   * Author: Nikita Popov <​nikic@php.net>​   * Author: Nikita Popov <​nikic@php.net>​
-  * Status: ​Draft+  * Status: ​Implemented (in PHP 7.3) 
 +  * Implementation:​ https://​github.com/​php/​php-src/​pull/​3366 (unless other patch linked below) 
 +  * Discussion: https://​externals.io/​message/​102394
  
 ===== Introduction ===== ===== Introduction =====
  
-This is a draft RFC for multiple deprecations targeting PHP 7.3. The RFC proposes to deprecate the listed functionality in PHP 7.3 and remove it no later than in PHP 8.0.+This is a draft RFC for multiple deprecations targeting PHP 7.3. The RFC proposes to deprecate the listed functionality in PHP 7.3 and remove it in PHP 8.
  
 The following list provides a short overview of the functionality targeted for deprecation,​ while more detailed explanation is provided in the Proposal section: The following list provides a short overview of the functionality targeted for deprecation,​ while more detailed explanation is provided in the Proposal section:
  
-  * TODO+  * Undocumented mbstring function aliases 
 +  * String search functions with integer needle 
 +  * ''​fgetss()''​ function and ''​string.strip_tags''​ filter 
 +  * Defining a free-standing ''​assert()''​ function 
 +  * ''​FILTER_FLAG_SCHEME_REQUIRED''​ and ''​FILTER_FLAG_HOST_REQUIRED''​ flags 
 +  * ''​pdo_odbc.db2_instance_name''​ php.ini directive
  
 ===== Proposal ===== ===== 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.3 and removal in the next major version (presumably PHP 8.0). +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.3 and removal in the next major version (presumably PHP 8.0). The votes close on 2018-07-16.
- +
-==== WDDX extension ==== +
- +
-Previous discussions:​ https://​externals.io/​message/​100183 and https://​externals.io/​message/​100220. +
- +
-TODO+
  
 ==== Undocumented mbstring function aliases ==== ==== Undocumented mbstring function aliases ====
Line 28: Line 29:
 Proposed action: Mark the functions as deprecated, so that a deprecation notice is emitted on every call. In PHP 8 these aliases will be removed. Proposed action: Mark the functions as deprecated, so that a deprecation notice is emitted on every call. In PHP 8 these aliases will be removed.
  
-==== mb_detect_encoding() without strict mode ==== +<doodle title="​Deprecate ​(and subsequently removeundocumented mbstring function aliases?"​ auth="​nikic"​ voteType="​single"​ closed="​true">​ 
- +   * Yes 
-TODO +   * No 
- +</​doodle>​
-==== strip_tags() ​and fgetss(functions ==== +
- +
-TODO +
- +
-From some preliminary feedback: We might want to only deprecate the insecure allowed_tags parameter, but keep the "strip all tags" functionality. This function appears to be useful as a relatively simple way of reusing code that outputs HTML in a different context (CLI output, text messages, etc.)+
  
 ==== String search functions with integer needle ==== ==== String search functions with integer needle ====
Line 54: Line 50:
 Proposed action: Throw a deprecation warning if a non-string is passed as a needle to ''​strpos''​ or one of the above-listed functions. The deprecation warning should note that an explicit ''​chr''​ call may be used instead. In PHP 8 the deprecation warning will be removed and the needle parameter will be changed into a string. Proposed action: Throw a deprecation warning if a non-string is passed as a needle to ''​strpos''​ or one of the above-listed functions. The deprecation warning should note that an explicit ''​chr''​ call may be used instead. In PHP 8 the deprecation warning will be removed and the needle parameter will be changed into a string.
  
-==== Continue acting on switch ====+<doodle title="​Deprecate (and subsequently remove) integer needles in string search functions?"​ auth="​nikic"​ voteType="​single"​ closed="​true">​ 
 +   * Yes 
 +   * No 
 +</​doodle>​
  
-In PHP an argument-less ''​continue''​ inside a ''​switch''​ block behaves the same way as ''​break''​. In other C-based languages, it will continue the wrapping loop instead. As such, in PHP you need to write ''​continue 2''​ for an operation that would be just ''​continue''​ in other languages.+==== fgetss() function and string.strip_tags filter ====
  
-We cannot change these semantics for reasons of backwards-compatibility ​(and arguably wouldn't want to anyway), but we can remove this particular gotcha by disallowing ​the application ​of ''​continue'' ​to switch statement and instead force the use of ''​break'' ​(at the same levelor a ''​continue'' ​at a higher leveldepending ​on which semantics are intended.+The ''​fgetss()''​ function ​and the ''​string.strip_tags''​ stream filters expose ​the functionality ​of ''​strip_tags()'' ​in streaming matter. The need to support these makes the implementation ​of ''​strip_tags()''​ more complicated,​ as streaming state machine is necessary. On the other hand, these functions seem to be of very little utility. ​''​strip_tags()'' ​itselfdue to its limitations and known bugs, already has very few legitimate applications. There is no need to provide native support for streaming application ​on top of that.
  
-In the following some examples are provided to illustrate invalid usages ​and what they should be replaced with.+Proposed action: Mark ''​fgetss()'',​ ''​gzgetss()''​ and ''​SplFileObject::​fgetss()''​ as deprecated, so that a deprecation notice is emitted on every call. Generate a deprecation notice if the ''​string.strip_tags''​ stream filter is created. ​In PHP 8 the functions ​and the stream filter are removed.
  
-<code php> +<doodle title="​Deprecate ​(and subsequently removefgetss() (and variations) and the string.strip_tags filter?" ​auth="nikic" voteType="​single"​ closed="​true">​ 
-switch ​($foo+   * Yes 
-    case "bar": +   * No 
-        ​continue;​ // INVALID. Replace with: +</​doodle>​
-        ​break;​ +
-}+
  
-while ($foo+==== Defining a free-standing assert() function ====
-    switch ($bar) { +
-        case "​baz":​ +
-            continue; ​  // INVALID. Replace with +
-            continue 2; // or +
-            break; ​     // depending on the intended behavior +
-    } +
-}+
  
-while ($foo+Since PHP 7.0 the ''​assert()''​ function is subject to special treatment in the compiler. In particular, calls to ''​assert()''​ will be elided if ''​zend.assertions=-1''​ is set. To make this elision of asserts in production systems work reliably, this also applies to unqualified ''​assert()''​ calls inside namespacesHowever, such calls may refer to a namespaced variant ​of ''​assert()''​ rather than the global function, and such calls are thus also subjected to ''​zend.assertions=-1''​. See [[https://​bugs.php.net/​bug.php?​id=75445|Bug #75445]].
-    switch ​($bar+
-        case "​baz":​ +
-            while ($xyz+
-                continue 2; // INVALIDReplace with one of: +
-                continue 3; +
-                break 2; +
-            } +
-    } +
-+
-</code>+
  
-Proposed action: Throw a deprecation warning from the compiler if a ''​continue'' ​directly targets a ''​switch''​ statement (rather than a loop at a lower or higher level than it)Preferably the deprecation message should include a suggestion for the possible alternatives. In PHP 8 the deprecation will be replaced by a compiler error.+To avoid confusion due to this behavior, it is suggested to forbid ​the definition of free-standing ​''​assert()'' ​functionsMethods are unaffected.
  
-==== Defining ​free-standing ​assert() function ​====+Proposed action: Generate ​compile-time deprecation warning if an ''​assert()'' ​function ​is declared. In PHP 8 this becomes a compile-error.
  
-Interacts badly with zend.assertions.+<doodle title="​Deprecate (and subsequently remove) support for defining a free-standing assert() function?"​ auth="​nikic"​ voteType="​single"​ closed="​true">​ 
 +   * Yes 
 +   * No 
 +</​doodle>​
  
-TODO+==== FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED ==== 
 + 
 +As of PHP 5.2.1 ''​FILTER_VALIDATE_URL''​ implies ''​FILTER_FLAG_SCHEME_REQUIRED''​ and ''​FILTER_FLAG_HOST_REQUIRED''​. Not only are these constants useless, they also create the incorrect impression that the scheme/host requirement can be disabled. 
 + 
 +Proposed action: Generate a deprecation warning if the ''​FILTER_FLAG_SCHEME_REQUIRED''​ or ''​FILTER_FLAG_HOST_REQUIRED''​ flags are explicitly set in calls to filter APIs (PHP currently has no mechanism to deprecate the constants themselves). In PHP 8 the constants will be removed. 
 + 
 +Implementation:​ https://​github.com/​php/​php-src/​pull/​3322 
 + 
 +<doodle title="​Deprecate (and subsequently remove) FILTER_FLAG_(SCHEME|HOST)_REQUIRED flags?"​ auth="​nikic"​ voteType="​single"​ closed="​true">​ 
 +   * Yes 
 +   * No 
 +</​doodle>​ 
 + 
 +==== pdo_odbc.db2_instance_name php.ini directive ==== 
 + 
 +As of PHP 5.1.1 ''​pdo_odbc.db2_instance_name''​ was marked as deprecated in the manual, promising removal in a future version of PHP. This ini directive modifies the DB2INSTANCE environment variable for non Windows operating systems, allowing pdo_odbc to make cataloged connections to a DB2 database. 
 + 
 +The side effect here is that this setting is process wide and also affects the ODBC extension, which can create some hard to debug situations. Besides this, the PECL package, ibm_db2 seems to implement the exact same behavior which could also conflict. 
 + 
 +Proposed action: Add a deprecation notice if the ini directive has a value at module initialization. 
 + 
 +Implementations:​ https://​gist.github.com/​KalleZ/​424ea78492cd5f4c2198cba6b25403d9 
 + 
 +<doodle title="​Deprecate (and subsequently remove) pdo_odbc.db2_instance_name php.ini directive?"​ auth="​nikic"​ voteType="​single"​ closed="​true">​ 
 +   * Yes 
 +   * No 
 +</​doodle>​
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 105: Line 114:
  
 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. 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). 
rfc/deprecations_php_7_3.1529839530.txt.gz · Last modified: 2018/06/24 11:25 by nikic