-
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
Conversation
Walkthroughcomposer.json dependency constraints were tightened: 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, value, expires, path, domain, secure, httponly, samesite)
Svr-->>Resp: Cookie set
Resp-->>App: Done
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
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.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: 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 requiresexpiresas anintandsamesiteas astring(passingfalsewill be rejected). Casting each$options[...]value ensures you never pass the wrong type.Apply this diff in
src/Swoole/Response.phparound 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
$nameunblocks PHPStan without relying on the stub’s internal parameter name.- Casting
expirestointandsamesitetostringmatches the stub signature and prevents passingfalseto 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 512Mpasses 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
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: 0
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)
247-256: Incorrect parameter name for Swoole 6.x Response::cookie() method.The parameter should be
name, notname_or_object. According to the official Swoole 6.0 documentation, the Response::cookie() method signature usesnameas the parameter:$response->cookie( name: 'sid', value: 'abc', expires: time() + 3600, path: '/', domain: 'example.com', secure: true, httponly: true, );Change line 248 back to
name: $name,to match the actual Swoole 6.x API.
Summary by CodeRabbit
Chores
Bug Fixes
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.