class Deprecated (View source)

Constants

PHP_VERSIONS

Methods

__construct(string $reason = "", string $replacement = "", string $since = "5.6")

Mark element as deprecated

Details

__construct(string $reason = "", string $replacement = "", string $since = "5.6")

Mark element as deprecated

Parameters

string $reason

Reason for deprecation. It will be displayed by PhpStorm via the Deprecated inspection instead of the default message

string $replacement

Applicable only to function/method calls: IDE will suggest replacing a deprecated function call with the provided code template. The following variables are available in this template:

  • %parametersList%: parameters of the function call. For example, for the "f(1,2)" call, %parametersList% will be "1,2"
  • %parameter0%,%parameter1%,%parameter2%,...: parameters of the function call. For example, for the "f(1,2)" call, %parameter1% will be "2"
  • %name%: For "\x\f(1,2)", %name% will be "\x\f", for "$this->ff()", %name% will be "ff"
  • %class%: If the attribute is provided for method "m", then for "$this->f()->m()", %class% will be "$this->f()"

The following example shows how to wrap a function call in another call and swap arguments:
"#[Deprecated(replaceWith: "wrappedCall(%name%(%parameter1%, %parameter0%))")] f($a, $b)}
f(1,2) will be replaced with wrappedCall(f(2,1))

string $since

Element is deprecated starting with the provided PHP language level, applicable only for PhpStorm stubs entries