Updated Rector to commit d67342e4e23b577a259e2d2af0ed64461db9968b

d67342e4e2 Fix original quotes in PregReplaceEModifierRector (#5827)
This commit is contained in:
Tomas Votruba 2024-04-17 10:04:21 +00:00
parent b7b08c4396
commit 83bfbc18b8
3 changed files with 13 additions and 23 deletions

View File

@ -5,6 +5,7 @@ namespace Rector\Php55\Rector\FuncCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name;
@ -89,13 +90,11 @@ CODE_SAMPLE
$firstArgument = $node->getArgs()[0];
$firstArgumentValue = $firstArgument->value;
$patternWithoutEExpr = $this->regexMatcher->resolvePatternExpressionWithoutEIfFound($firstArgumentValue);
if ($patternWithoutEExpr === null) {
if (!$patternWithoutEExpr instanceof Expr) {
return null;
}
/** @var Arg $secondArgument */
$secondArgument = $node->args[1];
$secondArgumentValue = $secondArgument->value;
$anonymousFunction = $this->anonymousFunctionFactory->createAnonymousFunctionFromExpr($secondArgumentValue);
$secondArgument = $node->getArgs()[1];
$anonymousFunction = $this->createAnonymousFunction($secondArgument);
if (!$anonymousFunction instanceof Closure) {
return null;
}
@ -104,4 +103,8 @@ CODE_SAMPLE
$secondArgument->value = $anonymousFunction;
return $node;
}
private function createAnonymousFunction(Arg $arg) : ?Closure
{
return $this->anonymousFunctionFactory->createAnonymousFunctionFromExpr($arg->value);
}
}

View File

@ -7,14 +7,8 @@ use RectorPrefix202404\Nette\Utils\Strings;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Scalar\String_;
use Rector\PhpParser\Node\Value\ValueResolver;
final class RegexMatcher
{
/**
* @readonly
* @var \Rector\PhpParser\Node\Value\ValueResolver
*/
private $valueResolver;
/**
* @var string
* @see https://regex101.com/r/Ok4wuE/1
@ -30,20 +24,13 @@ final class RegexMatcher
* @see https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
*/
private const ALL_MODIFIERS_VALUES = ['i', 'm', 's', 'x', 'e', 'A', 'D', 'S', 'U', 'X', 'J', 'u'];
public function __construct(ValueResolver $valueResolver)
{
$this->valueResolver = $valueResolver;
}
/**
* @return \PhpParser\Node\Expr\BinaryOp\Concat|\PhpParser\Node\Scalar\String_|null
*/
public function resolvePatternExpressionWithoutEIfFound(Expr $expr)
{
if ($expr instanceof String_) {
$pattern = $this->valueResolver->getValue($expr);
if (!\is_string($pattern)) {
return null;
}
$pattern = $expr->value;
$delimiter = $pattern[0];
switch ($delimiter) {
case '(':
@ -67,8 +54,8 @@ final class RegexMatcher
if (\strpos($modifiers, 'e') === \false) {
return null;
}
$patternWithoutE = $this->createPatternWithoutE($pattern, $delimiter, $modifiers);
return new String_($patternWithoutE);
$expr->value = $this->createPatternWithoutE($pattern, $delimiter, $modifiers);
return $expr;
}
if ($expr instanceof Concat) {
return $this->matchConcat($expr);

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7574abd469cbfe569dd47dd9ae9e6aa668a0cf1b';
public const PACKAGE_VERSION = 'd67342e4e23b577a259e2d2af0ed64461db9968b';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-04-17 16:27:51';
public const RELEASE_DATE = '2024-04-17 10:01:56';
/**
* @var int
*/