====== PHP RFC: #[\Deprecated] Attribute ======
* Version: 1.3-dev
* Date: 2024-04-15
* Author: Benjami... n
* First Published at: http://wiki.php.net/rfc/deprecated_attribute
===== Introduction =====
PHP’s internal functions can be marked as deprecated, making this information available to Reflection ... <php>trigger_error()</php> to emit a <php>E_USER_DEPRECATED</php> error when calling a method and either pars
choices:
* **Short path**: a signature becomes deprecated in PHP 8.4 (or in PHP 8.3 when there is no need f... 0 at last.
* **Long path**: a signature becomes deprecated in PHP 8.4 (or in PHP 8.3 when there is no need f... 10.0.
* **No**: the signature should be neither deprecated, nor removed.
A few votes only include the "Shor... ion for more details.
**When will a signature be deprecated?**
When the "Short path" combined with the "Long
y to ExcludeList]] (Created 2020-06-09)
* [[rfc:deprecated_attribute|#[\Deprecated] Attribute]]\\ This RFC proposes an attribute to mark declarations as deprecated (Created 2020-05-07)
* [[rfc:var-export-array-s... Deprecations for PHP 7.4]] \\ Functionality to be deprecated in PHP 7.4. (Discussion started: 2019-06-21)
*
Error.
<code php>
//PHP 8.4
var_dump(0 ** -1); //Deprecated: Zero raised to a negative power is deprecated
var_dump(0 ** -1.1); //Deprecated: Zero raised to a negative power is deprecated
var_dump(pow(0, -1)); //Deprecated: Zero raised to a negativ
on is provided in the Proposal section:
* Soft-deprecated <php>DOMDocument</php> and <php>DOMEntity</php> p... ation in PHP 8.4 and removal in PHP 9.
==== Soft-deprecated DOMDocument and DOMEntity properties ====
Author...
The following properties have already been soft-deprecated for a long time:
* ''DOMDocument::$actualEncodi... any other well behaved constants, therefore it's deprecated.
<doodle title="Deprecate and remove the aforeme
n''.
Moreover, the "legacy" code assertions were deprecated in PHP 7.2 and have been removed in PHP 8.0. Howe... INI settings related to those assertions had been deprecated nor removed. Moreover, with the removal of the co... hp>assert_options()</php> function that was "soft deprecated" in PHP 7.0, by emitting an <php>E_DEPRECATED</php> notice when it is called.
* Deprecate the ''assert.acti
e were [[https://github.com/php/php-src/pull/5067|deprecated in PHP 8.0]],
the case of implicitly nullable typ... d be noted that the example signatures above were deprecated prior to the introduction of [[rfc:named_params|n... llowing deprecation notice at compile time:
<PHP>
Deprecated: Implicitly marking parameter $var as nullable is deprecated, the explicit nullable type must be used instead
r the developer, <php>MT_RAND_PHP</php> should be deprecated.
<doodle title="Deprecate and remove the broken ... better alternatives, the global Mt19937 should be deprecated and then removed. The function-based API will the... 37</php> class.
The following functions shall be deprecated:
* <php>mt_rand()</php>
* <php>mt_srand()</p... ing the function is based on the since some years deprecated underlying ''ldap_open'' function. Internally we
alchars(false);
$o[] = htmlspecialchars(NULL); // Deprecated in 8.1, Fatal Error in 9.0?
</code>
With user-de... === Temporary Solutions ====
You can disable //E_DEPRECATED// (as recommended by projects like WordPress).
A... 59c51e8d7/Zend/zend_API.c#L458
if ($errno === E_DEPRECATED && preg_match('/Passing null to parameter #.* of type .* is deprecated/', $errstr)) {
return true;
}
return fals
g
Changing any of the following settings will be deprecated:
* <php>session.use_only_cookies</php>
* <ph... t()</php> to their non-default value will also be deprecated.
The constant <php>SID</php> will also be deprecated as part of this RFC. The standalone proposal to deprec... omatic rewriting of URLs to add PHPSESSID will be deprecated.
The hack which allows for manual control of th
converted to 0
*/
var_dump(range(null, 2));
/*
Deprecated: range(): Passing null to parameter #1 ($start) of type string|int|float is deprecated
array(3) {
[0]=>
int(0)
[1]=>
int(1)
[2... ]=>
int(2)
}
*/
var_dump(range(null, 'e'));
/*
Deprecated: range(): Passing null to parameter #1 ($start) of type string|int|float is deprecated in %s on line %d
Warning: range(): Argument #1 (
magic value to empty the autoloader list will be deprecated.
It will still be possible to unregister all aut... </php> to <php>spl_autoload_unregister()</php> is deprecated.
The current RFC as proposed has a large BC brea... int the current SPL autoloader functions could be deprecated and then removed in a later version of PHP, there
itionally, the ''$datalen'' property would become deprecated in favor of ''$dataLength'' in the subsequent min... reamBucket
{
/**
* @var resource
* @deprecated after resource to object conversion happens
... public $bucket;
public string $data;
/** @deprecated in PHP 8.5 or PHP 9.0 whichever comes next */
tentially many lines later...
if(is_called_with_deprecated_value($oldParam)) {
$logger->warn(nameof($oldParam) . ' is deprecated in the next version, please use ' . nameof($newPa