feat(php): add consumer message iterator#3463
Open
countradooku wants to merge 3 commits into
Open
Conversation
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
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
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
Contributor
Author
|
/ready |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Iggy\Consumer::iterMessages()for PHP consumers, returning anIggy\MessageIteratorthat implements PHP'sIteratorinterface and yieldsIggy\ReceiveMessageinstances forforeachconsumption.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 --allcargo fmt --manifest-path foreign/php/Cargo.toml -- --checkphp -l foreign/php/iggy-php.stubs.php && php -l foreign/php/tests/IggySdkTest.phpdocker run php:8.3-cli-bookworm cargo check --manifest-path foreign/php/Cargo.tomlcargo clippy