2021-01-20 17:17:59 +01:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2021-01-20 17:17:59 +01:00
|
|
|
namespace Rector\BetterPhpDocParser\Printer;
|
|
|
|
|
2021-08-07 11:33:39 +00:00
|
|
|
use RectorPrefix20210807\Nette\Utils\Strings;
|
2021-01-20 17:17:59 +01:00
|
|
|
final class DocBlockInliner
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
* @see https://regex101.com/r/Mjb0qi/1
|
|
|
|
*/
|
2021-05-09 20:15:43 +00:00
|
|
|
private const NEWLINE_CLOSING_DOC_REGEX = "#\n \\*\\/\$#";
|
2021-01-20 17:17:59 +01:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
* @see https://regex101.com/r/U5OUV4/2
|
|
|
|
*/
|
2021-05-09 20:15:43 +00:00
|
|
|
private const NEWLINE_MIDDLE_DOC_REGEX = "#\n \\* #";
|
|
|
|
public function inline(string $docContent) : string
|
2021-01-20 17:17:59 +01:00
|
|
|
{
|
2021-08-07 11:33:39 +00:00
|
|
|
$docContent = \RectorPrefix20210807\Nette\Utils\Strings::replace($docContent, self::NEWLINE_MIDDLE_DOC_REGEX, ' ');
|
|
|
|
return \RectorPrefix20210807\Nette\Utils\Strings::replace($docContent, self::NEWLINE_CLOSING_DOC_REGEX, ' */');
|
2021-01-20 17:17:59 +01:00
|
|
|
}
|
|
|
|
}
|