Skip to content

fix: cast integer values to string before rawurlencode in query string builder#36

Merged
pkotets merged 1 commit intoreaddle:masterfrom
vincentmary:fix/handle-int-values-in-query-string
Mar 16, 2026
Merged

fix: cast integer values to string before rawurlencode in query string builder#36
pkotets merged 1 commit intoreaddle:masterfrom
vincentmary:fix/handle-int-values-in-query-string

Conversation

@vincentmary
Copy link
Copy Markdown
Contributor

Fix rawurlencode() type error on integer query parameters

Fixes #34

Problem

When building a query string, integer values were passed directly to rawurlencode(), which expects a string. This caused a fatal error:

rawurlencode(): Argument #1 ($string) must be of type string, int given
For example, GetTransactionHistoryQueryParams defines startDate and endDate as int (Unix timestamps). Passing them to getQueryString() triggered the error:

  $params = new GetTransactionHistoryQueryParams();
  $params->startDate = 1700000000;
  $params->endDate   = 1710000000;

  $params->getQueryString(); // ❌ Fatal error: rawurlencode() expects string, int given

Solution

Added an explicit is_int check in AbstractRequestQueryParams::getQueryString() so integer values are appended directly without going through rawurlencode(), consistent with how booleans are already handled.

  } elseif (is_int($value)) {
      $queryStringParams[] = $propName . '=' . $value;
  }

Changes

  • src/RequestQueryParams/AbstractRequestQueryParams.php — added elseif (is_int($value)) branch to handle integer query parameters safely

@pkotets
Copy link
Copy Markdown
Collaborator

pkotets commented Mar 16, 2026

Thanks a lot for the fix, and especially for the test!
Adding test coverage for this library is still on my to-do list... :)

@pkotets pkotets merged commit 7c75fe4 into readdle:master Mar 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rawurlencode(): Argument #1 ($string) must be of type string, int given

2 participants