irazasyed / telegram-bot-sdk

🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
https://telegram-bot-sdk.com
BSD 3-Clause "New" or "Revised" License
2.99k stars 660 forks source link

Psalm check issue with generics #929

Closed Kravets1996 closed 2 years ago

Kravets1996 commented 2 years ago

Laravel 9 added PHPDoc template annotation (generics) in collections classes: https://github.com/laravel/framework/pull/38538

Because of that, on Laravel 9, psalm shows errors on this code:

Keyboard::make()

Error:

ERROR: TooManyTemplateParams - app/Modules/PasswordManager/Services/PasswordRequestMessageService.php:308:21 - Telegram\Bot\Keyboard\Keyboard<empty, empty> has too many template params, expecting 0 (see https://psalm.dev/184)
        $keyboard = Keyboard::make()->inline();

I added template annotations in this PR:

928

Kravets1996 commented 2 years ago

Template inheritance is defined in this docs: https://psalm.dev/docs/annotating_code/templated_annotations/#template-inheritance https://phpstan.org/blog/generics-in-php-using-phpdocs#class-level-generics