Fix #80: Add $options to Memcached::__construct()#80
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #80 +/- ##
============================================
+ Coverage 98.91% 98.93% +0.02%
- Complexity 43 45 +2
============================================
Files 1 1
Lines 92 94 +2
============================================
+ Hits 91 93 +2
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for passing Memcached extension options through the cache wrapper constructor and Yii DI configuration.
Changes:
- Adds an
$optionsconstructor argument and applies it viaMemcached::setOptions(). - Adds default
optionsparams and wires them into DI config. - Adds tests for valid and invalid Memcached options.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Memcached.php |
Adds constructor support for Memcached options. |
config/params.php |
Adds default empty options configuration. |
config/di.php |
Passes configured options into the Memcached constructor. |
tests/MemcachedTest.php |
Adds option-related tests and updates the test helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/MemcachedTest.php (1)
534-534: 💤 Low valueFollow PSR-12 method modifier order.
The method declaration uses
static public, but PSR-12 specifies the order should bepublic static.♻️ Suggested fix
- static public function optionsProvider(): array + public static function optionsProvider(): array🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/MemcachedTest.php` at line 534, The method declaration uses non-PSR-12 modifier ordering; change the declaration of the optionsProvider method from "static public function optionsProvider()" to use the canonical order "public static function optionsProvider()" so the method signature in the tests/MemcachedTest.php (function name: optionsProvider) follows PSR-12.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Memcached.php`:
- Around line 71-83: The code must explicitly detect when
$this->cache->setOptions($options) returns false in addition to catching
converted PHP errors; update the try block around
$this->cache->setOptions($options) (the call to setOptions on $this->cache) to
capture its return value, and if that value === false throw an
InvalidArgumentException (include diagnostic info such as
$this->cache->getResultMessage() and getResultCode() if available) so
configuration failures are not silently ignored; preserve the existing
ErrorException-to-InvalidArgumentException conversion and ensure
restore_error_handler() still runs in the finally block.
---
Nitpick comments:
In `@tests/MemcachedTest.php`:
- Line 534: The method declaration uses non-PSR-12 modifier ordering; change the
declaration of the optionsProvider method from "static public function
optionsProvider()" to use the canonical order "public static function
optionsProvider()" so the method signature in the tests/MemcachedTest.php
(function name: optionsProvider) follows PSR-12.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f93cbb98-91ea-4887-9865-c7098d221cd4
📒 Files selected for processing (4)
config/di.phpconfig/params.phpsrc/Memcached.phptests/MemcachedTest.php
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
vjik
left a comment
There was a problem hiding this comment.
- Add line to changelog
- Add info about new options to readme
|
@Gerych1984 it still fails tests. |
Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
$options to Memcached::__construct()
|
👍 |
Summary by CodeRabbit
New Features
Tests