From 170a09fac23f90ea2db6490a8777133a61e9cf48 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 31 Aug 2021 00:10:30 +0700 Subject: [PATCH] [CodingStyle] Add more statements for NewlineAfterStatementRector (#792) * [CodingStyle] Add more statements for NewlineAfterStatementRector * cs fix --- .../Fixture/no_new_line_classlike.php.inc | 57 +++++++++++++++++++ .../Fixture/no_new_line_try_catch.php.inc | 32 +++++++++++ .../Fixture/no_new_line_try_switch.php.inc | 36 ++++++++++++ .../Stmt/NewlineAfterStatementRector.php | 12 ++++ 4 files changed, 137 insertions(+) create mode 100644 rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_classlike.php.inc create mode 100644 rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_try_catch.php.inc create mode 100644 rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_try_switch.php.inc diff --git a/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_classlike.php.inc b/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_classlike.php.inc new file mode 100644 index 00000000000..668885009e0 --- /dev/null +++ b/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_classlike.php.inc @@ -0,0 +1,57 @@ + +----- + diff --git a/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_try_catch.php.inc b/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_try_catch.php.inc new file mode 100644 index 00000000000..e74652b0403 --- /dev/null +++ b/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_try_catch.php.inc @@ -0,0 +1,32 @@ + +----- + diff --git a/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_try_switch.php.inc b/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_try_switch.php.inc new file mode 100644 index 00000000000..9f650fa918a --- /dev/null +++ b/rules-tests/CodingStyle/Rector/Stmt/NewlineAfterStatementRector/Fixture/no_new_line_try_switch.php.inc @@ -0,0 +1,36 @@ + +----- + diff --git a/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php b/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php index 309ea4fa6d2..f93e40ff7df 100644 --- a/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php +++ b/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php @@ -6,6 +6,7 @@ use PhpParser\Node; use PhpParser\Node\Stmt; +use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassConst; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Do_; @@ -13,8 +14,13 @@ use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\If_; +use PhpParser\Node\Stmt\Interface_; +use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Property; +use PhpParser\Node\Stmt\Switch_; +use PhpParser\Node\Stmt\Trait_; +use PhpParser\Node\Stmt\TryCatch; use PhpParser\Node\Stmt\While_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; @@ -39,6 +45,12 @@ final class NewlineAfterStatementRector extends AbstractRector While_::class, For_::class, ClassConst::class, + Namespace_::class, + TryCatch::class, + Class_::class, + Trait_::class, + Interface_::class, + Switch_::class, ]; /**