Skip to content

feat(php): add consumer message iterator#3463

Merged
hubcio merged 4 commits into
apache:masterfrom
countradooku:feat/php-consumer-message-iterator
Jun 16, 2026
Merged

feat(php): add consumer message iterator#3463
hubcio merged 4 commits into
apache:masterfrom
countradooku:feat/php-consumer-message-iterator

Conversation

@countradooku

@countradooku countradooku commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Iggy\Consumer::iterMessages() for PHP consumers, returning an Iggy\MessageIterator that implements PHP's Iterator interface and yields Iggy\ReceiveMessage instances for foreach consumption.

The existing callback-based consumeMessages(callable, int $limit) path remains unchanged. The README and PHP stubs document the new API, and the PHP SDK tests now cover ordered iterator consumption.

Closes #3462

Validation

  • cargo fmt --all
  • cargo fmt --manifest-path foreign/php/Cargo.toml -- --check
  • php -l foreign/php/iggy-php.stubs.php && php -l foreign/php/tests/IggySdkTest.php
  • docker run php:8.3-cli-bookworm cargo check --manifest-path foreign/php/Cargo.toml
  • pre-commit hooks during commit
  • pre-push hooks during push, including cargo clippy

PHP consumers only exposed callback-driven consumption with a required finite limit. This adds a small Iterator implementation around the existing Rust consumer stream so PHP callers can compose message consumption with foreach while keeping consumeMessages() unchanged.

Constraint: PHP SDK is implemented as an ext-php-rs native extension

Constraint: Existing callback consumeMessages() behavior must remain compatible

Rejected: Add a generator implemented in PHP | the extension owns the Rust consumer stream and can expose Iterator directly

Confidence: medium

Scope-risk: narrow

Directive: Keep callback and iterator consumption semantics aligned around the same Rust consumer stream

Tested: cargo fmt --all

Tested: cargo fmt --manifest-path foreign/php/Cargo.toml -- --check

Tested: php -l foreign/php/iggy-php.stubs.php && php -l foreign/php/tests/IggySdkTest.php

Tested: docker run php:8.3-cli-bookworm cargo check --manifest-path foreign/php/Cargo.toml

Not-tested: Full PHP PHPUnit suite; foreign/php/Dockerfile.test installs PHP 8.2 while composer.json requires PHP >=8.3
@github-actions

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.65%. Comparing base (7f41bb9) to head (21b4f40).

Files with missing lines Patch % Lines
foreign/php/src/message_iterator.rs 93.18% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3463      +/-   ##
============================================
- Coverage     74.70%   74.65%   -0.06%     
  Complexity      937      937              
============================================
  Files          1256     1249       -7     
  Lines        124863   122776    -2087     
  Branches     100585    99301    -1284     
============================================
- Hits          93285    91653    -1632     
+ Misses        28578    28159     -419     
+ Partials       3000     2964      -36     
Components Coverage Δ
Rust Core 75.76% <ø> (+0.04%) ⬆️
Java SDK 58.57% <ø> (ø)
C# SDK 69.84% <ø> (-2.29%) ⬇️
Python SDK 88.88% <ø> (ø)
PHP SDK 84.29% <93.61%> (+0.71%) ⬆️
Node SDK 91.22% <ø> (-0.13%) ⬇️
Go SDK 39.54% <ø> (-0.83%) ⬇️
Files with missing lines Coverage Δ
foreign/php/src/consumer.rs 65.69% <100.00%> (+0.76%) ⬆️
foreign/php/src/message_iterator.rs 93.18% <93.18%> (ø)

... and 60 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The PHP lint job regenerates IDE stubs from the compiled extension and expects the checked-in file to match. The iterator method was documented before the generator's class order, so CI saw stub drift despite the extension building and tests passing.

Constraint: CI uses cargo php stubs from the compiled PHP extension as the source of truth
Rejected: Change Rust export ordering | the generator already emits a stable stub order and the code behavior does not need to move
Confidence: high
Scope-risk: narrow
Tested: cargo fmt --manifest-path foreign/php/Cargo.toml -- --check
Tested: php -l foreign/php/iggy-php.stubs.php && php -l foreign/php/tests/IggySdkTest.php
Tested: git diff --check
Not-tested: Full PHP 8.3 stub-generation lint locally; Docker daemon is unavailable and local PHP headers are 8.5/8.4, which fail ext-php-rs before this crate builds
@countradooku

Copy link
Copy Markdown
Contributor Author

/ready

Comment thread foreign/php/src/message_iterator.rs
Comment thread foreign/php/src/message_iterator.rs
Comment thread foreign/php/src/message_iterator.rs
Comment thread foreign/php/src/consumer.rs
Comment thread foreign/php/README.md
@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jun 15, 2026
@countradooku

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jun 16, 2026
@hubcio hubcio merged commit 5fcf40c into apache:master Jun 16, 2026
50 checks passed
@github-actions github-actions Bot removed the S-waiting-on-review PR is waiting on a reviewer label Jun 16, 2026
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.

Add PHP iterator API for consumer messages

3 participants