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

type error in jsonSerialize functions in many objects #363

Open
kaeverens opened this issue Jul 31, 2024 · 3 comments
Open

type error in jsonSerialize functions in many objects #363

kaeverens opened this issue Jul 31, 2024 · 3 comments

Comments

@kaeverens
Copy link

SDK you're using (please complete the following information):

  • Version 7.0.1

Describe the bug
in the method jsonSerialize, $json is initialised as a plain array []

4 lines later, you try to set $json->Organisations on it. https://github.com/XeroAPI/xero-php-oauth2/blob/master/lib/Models/Accounting/Organisations.php#L311

this fails because [] is not an object. it's an array.

sample error message:

[31-Jul-2024 13:43:16 UTC] PHP Fatal error:  Uncaught Error: Attempt to assign property "Organisations" on array in /home/crm/www/vendor/xeroapi/xero-php-oauth2/lib/Models/Accounting/Organisations.php:311
Stack trace:
#0 [internal function]: XeroAPI\XeroPHP\Models\Accounting\Organisations->jsonSerialize()
#1 /home/crm/www/php/api.php(370): json_encode(Array, 2097152)
#2 {main}
  thrown in /home/crm/www/vendor/xeroapi/xero-php-oauth2/lib/Models/Accounting/Organisations.php on line 311

To Reproduce
Steps to reproduce the behavior:

  1. do something which causes jsonSerialize() to run.

Expected behavior
I expect it to just create the expected JSON and return it.

Additional context
if you change $json->Organisations to $json['Organisations'] that fixes the immediate problem, but you appear to have made the exact same mistake in other files as well (see Contacts.php in the same directory, line 344).

Copy link

PETOSS-497

Copy link

Thanks for raising an issue, a ticket has been created to track your request

@kaeverens
Copy link
Author

I can see the same issue in many different places, all from the same single commit:

e93aa28

@kaeverens kaeverens changed the title error in Accounting Organisations jsonSerialize type error in jsonSerialize functions in many objects Jul 31, 2024
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

No branches or pull requests

1 participant