diff --git a/.gitattributes b/.gitattributes index d63c42d9e35..96b6e11132c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/doc/list.rst b/doc/list.rst index 5d756be46e3..f2224a48d0c 100644 --- a/doc/list.rst +++ b/doc/list.rst @@ -106,7 +106,7 @@ List of Available Rules - | ``statements`` | List of statements which must be preceded by an empty line. - | Allowed values: a subset of ``['break', 'case', 'continue', 'declare', 'default', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', 'yield_from']`` + | Allowed values: a subset of ``['break', 'case', 'continue', 'declare', 'default', 'die', 'phpdoc', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', 'yield_from']`` | Default value: ``['break', 'continue', 'declare', 'return', 'throw', 'try']`` diff --git a/doc/rules/whitespace/blank_line_before_statement.rst b/doc/rules/whitespace/blank_line_before_statement.rst index 21d6af01c2f..fa623d0f0a0 100644 --- a/doc/rules/whitespace/blank_line_before_statement.rst +++ b/doc/rules/whitespace/blank_line_before_statement.rst @@ -12,7 +12,7 @@ Configuration List of statements which must be preceded by an empty line. -Allowed values: a subset of ``['break', 'case', 'continue', 'declare', 'default', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', 'yield_from']`` +Allowed values: a subset of ``['break', 'case', 'continue', 'declare', 'default', 'die', 'phpdoc', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', 'yield_from']`` Default value: ``['break', 'continue', 'declare', 'return', 'throw', 'try']`` diff --git a/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php b/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php index 9e7cff6933c..ec0be673157 100644 --- a/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php +++ b/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php @@ -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, diff --git a/tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php b/tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php index 0fb8083208b..b56aab8498e 100644 --- a/tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php +++ b/tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php @@ -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 [ + '