rspec/rules/S2001/php/rule.adoc

71 lines
3.6 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Deprecated language features are those that have been retained temporarily for backward compatibility, but which will eventually be removed from the language. In effect, deprecation announces a grace period to allow the smooth transition from the old features to the new ones. In that period, no use of the deprecated features should be added to the code, and all existing uses should be gradually removed.
The following functions were deprecated in PHP 5:
[frame=all]
[cols="^1,^1"]
|===
|Deprecated|Use Instead
|``++call_user_method()++``|``++call_user_func()++``
|``++call_user_method_array()++``|``++call_user_func_array()++``
|``++define_syslog_variables()++``|
|``++dl()++``|
|``++ereg()++``|``++preg_match()++``
|``++ereg_replace()++``|``++preg_replace()++`` (note that this is deprecated in PHP 5.5)
|``++eregi()++``|``++preg_match()++`` with 'i' modifier
|``++eregi_replace()++``|``++preg_replace()++`` with 'i' modifier
|``++set_magic_quotes_runtime()++`` and its alias, ``++magic_quotes_runtime()++``|
|``++session_register()++``|``++$_SESSION++`` superglobal
|``++session_unregister()++``|``++$_SESSION++`` superglobal
|``++session_is_registered()++``|``++$_SESSION++`` superglobal
|``++set_socket_blocking()++``|``++stream_set_blocking()++``
|``++split()++``|``++preg_split()++``
|``++spliti()++``|``++preg_split()++`` with 'i' modifier
|``++sql_regcase()++``|
|``++mysql_db_query()++``|``++mysql_select_db()++`` and ``++mysql_query()++``
|``++mysql_escape_string()++``|``++mysql_real_escape_string()++``
|Passing locale category names as strings|Use the LC_* family of constants
|===
2021-04-28 16:49:39 +02:00
The following functions were deprecated in PHP 7:
[frame=all]
[cols="^1,^1"]
|===
|Deprecated|Use Instead
|``++__autoload()++``|``++spl_autoload_register()++``
|``++create_function()++``|anonymous function
|``++parse_str()++`` without second argument|``++parse_str()++`` with second argument
|``++gmp_random()++``|``++gmp_random_bits()++`` or ``++gmp_random_range()++``
|``++each()++``|``++foreach++``
|``++assert()++`` with string argument|
|Defining case-insensitive constants by calling ``++define()++`` with ``++true++`` as third parameter|``++define("myconst", $value)++`` or ``++define("myconst", $value, false)++``
|``++FILTER_FLAG_SCHEME_REQUIRED++`` and ``++FILTER_FLAG_HOST_REQUIRED++`` flags|``++FILTER_VALIDATE_URL++`` flag
|``++fgetss()++`` function, ``++"string.strip_tags"++`` stream filter name, ``++SplFileObject::fgetss()++`` method and ``++gzgetss()++`` function|
2021-04-28 16:49:39 +02:00
|``++mbregex_encoding()++``, ``++mbereg()++``, ``++mberegi()++``, ``++mbereg_replace()++``, ``++mberegi_replace()++``, ``++mbsplit()++``, ``++mbereg_match()++``, ``++mbereg_search()++``, ``++mbereg_search_pos()++``, ``++mbereg_search_regs()++``, ``++mbereg_search_init()++``, ``++mbereg_search_getregs()++``, ``++mbereg_search_getpos()++``, ``++mbereg_search_setpos()++``|Use the
corresponding ``++mb_ereg_*()++`` variants instead
|string search functions with integer needle (``++stristr++``, ``++strrchr++``, ``++strstr++``, ``++strripos++``, ``++stripos++``, ``++strrpos++``, ``++strpos++``, ``++strchr++``) |use a string needle instead
|``++image2wbmp()++``|``++imagewbmp()++``
|``++Normalizer::NONE++``|
|Defining an ``++assert()++`` function inside a namespace|use the standard ``++assert()++`` function
|===
2021-04-28 16:49:39 +02:00
== See
* https://wiki.php.net/rfc/deprecations_php_7_3[PHP RFC: Deprecations for PHP 7.3]
* https://wiki.php.net/rfc/case_insensitive_constant_deprecation[PHP RFC: Deprecate and Remove Case-Insensitive Constants]
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]