Skip to content

Commit a4cef98

Browse files
committed
SlevomatCodingStandard.Attributes.AttributesOrder: Fixed alphabetical sorting
1 parent 5204706 commit a4cef98

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

SlevomatCodingStandard/Sniffs/Attributes/AttributesOrderSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public function process(File $phpcsFile, $attributeOpenerPointer): void
9292
uasort(
9393
$expectedOrder,
9494
static fn (array $attributesGroup1, array $attributesGroup2): int => strnatcmp(
95-
$attributesGroup1[0]->getFullyQualifiedName(),
96-
$attributesGroup2[0]->getFullyQualifiedName(),
95+
$attributesGroup1[0]->getName(),
96+
$attributesGroup2[0]->getName(),
9797
),
9898
);
9999

tests/Sniffs/Attributes/AttributesOrderSniffTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ public function testOrderAlphabeticallyErrors(): void
6262
'orderAlphabetically' => true,
6363
]);
6464

65-
self::assertSame(3, $report->getErrorCount());
65+
self::assertSame(4, $report->getErrorCount());
6666

67-
self::assertSniffError($report, 3, AttributesOrderSniff::CODE_INCORRECT_ORDER);
68-
self::assertSniffError($report, 12, AttributesOrderSniff::CODE_INCORRECT_ORDER);
69-
self::assertSniffError($report, 18, AttributesOrderSniff::CODE_INCORRECT_ORDER);
67+
self::assertSniffError($report, 6, AttributesOrderSniff::CODE_INCORRECT_ORDER);
68+
self::assertSniffError($report, 15, AttributesOrderSniff::CODE_INCORRECT_ORDER);
69+
self::assertSniffError($report, 21, AttributesOrderSniff::CODE_INCORRECT_ORDER);
70+
self::assertSniffError($report, 31, AttributesOrderSniff::CODE_INCORRECT_ORDER);
7071

7172
self::assertAllFixedInFile($report);
7273
}

tests/Sniffs/Attributes/data/attributesOrderAlphabeticallyErrors.fixed.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use A\B;
4+
use B\A;
5+
36
#[AttributeA]
47
#[AttributeB]
58
#[\Group\AttributeA('paramS')]
@@ -25,4 +28,11 @@ public function method()
2528
public function method2()
2629
{
2730
}
31+
32+
#[A]
33+
#[B]
34+
public function method3()
35+
{
36+
}
37+
2838
}

tests/Sniffs/Attributes/data/attributesOrderAlphabeticallyErrors.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use A\B;
4+
use B\A;
5+
36
#[AttributeB]
47
#[\Group\AttributeB]
58
#[\Group\AttributeA('paramS')]
@@ -24,4 +27,11 @@ public function method()
2427
public function method2()
2528
{
2629
}
30+
31+
#[B]
32+
#[A]
33+
public function method3()
34+
{
35+
}
36+
2737
}

0 commit comments

Comments
 (0)