Simplify regex pattern to known ranges
class SomeClass
{
public function run($value)
{
- preg_match('#[a-zA-Z0-9+]#', $value);
+ preg_match('#[\w\d+]#', $value);
}
}
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
SimplifyRegexPatternRector::class,
]);