Skip to content

[CodeQuality] Deprecate SimplifyRegexPatternRector - #8263

Merged
TomasVotruba merged 1 commit into
mainfrom
deprecate-simplify-regex-pattern
Aug 2, 2026
Merged

[CodeQuality] Deprecate SimplifyRegexPatternRector#8263
TomasVotruba merged 1 commit into
mainfrom
deprecate-simplify-regex-pattern

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Deprecate SimplifyRegexPatternRector and remove it from the CodeQuality level set.

The rule shortens character ranges to shorthand classes:

 class SomeClass
 {
     public function run($value)
     {
-        preg_match('#[a-zA-Z0-9+]#', $value);
+        preg_match('#[\w\d+]#', $value);
     }
 }

Whether [a-zA-Z0-9_] or \w is more readable is a personal preference. Explicit ranges often communicate intent better, and the shorthand can hide subtle differences (e.g. unicode/locale behavior). This is a coding standard concern, not a code quality one.

Changes:

  • rule now implements DeprecatedInterface and throws on refactor()
  • removed from CodeQualityLevel
  • removed its tests and the now-unused RegexPatternDetector

…rence

The rule shortens ranges like [a-zA-Z0-9_] to \w. That is a matter of
personal preference and can worsen regex readability, so it belongs to
coding standard tooling rather than Rector.

Also removed from the CodeQuality level set.
@TomasVotruba
TomasVotruba merged commit 0247338 into main Aug 2, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-simplify-regex-pattern branch August 2, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant