Replace global 'version' variable with Configuration::VERSION class constant
Rename global 'version' variable to 'version-brevo'
This pull request addresses a potential naming conflict by renaming the global 'version' variable to 'version-brevo' in the Brevo PHP package.
Changes:
- Renamed $GLOBALS['version'] to $GLOBALS['version-brevo'] in lib/Configuration.php
- Updated the reference in the userAgent string
This change aims to prevent conflicts with other packages or user code that might use a similar global variable name.
Related issue: https://github.com/getbrevo/brevo-php/issues/31
This pull request addresses the issue of using a global variable for the Brevo PHP package version, which can cause conflicts and is deprecated in recent PHP versions.
Changes made
- Removed the line
$GLOBALS['version'] = '2.0.0'; - Added a
VERSIONconstant to theConfigurationclass - Updated the reference in the userAgent string
Details of the changes
class Configuration
{
/**
* Version of the package
*/
const VERSION = "2.0.0";
// ...
public function __construct()
{
$this->tempFolderPath = sys_get_temp_dir();
$this->userAgent = 'brevo_clientAPI/v' . self::VERSION . '/php';
}
}
Benefits of this change
- Eliminates potential naming conflicts with other code
- Improves code organization by keeping the version information within the relevant class
- Ensures compatibility with PHP 8.1 and later versions by avoiding the deprecated $GLOBALS assignment
Related issue: https://github.com/getbrevo/brevo-php/issues/31
Please review this change and let me know if any further modifications are needed.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code