Skip to content

Commit 230dd01

Browse files
authored
Add PhpDocPropertySorterFixer back as deprecated to keep BC (#1091)
1 parent f969a30 commit 230dd01

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## v3.34.0
44
- Add PhpdocPropertySortedFixer
5+
- Deprecate PhpDocPropertySorterFixer - use PhpdocPropertySortedFixer
56

67
## v3.33.0
78
- Add PhpDocPropertySorterFixer

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,20 @@ Configuration options:
461461
+echo 01234567; // octal
462462
```
463463

464+
#### PhpDocPropertySorterFixer
465+
Sorts @property annotations in PHPDoc blocks alphabetically within groups separated by empty lines.
466+
DEPRECATED: use `PhpCsFixerCustomFixers/phpdoc_property_sorted` instead.
467+
```diff
468+
<?php
469+
/**
470+
- * @property string $zzz
471+
* @property int $aaa
472+
* @property bool $mmm
473+
+ * @property string $zzz
474+
*/
475+
class Foo {}
476+
```
477+
464478
#### PhpUnitAssertArgumentsOrderFixer
465479
PHPUnit assertions must have expected argument before actual one.
466480
*Risky: when original PHPUnit methods are overwritten.*
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php declare(strict_types=1);
2+
3+
/*
4+
* This file is part of PHP CS Fixer: custom fixers.
5+
*
6+
* (c) 2018 Kuba Werłos
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*/
11+
12+
namespace PhpCsFixerCustomFixers\Fixer;
13+
14+
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
15+
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
16+
use PhpCsFixer\Tokenizer\Tokens;
17+
18+
/**
19+
* @deprecated
20+
*
21+
* @no-named-arguments
22+
*/
23+
final class PhpDocPropertySorterFixer extends AbstractFixer implements DeprecatedFixerInterface
24+
{
25+
private PhpdocPropertySortedFixer $phpdocPropertySortedFixer;
26+
27+
public function __construct()
28+
{
29+
$this->phpdocPropertySortedFixer = new PhpdocPropertySortedFixer();
30+
}
31+
32+
public function getDefinition(): FixerDefinitionInterface
33+
{
34+
return $this->phpdocPropertySortedFixer->getDefinition();
35+
}
36+
37+
public function getPriority(): int
38+
{
39+
return $this->phpdocPropertySortedFixer->getPriority();
40+
}
41+
42+
public function isCandidate(Tokens $tokens): bool
43+
{
44+
return $this->phpdocPropertySortedFixer->isCandidate($tokens);
45+
}
46+
47+
public function isRisky(): bool
48+
{
49+
return $this->phpdocPropertySortedFixer->isRisky();
50+
}
51+
52+
public function fix(\SplFileInfo $file, Tokens $tokens): void
53+
{
54+
$this->phpdocPropertySortedFixer->fix($file, $tokens);
55+
}
56+
57+
/**
58+
* @return list<string>
59+
*/
60+
public function getSuccessorsNames(): array
61+
{
62+
return [$this->phpdocPropertySortedFixer->getName()];
63+
}
64+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php declare(strict_types=1);
2+
3+
/*
4+
* This file is part of PHP CS Fixer: custom fixers.
5+
*
6+
* (c) 2018 Kuba Werłos
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*/
11+
12+
namespace Tests\Fixer;
13+
14+
use PhpCsFixerCustomFixers\Fixer\PhpdocPropertySortedFixer;
15+
16+
/**
17+
* @internal
18+
*
19+
* @covers \PhpCsFixerCustomFixers\Fixer\PhpDocPropertySorterFixer
20+
*/
21+
final class PhpDocPropertySorterFixerTest extends AbstractFixerTestCase
22+
{
23+
public function testSuccessorName(): void
24+
{
25+
self::assertSuccessorName(PhpdocPropertySortedFixer::name());
26+
}
27+
28+
public function testIsRisky(): void
29+
{
30+
self::assertRiskiness(false);
31+
}
32+
33+
/**
34+
* @dataProvider provideFixCases
35+
*/
36+
public function testFix(string $expected, ?string $input = null): void
37+
{
38+
$this->doTest($expected, $input);
39+
}
40+
41+
/**
42+
* @return iterable<array{0: string, 1?: string}>
43+
*/
44+
public static function provideFixCases(): iterable
45+
{
46+
yield from PhpdocPropertySortedFixerTest::provideFixCases();
47+
}
48+
}

0 commit comments

Comments
 (0)