Mangopay / mangopay2-php-sdk

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

Bug fix/restool/issue 500 #507

Closed H4wKs closed 3 years ago

H4wKs commented 3 years ago
Q A
Branch ? Master
Bug Fix ? Yes
New feature ? No
Deprecation ? No
Tickets Fix #500 #506
Licence MIT

This PR fix the (Warning: Invalid argument supplied for foreach() in RestTool.php (line 379)) warning triggered in RestTool.php as stated in issue #500 and #506

This happen when $error->Errors is null while foreach expect an array. Add a cast (array) seem's to be a clean way to fix this.

Code Before

        foreach ($error->Errors as $key => $val) {
            $error->Message .= sprintf(' %s error: %s', $key, $val);
        }

Code After

        foreach ((array) $error->Errors as $key => $val) {
            $error->Message .= sprintf(' %s error: %s', $key, $val);
        }

Feedback welcome :)

H4wKs commented 3 years ago

I will make a new pull request. This one contain some update that were not mean to be here :x