Skip to content

feat(php): add consumer message iterator#3463

Open
countradooku wants to merge 3 commits into
apache:masterfrom
countradooku:feat/php-consumer-message-iterator
Open

feat(php): add consumer message iterator#3463
countradooku wants to merge 3 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.47%. Comparing base (8678ead) to head (7fba0aa).

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.57%   74.47%   -0.10%     
- Complexity      937      943       +6     
============================================
  Files          1249     1246       -3     
  Lines        123564   121523    -2041     
  Branches      99837    97597    -2240     
============================================
- Hits          92143    90504    -1639     
+ Misses        28438    28063     -375     
+ Partials       2983     2956      -27     
Components Coverage Δ
Rust Core 75.55% <ø> (-0.18%) ⬇️
Java SDK 58.44% <ø> (-0.14%) ⬇️
C# SDK 69.92% <ø> (+0.07%) ⬆️
Python SDK 81.06% <ø> (ø)
PHP SDK 84.29% <93.61%> (+0.71%) ⬆️
Node SDK 91.53% <ø> (+0.31%) ⬆️
Go SDK 40.20% <ø> (-0.05%) ⬇️
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 573 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

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

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PHP iterator API for consumer messages

1 participant