==================================== Rule ``blank_line_before_statement`` ==================================== An empty line feed must precede any configured statement. Configuration ------------- ``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', 'phpdoc', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', 'yield_from']`` Default value: ``['break', 'continue', 'declare', 'return', 'throw', 'try']`` Examples -------- Example #1 ~~~~~~~~~~ *Default* configuration. .. code-block:: diff --- Original +++ New ['break']]``. .. code-block:: diff --- Original +++ New process(); + break; case 44: break; } Example #3 ~~~~~~~~~~ With configuration: ``['statements' => ['continue']]``. .. code-block:: diff --- Original +++ New isTired()) { $bar->sleep(); + continue; } } Example #4 ~~~~~~~~~~ With configuration: ``['statements' => ['do']]``. .. code-block:: diff --- Original +++ New 0); Example #5 ~~~~~~~~~~ With configuration: ``['statements' => ['exit']]``. .. code-block:: diff --- Original +++ New ['goto']]``. .. code-block:: diff --- Original +++ New ['if']]``. .. code-block:: diff --- Original +++ New ['return']]``. .. code-block:: diff --- Original +++ New ['switch']]``. .. code-block:: diff --- Original +++ New ['throw']]``. .. code-block:: diff --- Original +++ New bar(); + throw new \UnexpectedValueException("A cannot be null."); } Example #11 ~~~~~~~~~~~ With configuration: ``['statements' => ['try']]``. .. code-block:: diff --- Original +++ New bar(); } catch (\Exception $exception) { $a = -1; } Example #12 ~~~~~~~~~~~ With configuration: ``['statements' => ['yield']]``. .. code-block:: diff --- Original +++ New `_ with config: ``['statements' => ['break', 'case', 'continue', 'declare', 'default', 'exit', 'goto', 'include', 'include_once', 'phpdoc', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'yield', 'yield_from']]`` - `@Symfony <./../../ruleSets/Symfony.rst>`_ with config: ``['statements' => ['return']]`` References ---------- - Fixer class: `PhpCsFixer\\Fixer\\Whitespace\\BlankLineBeforeStatementFixer <./../../../src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php>`_ - Test class: `PhpCsFixer\\Tests\\Fixer\\Whitespace\\BlankLineBeforeStatementFixerTest <./../../../tests/Fixer/Whitespace/BlankLineBeforeStatementFixerTest.php>`_ The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.