From 3aaf5b74fbff675083333f8fb36764ffc6a4269a Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 27 Nov 2023 16:03:30 +0000 Subject: [PATCH] Updated Rector to commit b5f434b53c4c6fceb88c19d4656e4f11c6092f3c https://github.com/rectorphp/rector-src/commit/b5f434b53c4c6fceb88c19d4656e4f11c6092f3c [CodeQuality] Make CommonNotEqualRector skip if not <> (#5292) --- .../Rector/NotEqual/CommonNotEqualRector.php | 20 ++++++++++++++++++- src/Application/VersionResolver.php | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php b/rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php index e7c0bdfba68..9c60c38fe8f 100644 --- a/rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php +++ b/rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php @@ -47,10 +47,28 @@ CODE_SAMPLE /** * @param NotEqual $node */ - public function refactor(Node $node) : NotEqual + public function refactor(Node $node) : ?NotEqual { + if (!$this->doesNotEqualContainsShipCompareToken($node)) { + return null; + } // invoke override to default "!=" $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } + private function doesNotEqualContainsShipCompareToken(NotEqual $notEqual) : bool + { + $tokenStartPos = $notEqual->getStartTokenPos(); + $tokenEndPos = $notEqual->getEndTokenPos(); + for ($i = $tokenStartPos; $i < $tokenEndPos; ++$i) { + $token = $this->file->getOldTokens()[$i]; + if (!isset($token[1])) { + continue; + } + if ($token[1] === '<>') { + return \true; + } + } + return \false; + } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index ffc350ac7b7..00cd4c8fb9b 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 = 'e66754adeaad2e9cb67cf1784a6255285dfc542d'; + public const PACKAGE_VERSION = 'b5f434b53c4c6fceb88c19d4656e4f11c6092f3c'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-11-27 13:43:57'; + public const RELEASE_DATE = '2023-11-27 16:01:26'; /** * @var int */