php-imap
php-imap copied to clipboard
[PHP 8.1] Return value must be of type Webklex\PHPIMAP\Events\Event, string returned
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
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.
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.
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,