File tree Expand file tree Collapse file tree 4 files changed +31
-6
lines changed
SlevomatCodingStandard/Sniffs/Commenting Expand file tree Collapse file tree 4 files changed +31
-6
lines changed Original file line number Diff line number Diff line change 1414use const T_DOC_COMMENT_STRING ;
1515use const T_DOC_COMMENT_WHITESPACE ;
1616use const T_WHITESPACE ;
17- use function array_combine ;
1817use function array_diff ;
1918use function array_flip ;
2019use function array_key_exists ;
2625use function explode ;
2726use function ksort ;
2827use function max ;
28+ use function min ;
2929use function preg_match ;
30- use function range ;
3130use function sprintf ;
3231use function strlen ;
3332use function strpos ;
@@ -494,10 +493,10 @@ private function checkAnnotationsGroupsOrder(
494493 }
495494
496495 if (!$ incorrectAnnotationsGroupsExist ) {
497- $ recalculatedAnnotationsGroupsPositions = array_combine ( array_keys ( $ annotationsGroupsPositions ), range ( 0 , count ( $ annotationsGroupsPositions) - 1 ));
496+ $ positionDiff = min ( $ annotationsGroupsPositions ) - min ( array_keys ( $ annotationsGroupsPositions ));
498497
499- foreach ($ recalculatedAnnotationsGroupsPositions as $ annotationsGroupPosition => $ sortedAnnotationsGroupPosition ) {
500- if ($ annotationsGroupPosition === $ sortedAnnotationsGroupPosition ) {
498+ foreach ($ annotationsGroupsPositions as $ annotationsGroupPosition => $ sortedAnnotationsGroupPosition ) {
499+ if ($ annotationsGroupPosition === $ sortedAnnotationsGroupPosition - $ positionDiff ) {
501500 continue ;
502501 }
503502
Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ public function testAnnotationsGroupsErrors(): void
119119 $ report = self ::checkFile (__DIR__ . '/data/docCommentSpacingAnnotationsGroupsErrors.php ' , [
120120 'linesCountBetweenAnnotationsGroups ' => 1 ,
121121 'annotationsGroups ' => [
122+ '@dataProvider ' ,
122123 '@param ' ,
123124 '@X \\Boo,@X \\,@XX ' ,
124125 '@throws ' ,
@@ -133,12 +134,13 @@ public function testAnnotationsGroupsErrors(): void
133134 DocCommentSpacingSniff::CODE_INCORRECT_ORDER_OF_ANNOTATIONS_IN_GROUP ,
134135 ]);
135136
136- self ::assertSame (4 , $ report ->getErrorCount ());
137+ self ::assertSame (5 , $ report ->getErrorCount ());
137138
138139 self ::assertSniffError ($ report , 20 , DocCommentSpacingSniff::CODE_INCORRECT_ANNOTATIONS_GROUP );
139140 self ::assertSniffError ($ report , 34 , DocCommentSpacingSniff::CODE_INCORRECT_LINES_COUNT_BETWEEN_ANNOTATIONS_GROUPS );
140141 self ::assertSniffError ($ report , 46 , DocCommentSpacingSniff::CODE_INCORRECT_ORDER_OF_ANNOTATIONS_GROUPS );
141142 self ::assertSniffError ($ report , 49 , DocCommentSpacingSniff::CODE_INCORRECT_ORDER_OF_ANNOTATIONS_IN_GROUP );
143+ self ::assertSniffError ($ report , 62 , DocCommentSpacingSniff::CODE_INCORRECT_ORDER_OF_ANNOTATIONS_GROUPS );
142144
143145 self ::assertAllFixedInFile ($ report );
144146 }
Original file line number Diff line number Diff line change @@ -57,4 +57,16 @@ public function anotherMethod()
5757
5858 }
5959
60+ /**
61+ * @dataProvider oneMoreMethodData
62+ *
63+ * @param int $a
64+ * @param int|null $b
65+ * @param string $c
66+ */
67+ public function oneMoreMethod ($ a , $ b , $ c )
68+ {
69+
70+ }
71+
6072}
Original file line number Diff line number Diff line change @@ -58,4 +58,16 @@ public function anotherMethod()
5858
5959 }
6060
61+ /**
62+ * @param int $a
63+ * @param int|null $b
64+ * @param string $c
65+ *
66+ * @dataProvider oneMoreMethodData
67+ */
68+ public function oneMoreMethod ($ a , $ b , $ c )
69+ {
70+
71+ }
72+
6173}
You can’t perform that action at this time.
0 commit comments