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

Error with getStatusCode() when doing $promise->wait()

Open AlexanderBech opened this issue 1 year ago • 4 comments

I'm suddenly getting the following error, when trying to send:

Fatal error: Declaration of SparkPost\SparkPostResponse::getStatusCode() must be compatible with Psr\Http\Message\ResponseInterface::getStatusCode(): int in /var/www/domain.com/public_html/includes/vendor/sparkpost/sparkpost/lib/SparkPost/SparkPostResponse.php on line 109

The error appears when doing: $response = $promise->wait();

My composer looks like this: "require": { "guzzlehttp/guzzle": "^7.0", "php-http/guzzle7-adapter": "^1", "sparkpost/sparkpost": "^2", "php-http/message": "^1.16", "php-http/message-factory": "^1.1" },

What is the issue?

I'm running PHP Version 8.2.12.

Update: I suspect this has something to do with something called PSR7, which i have no knowledge about.

Update 2: Solved! Adding this to my composers require solved it: "psr/http-message": "^1.1"

It downgraded from 2.0 to 1.1 when adding it manually.

AlexanderBech avatar Nov 03 '23 14:11 AlexanderBech

Can confirm that psr/http-message @ v1.1 fixes this issue for me too!

Didn't work at first with a composer require psr/http-message - seems like v2.0 is too much.

Thanks @AlexanderBech

Taelkir avatar Nov 20 '23 14:11 Taelkir

Your welcome! :)

AlexanderBech avatar Nov 21 '23 10:11 AlexanderBech

The exact same error started occurring for me today. I tried the suggested suggestion, but it doesn't work. Any other ideas?

danieleperilli avatar Jun 14 '24 09:06 danieleperilli