-
Notifications
You must be signed in to change notification settings - Fork 11
Fix parameter name for v6 #34
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughDependency 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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 (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.
⛔ 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 compatibilityPHPStan’s current stubs (ide-helper 6.x) still declare the first parameter as
$name
, so using a named argumentname_or_object:
breaks static analysis. In addition, the stub signature requiresexpires
as anint
andsamesite
as astring
(passingfalse
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
toint
andsamesite
tostring
matches the stub signature and prevents passingfalse
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 thatvendor/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 helperPinning 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.*", |
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 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.
"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.
Summary by CodeRabbit
Chores
Bug Fixes
Refactor