Skip to content

Add support of google/protobuf v5.x - #15

Merged
roxblnfk merged 3 commits into
2.xfrom
feat/protobuf-v5
Jul 28, 2026
Merged

Add support of google/protobuf v5.x#15
roxblnfk merged 3 commits into
2.xfrom
feat/protobuf-v5

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Jul 28, 2026

Copy link
Copy Markdown
Member

Allows google/protobuf 5.x, the same way #13 allowed 4.x — the constraint becomes
^3.7 || ^4.0 || ^5.0. No source change is needed: the DTOs come from
roadrunner-php/roadrunner-api-dto, which already requires
google/protobuf: ^4.31.1 || ^5.34.0, so this package's upper bound is the only thing that keeps
protobuf 5 out of an installation.

Why it matters downstream: spiral/roadrunner-bridge ^4.0 depends on this package, so an
application that wants the bridge together with google/protobuf 5.x cannot have both — Composer
either fails to resolve or downgrades protobuf to 4.x.

The test commit

RPCCentrifugoApiTest::testPublish compares the publish tags with === against ['baz', 'baf'],
which also compares key order. The iteration order of a protobuf MapField is an implementation
detail of the runtime and it changed: on google/protobuf 4.33 a two-entry map already iterates back
to front ([1 => 'baf', 0 => 'baz']), so the test fails there — before this constraint change,
on 4.x. The first commit sorts the entries by key so the assertion checks the tag values it means to
check. Without it CI on this branch would be red for a reason unrelated to protobuf 5.

Verification

php 8.4.23, full suite green in both matrix legs CI uses:

Leg Resolved Result
prefer-stable google/protobuf v5.35.1, api-dto v1.14.1 121 tests, 425 assertions — OK
prefer-lowest google/protobuf v4.33.6, api-dto v1.8.0 121 tests, 425 assertions — OK

Note on the static analysis job: it is already failing on 2.x independently of this PR. Psalm 6
(the require-dev constraint is >= 5.8) reports 48 MissingOverrideAttribute / ClassMustBeFinal
issues; the count is identical with and without this branch, so it is left alone here.


🤖 Generated with Claude Code

Summary by CodeRabbit

  • Compatibility

    • Broadened supported Protocol Buffers versions, including Protobuf v5.x.
  • Bug Fixes

    • Fixed publish request tag validation to be consistent regardless of tag ordering.
  • Tests

    • Updated the test bootstrap process and added a Protobuf compatibility shim to keep unit tests working across different Protobuf runtime variants.

roxblnfk added 2 commits July 28, 2026 17:25
`MapField` iteration order is an implementation detail of the protobuf runtime,
and it changed: google/protobuf 4.33 already yields the two entries of the tags
map back to front, so the strict comparison against ['baz', 'baf'] fails because
`===` on arrays also compares key order. The test broke without anything in this
package changing.

Sort the entries by key before comparing, so the assertion checks what it means —
the tag values that were set — instead of the runtime's hash order.
Widen the constraint the same way #13 did for v4.x. Nothing in the source needs to
change: the DTOs come from roadrunner-php/roadrunner-api-dto, which already requires
google/protobuf ^4.31.1 || ^5.34.0, so this package's upper bound is the only thing
keeping protobuf 5 out of an installation.

The practical effect is on downstream packages: spiral/roadrunner-bridge ^4.0 depends
on this package, so an application that wants the bridge together with protobuf 5 is
forced back to protobuf 4.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8fa1f8d6-533a-44d8-9105-8ccf45087991

📥 Commits

Reviewing files that changed from the base of the PR and between 1dc378c and a9126dd.

📒 Files selected for processing (4)
  • phpunit.xml
  • tests/Unit/Request/ConnectTest.php
  • tests/Unit/Request/SubscribeTest.php
  • tests/bootstrap.php

📝 Walkthrough

Walkthrough

The Protobuf dependency constraint now includes v5.x, PHPUnit uses a compatibility bootstrap for repeated fields, and the publish RPC test normalizes tag-map ordering before comparison.

Changes

Protobuf compatibility

Layer / File(s) Summary
Protobuf version constraint
composer.json
Allows google/protobuf versions ^3.7, ^4.0, and ^5.0.
Test runtime compatibility
phpunit.xml, tests/bootstrap.php, tests/Unit/Request/ConnectTest.php, tests/Unit/Request/SubscribeTest.php
Loads the test bootstrap, aliases the internal repeated-field class when needed, and updates request tests to use the public class name.
Stable publish tag comparison
tests/Unit/RPCCentrifugoApiTest.php
Sorts publish request tags by key before test comparison.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: enabling google/protobuf v5.x support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/protobuf-v5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

`google/protobuf` moved `RepeatedField` out of the `Internal` namespace:
4.x left a deprecated shim behind, 5.x removed the file entirely. The
`class_alias()` for the old FQN sits at the bottom of the new class file,
so it is only registered once the new class has been loaded -- autoloading
`Google\Protobuf\Internal\RepeatedField` on its own fails on 5.x.

Tests now reference the public `Google\Protobuf\RepeatedField` and a test
bootstrap back-fills that FQN on protobuf 3.x, which still ships only the
`Internal` one. This also silences the deprecation notice emitted by the
4.x shim.

`MapField` is left untouched -- it has not been moved and still lives in
`Google\Protobuf\Internal` in every version, including upstream `main`.

Verified with 121 tests passing on PHP 8.1/protobuf 3.22.0 (--prefer-lowest),
PHP 8.2/protobuf 4.33.6, PHP 8.2/8.5/protobuf 5.35.1, and PHP 8.4 with the
protobuf C extension loaded.

Assisted-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@roxblnfk
roxblnfk merged commit 6022e35 into 2.x Jul 28, 2026
10 of 12 checks 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.

1 participant