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

[PHP 8.1] Return value must be of type Webklex\PHPIMAP\Events\Event, string returned

Open freescout-helpdesk opened this issue 2 years ago • 2 comments

Type error: Webklex\PHPIMAP\Message::getEvent(): Return value must be of type Webklex\PHPIMAP\Events\Event, string returned

Occurs in PHP 8.1 in /vendor/webklex/php-imap/src/Traits/HasEvents.php on line 63

freescout-helpdesk avatar Mar 13 '22 08:03 freescout-helpdesk

In PHP 8.1 it's actually not required to specify return types for all functions. You need to specify return type only when extending some class and this class has return type specified for this function.

freescout-helpdesk avatar Mar 13 '22 08:03 freescout-helpdesk

We should remove the return values from the class again. The return values were introduced only in PHP 7. Earlier PHP versions would run into an error with this.

Who wants can add the return values to inherited functions in his project.

HelloSebastian avatar Mar 13 '22 10:03 HelloSebastian

Hi @freescout-helpdesk @HelloSebastian , thanks for the report. This has been solved with the last release: https://github.com/Webklex/php-imap/blob/d90f4cdfa9dd9697c82a5bf3daa3e3d106377070/src/Traits/HasEvents.php#L53-L66

Best regards,

Webklex avatar Aug 25 '22 22:08 Webklex