Merge pull request #2962 from rectorphp/fix-printer

cleanup extra space in doc print
This commit is contained in:
Tomas Votruba 2020-02-29 02:05:14 +01:00 committed by GitHub
commit f20d8e491b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 0 deletions

View File

@ -102,6 +102,9 @@ final class PhpDocInfoPrinter
$phpDocString = $this->printPhpDocNode($this->attributeAwarePhpDocNode);
// replace extra space after *
$phpDocString = Strings::replace($phpDocString, '#([^*])\*[ \t]+$#sm', '$1*');
// hotfix of extra space with callable ()
return Strings::replace($phpDocString, '#callable(\s+)\(#', 'callable(');
}

View File

@ -0,0 +1,5 @@
/**
* Test.
*
* @param string $param
*/

View File

@ -22,6 +22,18 @@ final class PhpDocInfoPrinterTest extends AbstractPhpDocInfoPrinterTest
$this->assertSame($docComment, $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo));
}
public function testRemoveSpace(): void
{
$docComment = FileSystem::read(__DIR__ . '/FixtureChanged/with_space.txt');
$phpDocInfo = $this->createPhpDocInfoFromDocCommentAndNode($docComment, new Nop());
$expectedDocComment = FileSystem::read(__DIR__ . '/FixtureChanged/with_space_expected.txt.inc');
$printedDocComment = $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo);
$this->assertSame($expectedDocComment, $printedDocComment);
}
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureBasic', '*.txt');