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

Remove deprecation notice on nullable properties in method signatures

Open LaurentBrieu opened this issue 11 months ago • 1 comments

Description

Update methods signatures to avoid deprecation notices when using PHP 8.4 :

Brevo\Client\Api\EventsApi::__construct(): Implicitly marking parameter $client as nullable is deprecated, the explicit nullable type must be used instead in lib/Api/EventsApi.php on line 72
Brevo\Client\Api\EventsApi::__construct(): Implicitly marking parameter $config as nullable is deprecated, the explicit nullable type must be used instead in lib/Api/EventsApi.php on line 72
Brevo\Client\Api\EventsApi::__construct(): Implicitly marking parameter $selector as nullable is deprecated, the explicit nullable type must be used instead in lib/Api/EventsApi.php on line 72

Proposed Solution

Generally speaking, across the whole project, it will be cool to set the expected types in method signatures, so that we don't have that kind of deprecations in the future.

Regarding the ones i've mentionned above, here's a quick fix in lib/Api/EventsApi.php.

public function __construct(
        ?ClientInterface $client = null,
        ?Configuration $config = null,
        ?HeaderSelector $selector = null
) {

Disclaimer

This fix will not be suitable for users that uses PHP < 7.1.

When does the support of PHP 5.6/7.0 will stop ?

LaurentBrieu avatar Mar 10 '25 13:03 LaurentBrieu

Noting that I'm also encountering this with PHP 8.4, with the CreateSmtpEmail construct

Deprecated: Brevo\Client\Model\CreateSmtpEmail::__construct(): Implicitly marking parameter $data as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/getbrevo/brevo-php/lib/Model/CreateSmtpEmail.php on line 183

Soben avatar Jun 17 '25 01:06 Soben