Skip to content

[Release v1.0] Add missing query builder methods, api resources, and other improvements#14

Merged
ianhalpern merged 6 commits into
masterfrom
release/v1.0.0
Feb 18, 2026
Merged

[Release v1.0] Add missing query builder methods, api resources, and other improvements#14
ianhalpern merged 6 commits into
masterfrom
release/v1.0.0

Conversation

@ianhalpern
Copy link
Copy Markdown
Contributor

@ianhalpern ianhalpern commented Feb 12, 2026

Description

Major update to the Payload PHP SDK bringing it up to parity with the Node.js SDK. Adds missing query builder methods, new API resource classes, improved subclass discovery, and reorganized tests.

Changes include:

  • Add order_by, limit, and offset methods to ARMRequest and ARMObject for query building
  • Add default_params support on ARMObject subclasses, applied automatically to requests (user params take precedence)
  • Add InvoiceAttachment, WebhookLog, and Ledger API resource classes
  • Replace get_declared_classes() subclass scan in Utils::data2object with a lazy-loading registry on ARMObject that auto-discovers all classes via glob(__DIR__) + require_once
  • Fix group_by in ARMRequest incorrectly writing to fields param instead of group_by
  • Fix endpoint generation to handle object names already ending in 's'
  • Refactor ARMObject to use _build_request helper for consistent request construction
  • Declare ARMRequest properties explicitly (PHP 8.2+ compatibility)
  • Change include() to require_once() for Exceptions loading
  • Reorganize tests into Tests/Unit and Tests/Int directories
  • Add QueryParamsTest unit tests covering order_by, limit, offset, chaining, and default_params
  • Split CI workflow to run unit tests separately from integration tests
  • Apply phpcbf code formatting across all files

Type of change

  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking change which enhances functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Potential breaking change

Utils::data2object now uses a lazy-loading registry that auto-discovers all class files in the Payload/ directory via glob() + require_once. Previously, if a class file wasn't explicitly loaded, nested objects of that type would be left as plain associative arrays. Now all classes are always loaded, so nested objects will be deserialized into class instances where they previously may have remained arrays. Any code that accesses nested objects using array syntax (e.g. $val['key']) instead of property access (e.g. $val->key) may break.

@ianhalpern ianhalpern changed the title Release v1.0Add missing ordering and paging methods, object classes, and other fixes [Release v1.0] Add missing ordering and paging methods, object classes, and other fixes Feb 12, 2026
@ianhalpern ianhalpern changed the title [Release v1.0] Add missing ordering and paging methods, object classes, and other fixes [Release v1.0] Add missing query builder methods, api resources, and other improvements Feb 12, 2026
@ianhalpern ianhalpern requested a review from a team February 12, 2026 02:39
Comment thread Payload/ARMRequest.php
if (!Utils::is_assoc_array($obj)) {
$obj = ['object'=>'list', 'values'=>$obj];
}
if ($obj instanceof ARMObject) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If we're converting the $obj parameter to an array/list on line 199, wouldn't this if condition never be called?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We're only converting it to an array/list if it's a regular array instead of a associative array

Comment thread Payload/ARMObject.php Outdated
private static $_object_cache = [];
private static $_registry = [];
public static $spec = [];
public static $default_params = null;
Copy link
Copy Markdown

@russellw-dev russellw-dev Feb 17, 2026

Choose a reason for hiding this comment

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

Could be wrong here but in looking at how static properties/inheritance work in PHP, it looks like if we set this on a subclass it will then set it for every other subclass, which it looks like the test here is doing - is that something we want to happen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh yea, looks like that's right. Awesome find, will fix.

@russellw-dev
Copy link
Copy Markdown

In Payload/API.php and composer.json should we bump the version to 1.0.0 per the branch name?

@ianhalpern ianhalpern merged commit d5265a1 into master Feb 18, 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.

2 participants