Mangopay / mangopay2-php-sdk

PHP SDK for MANGOPAY
https://packagist.org/packages/mangopay/php-sdk-v2
MIT License
122 stars 133 forks source link

Incorrect nested ternary operator #470

Closed ldesgrange closed 3 years ago

ldesgrange commented 3 years ago

In RestTool.php there was the following code:

$error->Errors = property_exists($response, 'Errors')
    ? $response->Errors
    : property_exists($response, 'errors') ? $response->errors : null;

Which I think was wrong and has been automatically replaced by:

https://github.com/Mangopay/mangopay2-php-sdk/blob/d7538fe15150198261b0def8485cc352a6b5c096/MangoPay/Libraries/RestTool.php#L356-L358

See https://wiki.php.net/rfc/ternary_associativity, this makes it more explicit that the code was wrong as PHP had left-associative ternary operator (now deprecated).

The correct code should be:

$error->Errors = property_exists($response, 'Errors')
    ? $response->Errors
    : (property_exists($response, 'errors') ? $response->errors : null);

Thankfully MANGOPAY API seems to return errors (and not Errors) so this bug should not be triggered.

dduwoyemgp commented 3 years ago

Hello @ldesgrange We'll look into it, thanks

fredericdelordm commented 3 years ago

Thank @ldesgrange, it has been fixed.

If you have other feedback regarding this SDK, don't hesitate to book a slot in my agenda.