xero-php-oauth2 icon indicating copy to clipboard operation
xero-php-oauth2 copied to clipboard

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

Open mattwatson-sf opened this issue 4 years ago • 1 comments

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

mattwatson-sf avatar Oct 25 '21 10:10 mattwatson-sf

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.

wobinb avatar Oct 25 '21 10:10 wobinb

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 avatar Dec 06 '22 13:12 mattwatson-sf

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

mattwatson-sf avatar Dec 18 '23 10:12 mattwatson-sf

@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 avatar Jan 23 '24 15:01 manishT72

Issue is resolved in SDK v2.23.3.

manishT72 avatar Jan 25 '24 12:01 manishT72

Thanks! Looks to be working well. Cheers!

mattwatson-sf avatar Jan 26 '24 01:01 mattwatson-sf