XeroAPI / xero-php-oauth2

Xero PHP SDK for oAuth 2 generated from Xero API OpenAPI Spec 3.0
MIT License
90 stars 64 forks source link

Use of reserved keyword EMPTY as a constant in Payroll AU API #258

Closed mattwatson-sf closed 6 months ago

mattwatson-sf commented 2 years ago

I am using the Payroll AU API to synchronise employee data. When invoking a function to update an employee - prior to any data being sent, I notice that PHP reports a syntax error specifically with one of the Xero PHP SDK Model files (LeaveLineCalculationType):

Parse error: syntax error, unexpected 'EMPTY' (T_EMPTY), expecting identifier (T_STRING) in vendor/xeroapi/xero-php-oauth2/lib/Models/PayrollAu/LeaveLineCalculationType.php on line 50

Looking into this Model file, on line 50 it defines a constant of EMPTY - which is a reserved keyword in PHP (you are not meant to use it for defining constants or function names):

const EMPTY = ''

It seems to be the only place in the entire Payroll AU API where this use of a reserved keyword is used. This is not a coding question - the syntax error is reported before any mapped data is passed into the function and/or sent to Xero. I simply think it's a syntax error in the SDK itself.

I've commented it out and the employee update processes successfully through to Xero

wobinb commented 2 years ago

I've proposed a solution at OAS level https://github.com/XeroAPI/Xero-OpenAPI/pull/466, please note that this has yet to be tested or released.

Once merged, it would flow through to the PHP SDK the next time it is auto generated.

mattwatson-sf commented 1 year ago

Hi - I've also noticed this error occur in the new CountryOfResidence model file

"unexpected 'EMPTY' (T_EMPTY), expecting identifier (T_STRING) in /var/www/secure/scripts/vendor/xeroapi/xero-php-oauth2/lib/Models/PayrollAu/CountryOfResidence.php on line 298"

Is there any indication of when this issue might be fixed?

mattwatson-sf commented 7 months ago

Hi @wobinb this bug is still open 2+ years later, are there any plans to fix it? I've reproduced it on PHP 5.6 all the way through to PHP 8.1

manishT72 commented 6 months ago

@mattwatson-sf Apologies for the delay. We have removed empty enums from OpenAPI and new version of PHP SDK is now available. Let us know if you still face the problem.

manishT72 commented 6 months ago

Issue is resolved in SDK v2.23.3.

mattwatson-sf commented 6 months ago

Thanks! Looks to be working well. Cheers!