getbrevo / brevo-php

A fully-featured PHP API client to interact with Brevo.
https://developers.brevo.com/
MIT License
49 stars 22 forks source link

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

Open lordofweb opened 3 months ago

lordofweb commented 3 months ago

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:

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 commented 2 weeks ago

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

Related issue: https://github.com/getbrevo/brevo-php/issues/31

Please review this change and let me know if any further modifications are needed.

sonarcloud[bot] commented 2 weeks ago

Quality Gate Passed 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

See analysis details on SonarCloud