Skip to content

Conversation

abnegate
Copy link
Member

@abnegate abnegate commented Aug 26, 2025

Summary by CodeRabbit

  • Chores

    • Updated runtime requirement to Swoole 6.x for improved compatibility and stability.
    • Refreshed development tooling to the latest Swoole IDE helper 6.x.
  • Bug Fixes

    • Ensures cookie handling works correctly when running on Swoole 6.
  • Refactor

    • Minor internal adjustments to align with Swoole 6 behavior without changing public APIs.

Copy link

coderabbitai bot commented Aug 26, 2025

Walkthrough

Dependency constraints updated in composer.json to require Swoole 6.x and matching IDE helper. In src/Swoole/Response.php, the named argument in the internal Swoole cookie() call was adjusted from name to name_or_object to align with Swoole 6. No public API changes.

Changes

Cohort / File(s) Summary
Dependency constraints (Swoole 6)
composer.json
Narrowed ext-swoole from * to 6.*; bumped swoole/ide-helper from 5.0.2 to 6.0.2.
Swoole response cookie API alignment
src/Swoole/Response.php
Updated named parameter in call to Swoole cookie() from name to name_or_object; method signature unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App Code
  participant Resp as Response (this lib)
  participant Svr as Swoole\Http\Response (v6)

  App->>Resp: sendCookie(name, value, options)
  note right of Resp: Map options to Swoole cookie call
  Resp->>Svr: cookie(name_or_object: name, value, expires, path, domain, secure, httponly, samesite)
  Svr-->>Resp: Cookie set
  Resp-->>App: Done
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nudge my whiskers at version six,
Tighten the deps with tidy clicks.
A cookie by name_or_object I send—
Hop, hop, compatibility mend.
In burrows of code, I lightly tread,
Carrots for builds that stay ahead. 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-v6

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Swoole/Response.php (1)

188-191: Fix PHP 8.4 deprecation: implicitly nullable parameter in end()

The signature declares string $content with a default null, which is deprecated in PHP 8.4 and is breaking CodeQL/PHPStan in CI. Switch to a nullable string.

Apply this diff:

-    protected function end(string $content = null): void
+    protected function end(?string $content = null): void
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1af73dd and b682c3e.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • composer.json (1 hunks)
  • src/Swoole/Response.php (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: CodeQL
src/Swoole/Response.php

[error] 188-188: PHPStan: Deprecated in PHP 8.4: Parameter #1 $content (string) is implicitly nullable via default value null. Command './vendor/bin/phpstan analyse --level 6 src tests --memory-limit 512M' returned with exit code 1.


[error] 247-247: PHPStan: Missing parameter $name (mixed) in call to method Swoole\Http\Response::cookie(). Command './vendor/bin/phpstan analyse --level 6 src tests --memory-limit 512M' returned with exit code 1.


[error] 248-248: PHPStan: Unknown parameter $name_or_object in call to method Swoole\Http\Response::cookie(). Command './vendor/bin/phpstan analyse --level 6 src tests --memory-limit 512M' returned with exit code 1.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Unit & E2E
🔇 Additional comments (2)
src/Swoole/Response.php (1)

247-256: Tighten Swoole cookie call for PHPStan compatibility

PHPStan’s current stubs (ide-helper 6.x) still declare the first parameter as $name, so using a named argument name_or_object: breaks static analysis. In addition, the stub signature requires expires as an int and samesite as a string (passing false will be rejected). Casting each $options[...] value ensures you never pass the wrong type.

Apply this diff in src/Swoole/Response.php around line 247:

-        $this->swoole->cookie(
-            name_or_object: $name,
-            value: $value,
-            expires: $options['expire'] ?? 0,
-            path: $options['path'] ?? '',
-            domain: $options['domain'] ?? '',
-            secure: $options['secure'] ?? false,
-            httponly: $options['httponly'] ?? false,
-            samesite: $options['samesite'] ?? false,
-        );
+        $this->swoole->cookie(
+            $name,
+            value: $value,
+            expires: (int) ($options['expire'] ?? 0),
+            path: (string) ($options['path'] ?? ''),
+            domain: (string) ($options['domain'] ?? ''),
+            secure: (bool) ($options['secure'] ?? false),
+            httponly: (bool) ($options['httponly'] ?? false),
+            samesite: (string) ($options['samesite'] ?? ''),
+        );

Key points:

  • Switching the first argument to positional $name unblocks PHPStan without relying on the stub’s internal parameter name.
  • Casting expires to int and samesite to string matches the stub signature and prevents passing false to a parameter that expects a string.

After merging, please confirm locally that dependencies install (you may need --ignore-platform-req=ext-swoole --ignore-platform-req=ext-opentelemetry) and that

vendor/bin/phpstan analyse --level 6 src tests --memory-limit 512M

passes with zero errors.

composer.json (1)

17-17: LGTM on constraining to Swoole v6 + matching IDE helper

Pinning ext-swoole to 6.* and upgrading swoole/ide-helper to 6.0.2 are consistent with the code change in Response::sendCookie. No issues here.

Also applies to: 22-22

"require": {
"php": ">=8.0",
"ext-swoole": "*",
"ext-swoole": "6.*",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Align PHP engine constraint with Swoole 6 minimum (>= 8.1)

Swoole 6.x requires PHP >= 8.1. Keeping "php": ">=8.0" allows installing this package on platforms that cannot satisfy ext-swoole:6.*, leading to confusing Composer resolution failures. Bump the PHP requirement to be explicit.

Apply this diff:

-        "php": ">=8.0",
+        "php": ">=8.1",

References: Swoole 6.0.2 requires PHP >= 8.1 (Packagist/PECL). (packagist.org, pecl.php.net)

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"ext-swoole": "6.*",
"php": ">=8.1",
"ext-swoole": "6.*",
🤖 Prompt for AI Agents
In composer.json around line 17, the package requires "ext-swoole": "6.*" but
the project PHP engine constraint is still ">=8.0"; change the "php" requirement
to ">=8.1" to match Swoole 6's minimum PHP version, then run composer validate
and update the lockfile (e.g., composer update --lock or composer update) to
ensure composer.lock reflects the new PHP constraint.

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