zendesk / zendesk_api_client_php

Official Zendesk API v2 client library for PHP
336 stars 259 forks source link

Array to string conversion error #465

Closed ghost closed 4 months ago

ghost commented 3 years ago

\Zendesk\API\Debug::__toString()

$this->lastResponseHeaders and $this->lastRequestHeaders are arrays so method fails.

mtk3d commented 6 months ago

Also have this problem. Temporary quick fix for me is to use json_encode on Debug object instead of type casting to string.

ecoologic commented 5 months ago

Hi there @mtk3d,

Thank you for your contribution. Happy you found a way around this.

I can't replicate this issue:

$tickets = $client->tickets()->findAll(); // First page only
$client->getDebug()->lastResponseHeaders;

= [
    "Date" => [
      "Tue, 30 Apr 2024 22:36:08 GMT",
    ],
    "Content-Type" => [
      "application/json; charset=utf-8",
    ],
// etc..

Could you please provide a more complete example that's easier to reproduce?

mtk3d commented 5 months ago

Hi, of course 😄 The problem is when I'm trying to cast Debug object to string. Debug object has _toString() magic method, so I should be able to cast it to a string like this:

$debugContent = (string) $client->getDebug();

The problem is, that inside _toString() there is a concatination of lastResponseHeaders param with a string. In this case, PHP is trying to cast it to the string also, but lastResponseHeaders contains an array of headers, and it's not possible to directly cast it to a string.

ecoologic commented 4 months ago

Just a little update that I don't have an update yet, but we haven't forgotten, please bear with us. This doesn't sound blocking, but let us know if it's a big issue.

mtk3d commented 4 months ago

Thanks for update! Yes that's right, it's non-blocking issue

ecoologic commented 4 months ago

@mtk3d - can you take a look at the small PR above, please?