Type error in AccountContext. Doesn't recognize V2010 as a child of Twilio\Version
travisthomson opened this issue · comments
About once or twice a day, I see a recurring bug when sending an SMS message with the API. It does not seem to happen every time, far from it. But sometimes it gives me this error:
TypeError Twilio\Rest\Api\V2010\AccountContext::__construct(): Argument #1 ($version) must be of type Twilio\Version, Twilio\Rest\Api\V2010 given, called in /var/task/vendor/twilio/sdk/src/Twilio/Rest/Api/V2010.php on line 118
(I've included a longer stack trace below)
I'm confused by this because a V2010 is a child of Twilio\Version, and I only get this error about once every 200 times the same code snippet is run (with very similar parameters).
Here is the code snippet that triggers the error (but not every time!):
Edit: Sorry, initially included the wrong snippet. Here is the correct one:
use Twilio\Rest\Client;
$this->client = new Client(SID_HERE, AUTH_TOKEN_HERE);
$this->client->messages->create(
$toNumber,
array(
'from' => $fromNumber,
'body' => $message
)
);
Here is a longer stack trace:
TypeError Twilio\Rest\Api\V2010\AccountContext::__construct(): Argument #1 ($version) must be of type Twilio\Version, Twilio\Rest\Api\V2010 given, called in /var/task/vendor/twilio/sdk/src/Twilio/Rest/Api/V2010.php on line 118
vendor/twilio/sdk/src/Twilio/Rest/Api/V2010/AccountContext.php:118 Twilio\Rest\Api\V2010\AccountContext::__construct
vendor/twilio/sdk/src/Twilio/Rest/Api/V2010.php:118 Twilio\Rest\Api\V2010::getAccount
vendor/twilio/sdk/src/Twilio/Rest/Api/V2010.php:240 Twilio\Rest\Api\V2010::__get
vendor/twilio/sdk/src/Twilio/Rest/Client.php:543 Twilio\Rest\Client::getMessages
vendor/twilio/sdk/src/Twilio/Rest/Client.php:1036 Twilio\Rest\Client::__get
app/TwilioGateway.php:46 App\TwilioGateway::sendMessage
twilio-php version: 6.42.0
php version: 8.1
Sorry, I think this is likely more an issue on my serverless setup than the SDK.