Requests.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Requests for PHP
  4. *
  5. * Inspired by Requests for Python.
  6. *
  7. * Based on concepts from SimplePie_File, RequestCore and WP_Http.
  8. *
  9. * @package Requests
  10. *
  11. * @deprecated 2.0.0
  12. */
  13. /*
  14. * Integrators who cannot yet upgrade to the PSR-4 class names can silence deprecations
  15. * by defining a `REQUESTS_SILENCE_PSR0_DEPRECATIONS` constant and setting it to `true`.
  16. * The constant needs to be defined before this class is required.
  17. */
  18. if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS') || REQUESTS_SILENCE_PSR0_DEPRECATIONS !== true) {
  19. // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
  20. trigger_error(
  21. 'The PSR-0 `Requests_...` class names in the Request library are deprecated.'
  22. . ' Switch to the PSR-4 `WpOrg\Requests\...` class names at your earliest convenience.',
  23. E_USER_DEPRECATED
  24. );
  25. // Prevent the deprecation notice from being thrown twice.
  26. if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS')) {
  27. define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
  28. }
  29. }
  30. require_once dirname(__DIR__) . '/src/Requests.php';
  31. /**
  32. * Requests for PHP
  33. *
  34. * Inspired by Requests for Python.
  35. *
  36. * Based on concepts from SimplePie_File, RequestCore and WP_Http.
  37. *
  38. * @package Requests
  39. *
  40. * @deprecated 2.0.0 Use `WpOrg\Requests\Requests` instead for the actual functionality and
  41. * use `WpOrg\Requests\Autoload` for the autoloading.
  42. */
  43. class Requests extends WpOrg\Requests\Requests {
  44. /**
  45. * Deprecated autoloader for Requests.
  46. *
  47. * @deprecated 2.0.0 Use the `WpOrg\Requests\Autoload::load()` method instead.
  48. *
  49. * @codeCoverageIgnore
  50. *
  51. * @param string $class Class name to load
  52. */
  53. public static function autoloader($class) {
  54. if (class_exists('WpOrg\Requests\Autoload') === false) {
  55. require_once dirname(__DIR__) . '/src/Autoload.php';
  56. }
  57. return WpOrg\Requests\Autoload::load($class);
  58. }
  59. /**
  60. * Register the built-in autoloader
  61. *
  62. * @deprecated 2.0.0 Include the `WpOrg\Requests\Autoload` class and
  63. * call `WpOrg\Requests\Autoload::register()` instead.
  64. *
  65. * @codeCoverageIgnore
  66. */
  67. public static function register_autoloader() {
  68. require_once dirname(__DIR__) . '/src/Autoload.php';
  69. WpOrg\Requests\Autoload::register();
  70. }
  71. }