Skip to content

Commit

Permalink
[CodingStyle] Add more statements for NewlineAfterStatementRector (#792)
Browse files Browse the repository at this point in the history
* [CodingStyle] Add more statements for NewlineAfterStatementRector

* cs fix
  • Loading branch information
samsonasik committed Aug 30, 2021
1 parent ec7c68f commit 170a09f
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace A
{
class C
{
}
class D
{
}
}
namespace B
{
interface E
{
}
trait F
{
}
class G implements E
{
use F;
}
}

?>
-----
<?php

namespace A
{
class C
{
}

class D
{
}
}

namespace B
{
interface E
{
}

trait F
{
}

class G implements E
{
use F;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Rector\Tests\CodingStyle\Rector\Stmt\NewlineAfterStatementRector\Fixture;

function run()
{
try {

} catch (Exception $e) {

}
return true;
}

?>
-----
<?php

namespace Rector\Tests\CodingStyle\Rector\Stmt\NewlineAfterStatementRector\Fixture;

function run()
{
try {

} catch (Exception $e) {

}

return true;
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Rector\Tests\CodingStyle\Rector\Stmt\NewlineAfterStatementRector\Fixture;

function run($data)
{
switch ($data) {
case 'a':
echo 'test';
break;
default:
echo 'test 1';
}
return true;
}

?>
-----
<?php

namespace Rector\Tests\CodingStyle\Rector\Stmt\NewlineAfterStatementRector\Fixture;

function run($data)
{
switch ($data) {
case 'a':
echo 'test';
break;
default:
echo 'test 1';
}

return true;
}

?>
12 changes: 12 additions & 0 deletions rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@

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_;
use PhpParser\Node\Stmt\For_;
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;
Expand All @@ -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,
];

/**
Expand Down

0 comments on commit 170a09f

Please sign in to comment.