Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array to string conversion error #465

Closed
ghost opened this issue Apr 7, 2021 · 6 comments · Fixed by #535
Closed

Array to string conversion error #465

ghost opened this issue Apr 7, 2021 · 6 comments · Fixed by #535

Comments

@ghost
Copy link

ghost commented Apr 7, 2021

\Zendesk\API\Debug::__toString()

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

@mtk3d
Copy link

mtk3d commented Apr 2, 2024

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

@ecoologic
Copy link
Contributor

ecoologic commented Apr 30, 2024

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
Copy link

mtk3d commented Apr 30, 2024

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
Copy link
Contributor

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
Copy link

mtk3d commented May 13, 2024

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

ecoologic added a commit that referenced this issue May 20, 2024
ecoologic added a commit that referenced this issue May 20, 2024
@ecoologic
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants