Skip to content

Commit 3f3cce8

Browse files
authored
NoCommentedOutCodeFixer must run before ClassAttributesSeparationFixer (#853)
1 parent 818fd2a commit 3f3cce8

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

.dev-tools/src/Priority/PriorityCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PhpCsFixer\Fixer\FixerInterface;
1515
use PhpCsFixer\FixerFactory;
1616
use PhpCsFixerCustomFixers\Fixer\CommentSurroundedBySpacesFixer;
17+
use PhpCsFixerCustomFixers\Fixer\NoCommentedOutCodeFixer;
1718
use PhpCsFixerCustomFixers\Fixers;
1819
use Tests\PriorityTest;
1920

@@ -87,6 +88,7 @@ private function getFirstPriorityFixerWithoutPriority(): ?PriorityFixer
8788
{
8889
static $firstFixers = [
8990
CommentSurroundedBySpacesFixer::class,
91+
NoCommentedOutCodeFixer::class,
9092
];
9193

9294
$priorityFixersWithoutPriorities = \array_filter(

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
44
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
55
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
6-
![Tests](https://img.shields.io/badge/tests-3438-brightgreen.svg)
6+
![Tests](https://img.shields.io/badge/tests-3441-brightgreen.svg)
77
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
88

99
[![CI Status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/workflows/CI/badge.svg?branch=main)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions)

src/Fixer/CommentedOutFunctionFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function configure(array $configuration): void
6666
*/
6767
public function getPriority(): int
6868
{
69-
return 27;
69+
return 57;
7070
}
7171

7272
public function isCandidate(Tokens $tokens): bool

src/Fixer/NoCommentedOutCodeFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ public function getDefinition(): FixerDefinitionInterface
3131
}
3232

3333
/**
34-
* Must run before NoExtraBlankLinesFixer, NoTrailingWhitespaceFixer, NoUnusedImportsFixer.
34+
* Must run before ClassAttributesSeparationFixer, NoExtraBlankLinesFixer, NoTrailingWhitespaceFixer, NoUnusedImportsFixer.
3535
* Must run after CommentedOutFunctionFixer.
3636
*/
3737
public function getPriority(): int
3838
{
39-
return 1;
39+
return 56;
4040
}
4141

4242
public function isCandidate(Tokens $tokens): bool
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--CONFIGURATION--
2+
{ "PhpCsFixerCustomFixers/no_commented_out_code": true, "class_attributes_separation": true }
3+
--EXPECTED--
4+
<?php
5+
class Foo
6+
{
7+
const C1 = 1;
8+
9+
const C3 = 3;
10+
}
11+
12+
--INPUT--
13+
<?php
14+
class Foo
15+
{
16+
const C1 = 1;
17+
18+
// const C2 = 2;
19+
20+
const C3 = 3;
21+
}

0 commit comments

Comments
 (0)