Repository navigation
Bugs openapi generator upgrade II - #948
ashwaniarya-adyen wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request upgrades the minimum PHP version to ^8.1 and introduces auto-generated models, handlers, and serializers for AcsWebhooks, BalanceWebhooks, BinLookup, and Checkout services. Feedback on these changes includes upgrading the guzzlehttp/psr7 constraint to ensure Guzzle's Utils class is available, using round() before casting float weights to integers to prevent precision loss, and explicitly checking for empty strings when reading stream chunks to avoid premature loop termination on falsy '0' values. Additionally, it is recommended to use strict comparisons and the modern str_contains function in BaseService, and to verify if php_uname is enabled before calling it in Configuration to prevent runtime exceptions.
I am having trouble creating individual review comments. Click here to see my feedback.
composer.json (17)
The code in ObjectSerializer.php now uses GuzzleHttp\Psr7\Utils::streamFor. However, the Utils class was only introduced in guzzlehttp/psr7 version 1.8.0. Since the constraint allows ^1.7, users with 1.7.x installed will encounter a fatal Class "GuzzleHttp\Psr7\Utils" not found error when deserializing streams (e.g., for \SplFileObject). Please update the constraint to ^1.8.1 || ^2.0 to ensure the Utils class is always available.
"guzzlehttp/psr7": "^1.8.1 || ^2.0"
src/Adyen/HeaderSelector.php (176)
Casting the result of a float multiplication directly to int can lead to unexpected precision loss (e.g., (int)("0.58" * 1000) might yield 579 instead of 580 depending on the PHP float representation). Using round() before casting to int ensures the weight is calculated correctly.
'weight' => (int) round($outputArray[2] * 1000),src/Adyen/Model/AcsWebhooks/ObjectSerializer.php (462-464)
In PHP, the string "0" is considered falsy. If a chunk read from the stream happens to be exactly "0", the loop condition while ($chunk = $data->read(200)) will evaluate to false and terminate prematurely, resulting in an incomplete/corrupted file write. To prevent this, explicitly check that the read chunk is not an empty string.
while (($chunk = $data->read(200)) !== '') {
fwrite($file, $chunk);
}src/Adyen/Model/BalanceWebhooks/ObjectSerializer.php (462-464)
In PHP, the string "0" is considered falsy. If a chunk read from the stream happens to be exactly "0", the loop condition while ($chunk = $data->read(200)) will evaluate to false and terminate prematurely, resulting in an incomplete/corrupted file write. To prevent this, explicitly check that the read chunk is not an empty string.
while (($chunk = $data->read(200)) !== '') {
fwrite($file, $chunk);
}src/Adyen/Model/BinLookup/ObjectSerializer.php (462-464)
In PHP, the string "0" is considered falsy. If a chunk read from the stream happens to be exactly "0", the loop condition while ($chunk = $data->read(200)) will evaluate to false and terminate prematurely, resulting in an incomplete/corrupted file write. To prevent this, explicitly check that the read chunk is not an empty string.
while (($chunk = $data->read(200)) !== '') {
fwrite($file, $chunk);
}src/Adyen/BaseService.php (46)
Use strict comparison === instead of loose comparison == to prevent unexpected type coercion and maintain consistency with the rest of the codebase.
if ($this->configuration->getEnvironment() === Environment::TEST) {src/Adyen/BaseService.php (52)
Since the minimum PHP version has been upgraded to ^8.1 in composer.json, you can use the more modern and readable str_contains function instead of strpos(...) !== false.
if (str_contains($url, '/authe/')) {src/Adyen/Configuration.php (672)
The php_uname function can be disabled in some environments for security reasons (via disable_functions in php.ini). Calling it when disabled will trigger a warning or throw an exception in PHP 8. It is safer to check if the function is enabled before calling it, falling back to the PHP_OS constant.
$report .= ' OS: ' . (function_exists('php_uname') ? php_uname() : PHP_OS) . PHP_EOL;
|



Bugs openapi generator upgrade II