mailgun / mailgun-php

Mailgun's Official SDK for PHP
http://www.mailgun.com
MIT License
1.09k stars 314 forks source link

TypeError: Mailgun\Api\Suppression\Bounce::show() #878

Closed Quarkay closed 9 months ago

Quarkay commented 10 months ago

The code to replicate the issue is as follows:

$mg = Mailgun::create('key-example');
$mg->suppressions()->bounces()->show('domain', $email);

The error message is as follows:

TypeError: Mailgun\Api\Suppression\Bounce::show(): 
Return value must be of type ?Mailgun\Model\Suppression\Bounce\ShowResponse, Mailgun\Model\Suppression\Bounce\Bounce returned

The reason for this issue is:

  1. The create() method provided by the class Mailgun\Model\Suppression\Bounce\Bounce uses new self() during instantiation and use self as return type.
  2. Class Mailgun\Model\Suppression\Bounce\ShowResponse extended Mailgun\Model\Suppression\Bounce\ShowResponse,if we call ShowResponse::create() the actual return type will be Mailgun\Model\Suppression\Bounce\Bounce.
  3. In this commit, native php type restrictions were added for the show() method. This change exposed the issue.
oleksandr-mykhailenko commented 9 months ago

This one is fixed already. Thank you