Php-cs-fixer: PhpDoc: no extra empty lines

Created on 19 Jan 2016  路  10Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

Target: 1.x line

Code before:

<?php

/**
 * Description.
 *
 *
 * @var int
 */
$foo = 1;

Code after:

<?php

/**
 * Description.
 *
 * @var int
 */
$foo = 1;
easy pick kinfeature request topiannotation

Most helpful comment

would you be fine guys to trim any consecutive blank lines, not only ones after summary/description ?
(as one, single fixer, no config)

All 10 comments

We already have a fixer that nearly does that.

Updated feature specification to not partially duplicate PhpdocTrimFixer

I didn't originally add a fixer like this on purpose because the integration testing across lots of php repos showed that sometimes multiple lines breaks where indeed wanted, say when using complex markdown or code examples inside the phpdoc.

It should not touch content of part of docblock (like annotation/description/summary), but the space between them.
And even if we could not reach that - the fixer would be useful for some repos ;)

Sure. This should be quite easy to implement.

/**
 * Summary.
 *
 *
 * Description.
 *
 *
 * @var int
 *
 *
 * @return int
 *
 *
 * foo
 */
$foo = 1;

Extra blank line shall be removed after Summary and after Description.
One between annotations is already removed by phpdoc_separation, probably it shall not do it anymore and it shall be done only by new fixer.

Why reopening the issue?

because I think there are still cases where PhpDoc's have extra empty lines which can/should be removed. Example:

final class ClassKeywordRemoveFixerTest extends AbstractFixerTestCase
{
    /**
     * @param string      $expected
     * @param null|string $input
     *
     *
     *
     *
     * @dataProvider provideFixCases
     */
    public function testFix($expected, $input = null)
    {
        $this->doTest($expected, $input);
    }
}

would you be fine guys to trim any consecutive blank lines, not only ones after summary/description ?
(as one, single fixer, no config)

ref #3802

Was this page helpful?
0 / 5 - 0 ratings