brevo-php icon indicating copy to clipboard operation
brevo-php copied to clipboard

Replace global 'version' variable with Configuration::VERSION class constant

Open lordofweb opened this issue 1 year ago • 2 comments

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

lordofweb avatar Jul 16 '24 09:07 lordofweb

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

  1. Removed the line $GLOBALS['version'] = '2.0.0';
  2. Added a VERSION constant to the Configuration class
  3. 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.

lordofweb avatar Oct 09 '24 12:10 lordofweb