Skip to content

Commit

Permalink
PSR2/ClassDeclaration: add tests covering the CloseBraceSameLine error
Browse files Browse the repository at this point in the history
Previously, there were no dedicated tests for the `CloseBraceSameLine` error.
  • Loading branch information
jrfnl committed Jul 20, 2024
1 parent 64c2c23 commit e5e3b08
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,18 @@ class ClassWithMultiLineImplementsAndCommentOnSameLineAsInterfaceName implements
/* Comment. */ AnotherInterface
{
}

// Verify the `CloseBraceSameLine` error code is thrown when expected.
class ClassBraceNotOnLineByItselfError
{
public $prop;
} $foo = new ClassBraceNotOnLineByItselfError;

interface ClassBraceNotOnLineByItselfTrailingCommentIsAllowed
{
public function myMethod();
} //end interface -- this comment is allowed.

trait ClassBraceNotOnLineByItselfTrailingAnnotationIsAllowed
{
} // phpcs:ignore Stnd.Cat.Sniff -- this comment is also allowed.
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,18 @@ class ClassWithMultiLineImplementsAndCommentOnSameLineAsInterfaceName implements
AnotherInterface
{
}

// Verify the `CloseBraceSameLine` error code is thrown when expected.
class ClassBraceNotOnLineByItselfError
{
public $prop;
} $foo = new ClassBraceNotOnLineByItselfError;

interface ClassBraceNotOnLineByItselfTrailingCommentIsAllowed
{
public function myMethod();
} //end interface -- this comment is allowed.

trait ClassBraceNotOnLineByItselfTrailingAnnotationIsAllowed
{
} // phpcs:ignore Stnd.Cat.Sniff -- this comment is also allowed.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function getErrorList()
282 => 1,
310 => 1,
316 => 1,
324 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit e5e3b08

Please sign in to comment.