verze-app / solana-php-sdk

Simple PHP SDK for Solana JSON RPC endpoints
MIT License
88 stars 45 forks source link

nullable return type for getConfirmedTransaction and getTransaction #45

Closed ComradePashka closed 2 years ago

ComradePashka commented 2 years ago

I was trying to implement some logic in Laravel(Lumen) project to get confirmed transactions, however if tx not confirmed yet it may return null value according to documentation: https://docs.solana.com/ru/developing/clients/jsonrpc-api#gettransaction

Even thought I enclose my code in try/catch block I could not handle rising Laravel exception:

In Connection.php line 40:
  Tighten\SolanaPhpSdk\Connection::getConfirmedTransaction(): Return value must be of type array, null returned

So after I changed PHPDoc section and signatures for getConfirmedTransaction() and getTransaction() calls it start working properly.

Maybe I encounter very Laravel-specific case, but I still thing it's better to have nullable return-types as it one of the possible return value for mentioned calls.

neverything commented 2 years ago

Good catch! I'll look into it

ComradePashka commented 2 years ago

oh.. so seems I can close PR now?