Deprecated.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace JetBrains\PhpStorm;
  3. use Attribute;
  4. #[Attribute(Attribute::TARGET_FUNCTION | Attribute::TARGET_METHOD | Attribute::TARGET_CLASS | Attribute::TARGET_CLASS_CONSTANT | Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)]
  5. class Deprecated {
  6. public const PHP_VERSIONS = [
  7. "5.3",
  8. "5.4",
  9. "5.5",
  10. "5.6",
  11. "7.0",
  12. "7.1",
  13. "7.2",
  14. "7.3",
  15. "7.4",
  16. "8.0",
  17. "8.1",
  18. "8.2",
  19. ];
  20. /**
  21. * Mark element as deprecated
  22. *
  23. * @param string $reason Reason for deprecation. It will be displayed by PhpStorm via the Deprecated inspection instead of the default message
  24. * @param string $replacement Applicable only to function/method calls: IDE will suggest replacing a deprecated function call with the provided code template.
  25. * The following variables are available in this template:
  26. * <ul>
  27. * <li>%parametersList%: parameters of the function call. For example, for the "f(1,2)" call, %parametersList% will be "1,2"</li>
  28. * <li>%parameter0%,%parameter1%,%parameter2%,...: parameters of the function call. For example, for the "f(1,2)" call, %parameter1% will be "2"</li>
  29. * <li>%name%: For "\x\f(1,2)", %name% will be "\x\f", for "$this->ff()", %name% will be "ff"</li>
  30. * <li>%class%: If the attribute is provided for method "m", then for "$this->f()->m()", %class% will be "$this->f()"</li>
  31. * </ul>
  32. * The following example shows how to wrap a function call in another call and swap arguments:<br />
  33. * "#[Deprecated(replaceWith: "wrappedCall(%name%(%parameter1%, %parameter0%))")] f($a, $b){}<br />
  34. * f(1,2) will be replaced with wrappedCall(f(2,1))
  35. * @param string $since Element is deprecated starting with the provided PHP language level, applicable only for PhpStorm stubs entries
  36. */
  37. public function __construct($reason = "", $replacement = "",
  38. #[ExpectedValues(self::PHP_VERSIONS)] $since = "5.6")
  39. {
  40. }
  41. }