Skip to content

PHP 7.4/RemovedFunctions: handle removed functions from the Deprecations RFC#847

Merged
wimg merged 7 commits intomasterfrom
php-7.4/deprecations/removed-functions
Aug 26, 2019
Merged

PHP 7.4/RemovedFunctions: handle removed functions from the Deprecations RFC#847
wimg merged 7 commits intomasterfrom
php-7.4/deprecations/removed-functions

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Jul 22, 2019

Related to #808

PHP 7.4/RemovedFunctions: handle deprecated is_real()

As of PHP 7.4, the is_real() function is deprecated. Use is_float() instead.

This function is expected to be removed in PHP 8.0.

Refs:

PHP 7.4/RemovedFunctions: handle deprecated magic quote related functions

PHP's infamous magic_quotes configuration was removed in PHP 5.4 and the function implementations of checking whether or not these settings have been enabled have returned false since then. With PHP 7.0 not having magic_quotes at all, it is time to deprecate these functions and remove them entirely.

Proposal: Mark get_magic_quotes_gpc() and get_magic_quotes_runtime() as deprecated. This should only impact legacy code bases prior to PHP 5.4, running non-supported versions of PHP.

These functions are expected to be removed in PHP 8.0.

Refs:

PHP 7.4/RemovedFunctions: handle deprecated hebrevc()

The hebrevc() function is equivalent to calling nl2br() on the result of hebrev(), which is a function to convert Hebrew text from logical to visual ordering. While nl2br(hebrev($str)) is already preferable over hebrevc($str) for readability reasons, use of visual ordering is only relevant in contexts that do not have proper Unicode bidi support, such as certain terminals. As detailed in W3C Visual vs. logical ordering of text, visual ordering should never be used for HTML. The hebrevc() function is an explicit violation of this principle.

Proposal: Mark hebrevc() as deprecated.

This function is expected to be removed in PHP 8.0.

Refs:

Note: While nl2br(hebrev($str)) is equivalent, as visual ordering shouldn't be used in HTML and nl2br() is only useful in HTML contexts, this equivalent has not been marked as a valid alternative.

PHP 7.4/RemovedFunctions: handle deprecated convert_cyr_string()

The convert_cyr_string() function allows conversion between Cyrillic character sets. The character sets are specified using obscure single character names, such as convert_cyr_string($str, 'k', 'i'). This is a legacy function from a time where PHP did not provide general functions for conversion between character sets. Nowadays one of mb_convert_encoding(), iconv() or UConverter may be used for this purpose.

Proposal: Mark convert_cyr_string() as deprecated.

This function is expected to be removed in PHP 8.0.

Refs:

PHP 7.4/RemovedFunctions: handle deprecated money_format()

The money_format() function formats currency values using locale-specific settings. It is based on the strfmon() C function, which is not supported on all platforms. Most notably it is not available on Windows. Nowadays the NumberFormatter::formatCurrency() method provided by intl should be used instead, which is both platform-independent and does not rely on the system locale. Additionally, intl also provides the ability to parse currency values using NumberFormatter::parseCurrency().

Furthermore, the strfmon() implementation seems to have an internal buffer overrun on macos, which indicates that this functionality is not well tested.

This function is expected to be removed in PHP 8.0.

Refs:

PHP 7.4/RemovedFunctions: handle deprecated ezmlm_hash()

The ezmlm_hash() function creates hashes of email addresses which the EZMLM/QMail mailing list system understands. This function is of very limited usefulness for the average PHP developer as the EZMLM/QMail system is barely maintained and its last release was in 2007. The function was most likely originally added for use in the php.net mailing list infrastructure. It can be trivially reimplemented in userland code if needed.

Proposal: Mark ezmlm_hash() as deprecated.

This function is expected to be removed in PHP 8.0.

Refs:

PHP 7.4/RemovedFunctions: handle deprecated restore_include_path()

This function is essentially an “alias” of doing ini_restore('include_path'). Unlike other functions like restore_error_handler() or restore_exception_handler(), this function does not operate on a stack and always resets to the original/initial value. While you can use set_error_handler() and restore_error_handler() as a pair, doing the same with set_include_path() and restore_include_path()is not safe. As such, this function does not offer any benefit overini_restore('include_path')` and just causes wrong expectations.

Proposal: Mark restore_include_path() as deprecated.

This function is expected to be removed in PHP 8.0.

Refs:

@jrfnl jrfnl added Type: enhancement PR: quick merge PR only contains relatively simple changes PR: ready for review labels Jul 22, 2019
@jrfnl jrfnl added this to the 9.x Next milestone Jul 22, 2019
@jrfnl jrfnl requested a review from wimg July 22, 2019 22:07
@jrfnl jrfnl force-pushed the php-7.4/deprecations/removed-functions branch from 2e46b49 to 984490d Compare August 21, 2019 03:35
jrfnl added 7 commits August 21, 2019 05:52
As of PHP 7.4, the `is_real()` function is deprecated. Use `is_float()` instead.
This function is expected to be removed in PHP 8.0.

Refs:
* https://wiki.php.net/rfc/deprecations_php_7_4#the_real_type
* php/php-src#4390
* php/php-src@4e19069
…ions

>  PHP's infamous `magic_quotes` configuration was removed in PHP 5.4 and the function implementations of checking whether or not these settings have been enabled have returned `false` since then. With PHP 7.0 not having `magic_quotes` at all, it is time to deprecate these functions and remove them entirely.
>
> Proposal: Mark `get_magic_quotes_gpc()` and `get_magic_quotes_runtime()` as deprecated. This should only impact legacy code bases prior to PHP 5.4, running non-supported versions of PHP.

These functions are expected to be removed in PHP 8.0.

Refs:
* https://wiki.php.net/rfc/deprecations_php_7_4#magic_quotes_legacy
* php/php-src#4390
* php/php-src@b2ea507
> The `hebrevc()` function is equivalent to calling `nl2br()` on the result of `hebrev()`, which is a function to convert Hebrew text from logical to visual ordering. While `nl2br(hebrev($str))` is already preferable over `hebrevc($str)` for readability reasons, use of visual ordering is only relevant in contexts that do not have proper Unicode bidi support, such as certain terminals. As detailed in W3C Visual vs. logical ordering of text, visual ordering should never be used for HTML. The `hebrevc()` function is an explicit violation of this principle.
>
> Proposal: Mark `hebrevc()` as deprecated.

This function is expected to be removed in PHP 8.0.

Refs:
* https://wiki.php.net/rfc/deprecations_php_7_4#hebrevc_function
* php/php-src#4390
* php/php-src@4e4d8a4

**Note**: While `nl2br(hebrev($str))` is equivalent, as visual ordering shouldn't be used in HTML and `nl2br()` is only useful in HTML contexts, this equivalent has _not_ been marked as a valid alternative.
> The `convert_cyr_string()` function allows conversion between Cyrillic character sets. The character sets are specified using obscure single character names, such as `convert_cyr_string($str, 'k', 'i')`. This is a legacy function from a time where PHP did not provide general functions for conversion between character sets. Nowadays one of `mb_convert_encoding()`, `iconv()` or `UConverter` may be used for this purpose.
>
> Proposal: Mark `convert_cyr_string()` as deprecated.

This function is expected to be removed in PHP 8.0.

Refs:
* https://wiki.php.net/rfc/deprecations_php_7_4#convert_cyr_string
* php/php-src#4390
* php/php-src@b3668aa
> The `money_format()` function formats currency values using locale-specific settings. It is based on the `strfmon()` C function, which is not supported on all platforms. Most notably it is not available on Windows. Nowadays the `NumberFormatter::formatCurrency()` method provided by `intl` should be used instead, which is both platform-independent and does not rely on the system locale. Additionally, `intl` also provides the ability to parse currency values using `NumberFormatter::parseCurrency()`.
>
> Furthermore, the `strfmon()` implementation seems to have an internal buffer overrun on macos, which indicates that this functionality is not well tested.

This function is expected to be removed in PHP 8.0.

Refs:
* https://wiki.php.net/rfc/deprecations_php_7_4#money_format
* php/php-src#4390
* php/php-src@b1cdf06
> The `ezmlm_hash()` function creates hashes of email addresses which the EZMLM/QMail mailing list system understands. This function is of very limited usefulness for the average PHP developer as the EZMLM/QMail system is barely maintained and its last release was in 2007. The function was most likely originally added for use in the php.net mailing list infrastructure. It can be trivially reimplemented in userland code if needed.
>
> Proposal: Mark `ezmlm_hash()` as deprecated.

This function is expected to be removed in PHP 8.0.

Refs:
* https://wiki.php.net/rfc/deprecations_php_7_4#ezmlm_hash
* php/php-src#4390
* php/php-src@e9e2fa4
> This function is essentially an “alias” of doing `ini_restore('include_path')`. Unlike other functions like `restore_error_handler()` or `restore_exception_handler()`, this function does not operate on a stack and always resets to the original/initial value. While you can use `set_error_handler()` and `restore_error_handler()` as a pair, doing the same with `set_include_path() and `restore_include_path()` is not safe. As such, this function does not offer any benefit over `ini_restore('include_path')` and just causes wrong expectations.
>
> Proposal: Mark `restore_include_path()` as deprecated.

This function is expected to be removed in PHP 8.0.

Refs:
* https://wiki.php.net/rfc/deprecations_php_7_4#restore_include_path_function
* php/php-src#4390
* php/php-src@964de03
@jrfnl jrfnl force-pushed the php-7.4/deprecations/removed-functions branch from 984490d to f5612fb Compare August 21, 2019 04:28
@wimg wimg merged commit 614a10c into master Aug 26, 2019
@delete-merged-branch delete-merged-branch bot deleted the php-7.4/deprecations/removed-functions branch August 26, 2019 16:11
@jrfnl jrfnl removed PR: ready for review PR: quick merge PR only contains relatively simple changes labels Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants