EndOfStreamAwareHttpWorkerInterface#32
Conversation
📝 WalkthroughWalkthroughA new interface Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/EndOfStreamAwareHttpWorkerInterface.php (1)
12-24: Missing@paramtag for$endOfStream.The docblock documents
$status,$body, and$headersbut omits the$endOfStreamparameter, which is the primary reason this interface exists.📝 Proposed fix
* that header. + * `@param` bool $endOfStream Whether this is the last response in the stream. */🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/EndOfStreamAwareHttpWorkerInterface.php` around lines 12 - 24, The docblock for the respond method in EndOfStreamAwareHttpWorkerInterface is missing a `@param` entry for the $endOfStream parameter; update the PHPDoc for the respond method (respond(int $status, string|\Generator $body = '', array $headers = [], bool $endOfStream = true): void) to add a `@param` bool $endOfStream description explaining that it controls whether the last chunk ends the stream (true by default) so the interface documentation matches the method signature and purpose.src/HttpWorker.php (1)
41-41: Redundant interface declaration, but acceptable given the migration plan.
EndOfStreamAwareHttpWorkerInterfacealready extendsHttpWorkerInterface, so explicitly listing both is redundant. However, since the PR notes thatEndOfStreamAwareHttpWorkerInterfacemay be removed in the future (folding$endOfStreamintoHttpWorkerInterface), keeping both explicit makes the future removal a smaller diff.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/HttpWorker.php` at line 41, The class declaration lists both EndOfStreamAwareHttpWorkerInterface and HttpWorkerInterface, which is technically redundant because EndOfStreamAwareHttpWorkerInterface already extends HttpWorkerInterface; leave both interfaces on the HttpWorker class declaration as-is to minimize future diffs during the planned migration, and add a short inline comment near the class declaration (referencing class HttpWorker) explaining that both are kept intentionally for a smoother future removal of EndOfStreamAwareHttpWorkerInterface.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/EndOfStreamAwareHttpWorkerInterface.php`:
- Around line 12-24: The docblock for the respond method in
EndOfStreamAwareHttpWorkerInterface is missing a `@param` entry for the
$endOfStream parameter; update the PHPDoc for the respond method (respond(int
$status, string|\Generator $body = '', array $headers = [], bool $endOfStream =
true): void) to add a `@param` bool $endOfStream description explaining that it
controls whether the last chunk ends the stream (true by default) so the
interface documentation matches the method signature and purpose.
In `@src/HttpWorker.php`:
- Line 41: The class declaration lists both EndOfStreamAwareHttpWorkerInterface
and HttpWorkerInterface, which is technically redundant because
EndOfStreamAwareHttpWorkerInterface already extends HttpWorkerInterface; leave
both interfaces on the HttpWorker class declaration as-is to minimize future
diffs during the planned migration, and add a short inline comment near the
class declaration (referencing class HttpWorker) explaining that both are kept
intentionally for a smoother future removal of
EndOfStreamAwareHttpWorkerInterface.
|
I would suggest making version 4 right away.
|
|
I think, that releasing a major version just for this change is premature. Here are my thoughts: The current change is too minor to warrant a major version bump. It doesn't break backward compatibility. The new interface simply extends the existing one, and everyone already using Additionally, this package has dependents (including third-party ones) that are unlikely to update quickly to In my opinion, we need a smoother transition. Here's how I see the update process: Stage 1 (current, version 3.x):
Stage 2 (major version 4):
Stage 3 (major version 5):
This approach gives the community time to migrate smoothly:
|
|
Example of smoother upgrading code, that used Before We can't use function action(HttpWorkerInterface $worker): void
{
$worker->respond(200, 'OK');
}Step 1 If we needs set parameter function action(HttpWorkerInterface $worker): void
{
if ($worker instanceof EndOfStreamAwareHttpWorkerInterface) {
$worker->respond(200, 'OK', endOfStream: true);
} else {
$worker->respond(200, 'OK');
}
}Step 2 Upgrade to
We can refactor code and remove checks of function action(HttpWorkerInterface $worker): void
{
$worker->respond(200, 'OK', endOfStream: true);
}Step 3 Upgrade to
We MUST refactor our code, if we haven't done it yet |
|
In my opinion, releasing version 4 will be better than adding an obviously outdated interface. Updating to v4 won't be difficult unless someone implements the |
|
At this moment 52 public packages depends of Also, the big part of these packages are depends of php >=8.1. I'm more in favor of a smooth upgrade. But if you think it's the right thing to do, then I've created a PR #33 to prepare v4 release. |
Alternative solution of #30.
Instead of rewriting the
HttpWorkerInterface, I createdEndOfStreamAwareHttpWorkerInterface, which overrides the respond method and adds an optionalbool$endOfStreamargument.The
HttpWorkerclass now implementsEndOfStreamAwareHttpWorkerInterface.This change doesn't break BC.
In the future, the
$endOfStreamargument can be added to the mainHttpWorkerInterface, andEndOfStreamAwareHttpWorkerInterfacecan be removed.Summary by CodeRabbit