Problem
Deprecated.php defines REQUESTS_SILENCE_PSR0_DEPRECATIONS unconditionally:
define("REQUESTS_SILENCE_PSR0_DEPRECATIONS", true);
If another package or the host application (e.g. WordPress core, which defines this constant in its bundled Requests library) has already defined it before this file is loaded, PHP throws a fatal error:
PHP Fatal error: Constant REQUESTS_SILENCE_PSR0_DEPRECATIONS already defined
Note that Razorpay.php in the same package already guards the constant correctly:
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS'))
define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
Deprecated.php should follow the same pattern.
Suggested fix
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS')) define("REQUESTS_SILENCE_PSR0_DEPRECATIONS", true);
Environment
Reproduced when using razorpay/razorpay-php inside a WordPress plugin. WordPress core defines REQUESTS_SILENCE_PSR0_DEPRECATIONS before the plugin's Composer autoloader runs, causing Deprecated.php to collide on load.
Problem
Deprecated.phpdefinesREQUESTS_SILENCE_PSR0_DEPRECATIONSunconditionally:If another package or the host application (e.g. WordPress core, which defines this constant in its bundled Requests library) has already defined it before this file is loaded, PHP throws a fatal error:
Note that
Razorpay.phpin the same package already guards the constant correctly:Deprecated.phpshould follow the same pattern.Suggested fix
Environment
Reproduced when using
razorpay/razorpay-phpinside a WordPress plugin. WordPress core definesREQUESTS_SILENCE_PSR0_DEPRECATIONSbefore the plugin's Composer autoloader runs, causingDeprecated.phpto collide on load.