-
Notifications
You must be signed in to change notification settings - Fork 11
Fix parameter name for v6 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthroughcomposer.json tightens Swoole dependency versions (ext-swoole to 6.x, swoole/ide-helper to 6.0.2). In src/Swoole/Response.php, the named argument for Swoole’s cookie() first parameter is updated from name to name_or_object. No control flow or public API changes. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
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 unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (2)
src/Swoole/Response.php (2)
188-191: - PHP 8.4 deprecation: make $content explicitly nullable and avoid passing null to Swoole end()Defaulting a string-typed parameter to null is deprecated in PHP 8.4. Update the signature and safely pass an empty string if no content is provided. Swoole’s end() expects a string; sending an empty body is equivalent to calling end() with no argument. (php.net, openswoole.com)
Apply:
- protected function end(string $content = null): void + protected function end(?string $content = null): void { - $this->swoole->end($content); + $this->swoole->end($content ?? ''); }
245-257: Fix Swoole v6 cookie() call – use positional arguments
The named argumentname_or_objectisn’t supported in Swoole v6 and is causing CI failures under CodeQL. Replace the named-arg call with positional arguments (which remain stable across versions) and update the docblock so thatsamesiteis typed as a string.Affected location:
• src/Swoole/Response.php (around lines 245–257)Required changes:
protected function sendCookie(string $name, string $value, array $options): void { - $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, + $options['expire'] ?? 0, + $options['path'] ?? '', + $options['domain'] ?? '', + (bool)($options['secure'] ?? false), + (bool)($options['httponly'] ?? false), + (string)($options['samesite'] ?? '') + ); }Also update the docblock for
$optionsto reflect thatsamesiteis a string:- * samesite?: bool + * samesite?: stringI scanned the entire codebase for any other named‐arg calls to
cookie()orsetCookie()and found none—this is the only spot that needs adjustment.
🧹 Nitpick comments (1)
src/Swoole/Response.php (1)
218-221: Pass status code as int (minor type clean-up)Swoole expects an int for the first argument to status(); avoid casting to string. (openswoole.com)
- $this->swoole->status((string) $statusCode, $this->getStatusCodeReason($statusCode)); + $this->swoole->status($statusCode, $this->getStatusCodeReason($statusCode));
📜 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.
⛔ Files ignored due to path filters (1)
composer.lockis 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: Deprecated in PHP 8.4: Parameter #1 $content (string) is implicitly nullable via default value null.
[error] 247-247: Missing parameter $name (mixed) in call to method Swoole\Http\Response::cookie().
[error] 248-248: Unknown parameter $name_or_object in call to method Swoole\Http\Response::cookie().
⏰ 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
| "php": ">=8.0", | ||
| "ext-swoole": "*", | ||
| "ext-swoole": "6.*", | ||
| "utopia-php/framework": "0.33.*" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^9.3", | ||
| "swoole/ide-helper": "5.0.2", | ||
| "swoole/ide-helper": "6.0.2", | ||
| "laravel/pint": "1.2.*", |
There was a problem hiding this comment.
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 requirements
You’ve bumped ext-swoole to 6.* and ide-helper to 6.0.2 (good), but composer still allows PHP >=8.0. Swoole 6 requires PHP >=8.1 per PECL/Packagist. Tighten the PHP constraint to prevent unsatisfiable installs on PHP 8.0 environments. (pecl.php.net, packagist.org)
- "php": ">=8.0",
+ "php": ">=8.1",
"ext-swoole": "6.*",📝 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.
| "php": ">=8.0", | |
| "ext-swoole": "*", | |
| "ext-swoole": "6.*", | |
| "utopia-php/framework": "0.33.*" | |
| }, | |
| "require-dev": { | |
| "phpunit/phpunit": "^9.3", | |
| "swoole/ide-helper": "5.0.2", | |
| "swoole/ide-helper": "6.0.2", | |
| "laravel/pint": "1.2.*", | |
| "php": ">=8.1", | |
| "ext-swoole": "6.*", | |
| "utopia-php/framework": "0.33.*" | |
| }, | |
| "require-dev": { | |
| "phpunit/phpunit": "^9.3", | |
| "swoole/ide-helper": "6.0.2", | |
| "laravel/pint": "1.2.*", |
🤖 Prompt for AI Agents
In composer.json around lines 16 to 23, the PHP engine constraint is ">=8.0" but
ext-swoole is set to "6.*" which requires PHP >=8.1; update the "php"
requirement to ">=8.1" (or a more specific range that includes 8.1+) so Composer
won't allow installs on PHP 8.0 and avoids unsatisfiable dependency resolution.
Summary by CodeRabbit