File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
SlevomatCodingStandard/Sniffs/Commenting Expand file tree Collapse file tree 2 files changed +19
-5
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 ;
1718use function array_diff ;
1819use function array_flip ;
1920use function array_key_exists ;
2021use function array_keys ;
2122use function array_map ;
2223use function array_merge ;
2324use function array_values ;
25+ use function asort ;
2426use function count ;
2527use function explode ;
2628use function ksort ;
2729use function max ;
28- use function min ;
2930use function preg_match ;
3031use function sprintf ;
3132use function strlen ;
@@ -495,16 +496,19 @@ private function checkAnnotationsGroupsOrder(
495496 }
496497
497498 if (!$ incorrectAnnotationsGroupsExist ) {
498- $ positionDiff = min ($ annotationsGroupsPositions ) - min (array_keys ($ annotationsGroupsPositions ));
499+ $ positionsMappedToGroups = array_keys ($ annotationsGroupsPositions );
500+ $ tmp = array_values ($ annotationsGroupsPositions );
501+ asort ($ tmp );
502+ $ normalizedAnnotationsGroupsPositions = array_combine (array_keys ($ positionsMappedToGroups ), array_keys ($ tmp ));
499503
500- foreach ($ annotationsGroupsPositions as $ annotationsGroupPosition => $ sortedAnnotationsGroupPosition ) {
501- if ($ annotationsGroupPosition === $ sortedAnnotationsGroupPosition - $ positionDiff ) {
504+ foreach ($ normalizedAnnotationsGroupsPositions as $ normalizedAnnotationsGroupPosition => $ sortedAnnotationsGroupPosition ) {
505+ if ($ normalizedAnnotationsGroupPosition === $ sortedAnnotationsGroupPosition ) {
502506 continue ;
503507 }
504508
505509 $ fix = $ phpcsFile ->addFixableError (
506510 'Incorrect order of annotations groups. ' ,
507- $ annotationsGroups [$ annotationsGroupPosition ][0 ]->getStartPointer (),
511+ $ annotationsGroups [$ positionsMappedToGroups [ $ normalizedAnnotationsGroupPosition ] ][0 ]->getStartPointer (),
508512 self ::CODE_INCORRECT_ORDER_OF_ANNOTATIONS_GROUPS
509513 );
510514 break ;
Original file line number Diff line number Diff line change @@ -54,4 +54,14 @@ public function anotherMethod()
5454
5555 }
5656
57+ /**
58+ * @param string $a
59+ *
60+ * @anything
61+ */
62+ public function oneMoreMethod ($ a )
63+ {
64+
65+ }
66+
5767}
You can’t perform that action at this time.
0 commit comments