Skip to content

Commit

Permalink
BracesFixer - handle enums
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Feb 20, 2022
1 parent 1157777 commit 5dea965
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fixer/Basic/BracesFixer.php
Expand Up @@ -297,7 +297,7 @@ private function fixDoWhile(Tokens $tokens): void

private function fixIndents(Tokens $tokens): void
{
$classyTokens = [T_CLASS, T_TRAIT, T_INTERFACE]; // FIXME use Token::getClassyTokenKinds() when ENUM tests are made
$classyTokens = Token::getClassyTokenKinds();
$classyAndFunctionTokens = array_merge([T_FUNCTION], $classyTokens);
$controlTokens = $this->getControlTokens();
$indentTokens = array_filter(
Expand Down
42 changes: 42 additions & 0 deletions tests/Fixer/Basic/BracesFixerTest.php
Expand Up @@ -5428,4 +5428,46 @@ public function provideFix80Cases()
};',
];
}

/**
* @requires PHP 8.1
*
* @dataProvider provideFix81Cases
*/
public function testFix81(string $expected, string $input): void
{
$this->doTest($expected, $input);
}

public function provideFix81Cases()
{
yield 'enum' => [
'<?php
enum Foo
{
case Bar;
public function abc()
{
}
}',
'<?php
enum Foo {
case Bar;
public function abc() {
}
}',
];
yield 'backed-enum' => [
'<?php
enum Foo: string
{
case Bar = "bar";
}',
'<?php
enum Foo: string {
case Bar = "bar";}',
];
}
}

0 comments on commit 5dea965

Please sign in to comment.