Skip to content

Commit

Permalink
[CodeQuality] Skip surplus open square bracket on SimplifyRegexPatter…
Browse files Browse the repository at this point in the history
…nRector (#5494)

* [CodeQuality] Skip surplus open square bracket on SimplifyRegexPatternRector

* [CodeQuality] Skip surplus open square bracket on SimplifyRegexPatternRector
  • Loading branch information
samsonasik committed Jan 23, 2024
1 parent bcce8e3 commit dd02659
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
@@ -0,0 +1,11 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector\Fixture;

class SkipSurplusOpenSquareBracket
{
public function run()
{
$purln = preg_replace("/[^[a-zA-Z0-9_]/", "", "test");
}
}
Expand Up @@ -92,6 +92,11 @@ public function refactor(Node $node): ?Node
continue;
}

$countSqureOpenBracket = substr_count($simplifiedValue, '[');
if ($countSqureOpenBracket % 2 === 1) {
continue;
}

$node->value = $simplifiedValue;
return $node;
}
Expand Down

0 comments on commit dd02659

Please sign in to comment.