Updated Rector to commit 290926cc8b93331dd715d7ea061847dafbc1821a

290926cc8b  [Util] Make consistent new line splitter to Util  (#5651)
This commit is contained in:
Tomas Votruba 2024-02-21 15:30:52 +00:00
parent d7100344be
commit dc98feb11d
7 changed files with 33 additions and 18 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7e741fee0551af70bb6b3f45c95905fdf9d618ce';
public const PACKAGE_VERSION = '290926cc8b93331dd715d7ea061847dafbc1821a';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-02-21 22:15:12';
public const RELEASE_DATE = '2024-02-21 15:28:36';
/**
* @var int
*/

View File

@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\BetterPhpDocParser\PhpDocParser;
use RectorPrefix202402\Nette\Utils\Strings;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode;
use PHPStan\PhpDocParser\Lexer\Lexer;
@ -14,6 +13,7 @@ use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayP
use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\PlainValueParser;
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode;
use Rector\Util\NewLineSplitter;
/**
* Better version of doctrine/annotation - with phpdoc-parser and static reflection
* @see \Rector\Tests\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\StaticDoctrineAnnotationParserTest
@ -30,11 +30,6 @@ final class StaticDoctrineAnnotationParser
* @var \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser
*/
private $arrayParser;
/**
* @var string
* @see https://regex101.com/r/aU2knc/1
*/
private const NEWLINES_REGEX = "#\r?\n#";
/**
* @var string
* @see https://regex101.com/r/Pthg5d/1
@ -96,7 +91,7 @@ final class StaticDoctrineAnnotationParser
// the remaining of the annotation content is the comment
$comment = \substr($annotationContent, $tokenIterator->currentTokenOffset());
// we only keep the first line as this will be added as a line comment at the end of the attribute
$commentLines = Strings::split($comment, self::NEWLINES_REGEX);
$commentLines = NewLineSplitter::split($comment);
return $commentLines[0];
}
/**

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Console\Formatter;
use RectorPrefix202402\Nette\Utils\Strings;
use Rector\Util\NewLineSplitter;
use RectorPrefix202402\Symfony\Component\Console\Formatter\OutputFormatter;
/**
* Inspired by @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/src/Differ/DiffConsoleFormatter.php to be
@ -28,11 +29,6 @@ final class ColorConsoleDiffFormatter
* @see https://regex101.com/r/CMlwa8/1
*/
private const AT_START_REGEX = '#^(@.*)#';
/**
* @var string
* @see https://regex101.com/r/qduj2O/1
*/
private const NEWLINES_REGEX = "#\n\r|\n#";
/**
* @readonly
* @var string
@ -49,7 +45,7 @@ final class ColorConsoleDiffFormatter
private function formatWithTemplate(string $diff, string $template) : string
{
$escapedDiff = OutputFormatter::escape(\rtrim($diff));
$escapedDiffLines = Strings::split($escapedDiff, self::NEWLINES_REGEX);
$escapedDiffLines = NewLineSplitter::split($escapedDiff);
// remove description of added + remove; obvious on diffs
foreach ($escapedDiffLines as $key => $escapedDiffLine) {
if ($escapedDiffLine === '--- Original') {

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\PhpParser\Printer;
use PhpParser\Node\AttributeGroup;
use RectorPrefix202402\Nette\Utils\Strings;
use PhpParser\Comment;
use PhpParser\Node;
@ -113,10 +114,10 @@ final class BetterStandardPrinter extends Standard
$content = parent::p($node, $parentFormatPreserved);
return $node->getAttribute(AttributeKey::WRAPPED_IN_PARENTHESES) === \true ? '(' . $content . ')' : $content;
}
protected function pAttributeGroup(Node\AttributeGroup $node) : string
protected function pAttributeGroup(AttributeGroup $attributeGroup) : string
{
$ret = parent::pAttributeGroup($node);
$comment = $node->getAttribute(AttributeKey::ATTRIBUTE_COMMENT);
$ret = parent::pAttributeGroup($attributeGroup);
$comment = $attributeGroup->getAttribute(AttributeKey::ATTRIBUTE_COMMENT);
if (!\in_array($comment, ['', null], \true)) {
$ret .= ' // ' . $comment;
}

View File

@ -0,0 +1,21 @@
<?php
declare (strict_types=1);
namespace Rector\Util;
use RectorPrefix202402\Nette\Utils\Strings;
final class NewLineSplitter
{
/**
* @var string
* @see https://regex101.com/r/qduj2O/4
*/
private const NEWLINES_REGEX = "#\r?\n#";
/**
* @return string[]
*/
public static function split(string $content) : array
{
return Strings::split($content, self::NEWLINES_REGEX);
}
}

View File

@ -2422,6 +2422,7 @@ return array(
'Rector\\Util\\ArrayParametersMerger' => $baseDir . '/src/Util/ArrayParametersMerger.php',
'Rector\\Util\\FileHasher' => $baseDir . '/src/Util/FileHasher.php',
'Rector\\Util\\MemoryLimiter' => $baseDir . '/src/Util/MemoryLimiter.php',
'Rector\\Util\\NewLineSplitter' => $baseDir . '/src/Util/NewLineSplitter.php',
'Rector\\Util\\PhpVersionFactory' => $baseDir . '/src/Util/PhpVersionFactory.php',
'Rector\\Util\\Reflection\\PrivatesAccessor' => $baseDir . '/src/Util/Reflection/PrivatesAccessor.php',
'Rector\\Util\\StringUtils' => $baseDir . '/src/Util/StringUtils.php',

View File

@ -2641,6 +2641,7 @@ class ComposerStaticInit2d887a2f87c676eb32b3e04612865e54
'Rector\\Util\\ArrayParametersMerger' => __DIR__ . '/../..' . '/src/Util/ArrayParametersMerger.php',
'Rector\\Util\\FileHasher' => __DIR__ . '/../..' . '/src/Util/FileHasher.php',
'Rector\\Util\\MemoryLimiter' => __DIR__ . '/../..' . '/src/Util/MemoryLimiter.php',
'Rector\\Util\\NewLineSplitter' => __DIR__ . '/../..' . '/src/Util/NewLineSplitter.php',
'Rector\\Util\\PhpVersionFactory' => __DIR__ . '/../..' . '/src/Util/PhpVersionFactory.php',
'Rector\\Util\\Reflection\\PrivatesAccessor' => __DIR__ . '/../..' . '/src/Util/Reflection/PrivatesAccessor.php',
'Rector\\Util\\StringUtils' => __DIR__ . '/../..' . '/src/Util/StringUtils.php',