M1I05: SocketProxyInterface + ReusePortProxy#61
Merged
Conversation
- SocketProxyInterface with createSocket(), accept(), isSupported() - ReusePortProxy implementing SO_REUSEADDR + SO_REUSEPORT - Unit tests with platform-aware skipping
s2x
commented
May 1, 2026
Contributor
Author
s2x
left a comment
There was a problem hiding this comment.
Review Summary — Round 1
| # | Severity | File:Line | Finding |
|---|---|---|---|
| 1 | MEDIUM | ReusePortProxyTest.php:27 |
Unnecessary skip in testCreateSocketReturnsSocket |
| 2 | LOW | ReusePortProxyTest.php:42 |
Unnecessary skip in testAcceptReturnsConnection |
Follow-up Observations
- Unused
$protocolparameter:ReusePortProxy::createSocket()acceptsProtocolType $protocolbut always createsAF_INET, SOCK_STREAM, SOL_TCPsockets regardless. Functionally correct for current types (TCP, HTTP, WS all run over TCP), but a future non-TCP protocol would silently get wrong socket type. Consider@paramdocs or amatchon protocol. 0.0.0.0for client connect:testAcceptReturnsConnectionconnects to$addressfromsocket_getsocknamewhich returns0.0.0.0. Existing tests (e.g.,SocketTest) bind to127.0.0.1explicitly. Consider binding to127.0.0.1in the proxy or overriding in the test for consistency.- No error-path tests: No test covers the
SocketCreationExceptionpath (e.g., whensocket_createfails).
What's Fine ✔️
- Interface signatures match spec exactly
isSupported()implementation matches spec (defined('SO_REUSEPORT') && PHP_OS_FAMILY !== 'Windows')- Conditional
SO_REUSEPORTlogic is correct - Test covers interface implementation, socket creation, accept, and isSupported
- No security issues (no secrets, PII, injection vectors)
- All acceptance criteria from issue #7 and milestone doc satisfied
s2x
commented
May 1, 2026
Contributor
Author
s2x
left a comment
There was a problem hiding this comment.
Review Summary — Round 2
| # | Severity | Status | Finding |
|---|---|---|---|
| 1 | MEDIUM | ✅ Fixed | testCreateSocketReturnsSocket had unnecessary isSupported() skip |
| 2 | LOW | ✅ Fixed | testAcceptReturnsConnection had same unnecessary skip |
Follow-up Observations
$protocolparam unused increateSocket— always creates TCP sockets. When HTTP/WebSocket support is added to proxy implementations, this parameter will be used for protocol-specific socket creation.- Reflection helper —
getSocketResource()could be extracted to a test trait if similar helpers are needed in other proxy tests.
What's Fine ✅
- All 4 CI checks pass (lint + tests on PHP 8.2–8.5)
- Interface signatures match spec exactly:
createSocket(),accept(),isSupported() ReusePortProxyimplementsSO_REUSEADDR+ conditionalSO_REUSEPORTcorrectlyisSupported()matches spec:defined('SO_REUSEPORT') && PHP_OS_FAMILY !== 'Windows'- All issue #7 acceptance criteria satisfied
- No security issues, secrets, PII, or injection vectors
- Code follows existing project patterns
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
src/Server/Socket/SocketProxyInterface.phpcreateSocket(),accept(),isSupported()src/Server/Socket/ReusePortProxy.phptests/Server/Socket/ReusePortProxyTest.phpAcceptance criteria
SocketProxyInterfacedefines 3 methods with correct signaturesReusePortProxyimplements the interface, usesSO_REUSEADDR+ conditionalSO_REUSEPORTisSupported()returnsfalseon Windows or when constant undefinedCloses #7