Skip to content

Bugs openapi generator upgrade II - #948

Draft
ashwaniarya-adyen wants to merge 2 commits into
bugs-openapi-generator-upgradefrom
bugs-openapi-generator-upgrade-II
Draft

ashwaniarya-adyen wants to merge 2 commits into
bugs-openapi-generator-upgradefrom
bugs-openapi-generator-upgrade-II

Conversation

@ashwaniarya-adyen

Copy link
Copy Markdown
Contributor

Bugs openapi generator upgrade II

@ashwaniarya-adyen ashwaniarya-adyen self-assigned this Oct 6, 2026
@ashwaniarya-adyen
ashwaniarya-adyen changed the base branch from main to bugs-openapi-generator-upgrade October 6, 2026 12:22

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

high

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)

high

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)

high

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)

high

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)

high

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)

medium

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)

medium

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)

medium

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;

@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant