rector/packages/BetterPhpDocParser/Printer/DocBlockInliner.php
Tomas Votruba 7d0f151a40 Updated Rector to commit a2cd7283fbf2d6b2904016c51e3f4a545caa0256
a2cd7283fb Typo fix comment php 7.3 compat on rector workflow (#3432)
2023-03-01 13:00:30 +00:00

25 lines
678 B
PHP

<?php
declare (strict_types=1);
namespace Rector\BetterPhpDocParser\Printer;
use RectorPrefix202303\Nette\Utils\Strings;
final class DocBlockInliner
{
/**
* @var string
* @see https://regex101.com/r/Mjb0qi/1
*/
private const NEWLINE_CLOSING_DOC_REGEX = "#\n \\*\\/\$#";
/**
* @var string
* @see https://regex101.com/r/U5OUV4/2
*/
private const NEWLINE_MIDDLE_DOC_REGEX = "#\n \\* #";
public function inline(string $docContent) : string
{
$docContent = Strings::replace($docContent, self::NEWLINE_MIDDLE_DOC_REGEX, ' ');
return Strings::replace($docContent, self::NEWLINE_CLOSING_DOC_REGEX, ' */');
}
}