Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Psr16/MemcachedEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function __construct(?array $servers = null, $logger = null, ?array $opti
protected function fixKey(string $key): string
{
$key = $this->getKeyFromContainer($key);
$key = preg_replace('/[^A-Za-z0-9_\-]/', '-', $key);
return "cache-" . $key;
}
Comment on lines 52 to 57
Copy link

Choose a reason for hiding this comment

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

Undocumented Complex Regex Pattern category Readability

Tell me more
What is the issue?

The regex pattern '/[^A-Za-z0-9_\-]/' lacks clarity and documentation about its purpose.

Why this matters

Complex regex patterns without explanation make code maintenance difficult and increase cognitive load for developers trying to understand the key sanitization logic.

Suggested change ∙ Feature Preview
// Define regex pattern with explanation
protected function fixKey(string $key): string
{
    $key = $this->getKeyFromContainer($key);
    // Replace any character that is not alphanumeric, underscore, or hyphen with a hyphen
    $key = preg_replace('/[^A-Za-z0-9_\-]/', '-', $key);
    return "cache-" . $key;
}
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.


Expand Down