Skip to content

Commit

Permalink
BlankLineBeforeStatementFixer - add "phpdoc"
Browse files Browse the repository at this point in the history
  • Loading branch information
addiks authored and SpacePossum committed Dec 13, 2021
1 parent f2808cf commit 7ac2c41
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -17,4 +17,5 @@
*.php text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 diff=php
*.rst text whitespace=blank-at-eol,blank-at-eof
*.yml text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4
*.png binary eol=unset
/tests/Fixtures/**/* -text -filter
2 changes: 2 additions & 0 deletions src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php
Expand Up @@ -43,6 +43,8 @@ final class BlankLineBeforeStatementFixer extends AbstractFixer implements Confi
'continue' => T_CONTINUE,
'declare' => T_DECLARE,
'default' => T_DEFAULT,
'die' => T_EXIT,
'phpdoc' => T_DOC_COMMENT,
'do' => T_DO,
'exit' => T_EXIT,
'for' => T_FOR,
Expand Down
50 changes: 50 additions & 0 deletions tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php
Expand Up @@ -1491,6 +1491,56 @@ public function label(): string {
return "label";
}
}
',
];
}

/**
* @dataProvider provideFixWithDocCommentCases
*/
public function testFixWithDocCommentCases(string $expected, string $input = null): void
{
$this->fixer->configure([
'statements' => ['phpdoc'],
]);

$this->doTest($expected, $input);
}

public function provideFixWithDocCommentCases(): iterable
{
yield [
'<?php
/** @var int $foo */
$foo = 123;
/** @var float $bar */
$bar = 45.6;
/** @var string */
$baz = "789";
',
'<?php
/** @var int $foo */
$foo = 123;
/** @var float $bar */
$bar = 45.6;
/** @var string */
$baz = "789";
',
];

yield [
'<?php
/* header */
/**
* Class description
*/
class Foo {
/** test */
public function bar() {}
}
',
];
}
Expand Down

0 comments on commit 7ac2c41

Please sign in to comment.