From 83bfbc18b870232ba74020b44e20e9e8116aea5e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 17 Apr 2024 10:04:21 +0000 Subject: [PATCH] Updated Rector to commit d67342e4e23b577a259e2d2af0ed64461db9968b https://github.com/rectorphp/rector-src/commit/d67342e4e23b577a259e2d2af0ed64461db9968b Fix original quotes in PregReplaceEModifierRector (#5827) --- .../FuncCall/PregReplaceEModifierRector.php | 13 ++++++++----- rules/Php55/RegexMatcher.php | 19 +++---------------- src/Application/VersionResolver.php | 4 ++-- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php b/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php index ed519c5e7d3..0146b0b80cf 100644 --- a/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php +++ b/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php @@ -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); + } } diff --git a/rules/Php55/RegexMatcher.php b/rules/Php55/RegexMatcher.php index 2b737a3d38d..f44a7608dc6 100644 --- a/rules/Php55/RegexMatcher.php +++ b/rules/Php55/RegexMatcher.php @@ -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); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 529082d84d3..a6f73b4339d 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -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 */