Skip to content

Commit 3bfabd0

Browse files
committed
minor #5355 OrderedTraitsFixer - mark as risky (SpacePossum)
This PR was merged into the 2.17 branch. Discussion ---------- OrderedTraitsFixer - mark as risky closes #5350 Commits ------- c8ea464 OrderedTraitsFixer - mark as risky
2 parents 0569ba1 + c8ea464 commit 3bfabd0

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

doc/rules/class_notation/ordered_traits.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Rule ``ordered_traits``
44

55
Trait ``use`` statements must be sorted alphabetically.
66

7+
.. warning:: Using this rule is risky.
8+
9+
Risky when depending on order of the imports.
10+
711
Examples
812
--------
913

doc/rules/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Class Notation
127127
Orders the elements of classes/interfaces/traits.
128128
- `ordered_interfaces <./class_notation/ordered_interfaces.rst>`_ *(risky)*
129129
Orders the interfaces in an ``implements`` or ``interface extends`` clause.
130-
- `ordered_traits <./class_notation/ordered_traits.rst>`_
130+
- `ordered_traits <./class_notation/ordered_traits.rst>`_ *(risky)*
131131
Trait ``use`` statements must be sorted alphabetically.
132132
- `protected_to_private <./class_notation/protected_to_private.rst>`_
133133
Converts ``protected`` variables and methods to ``private`` where possible.

src/Fixer/ClassNotation/OrderedTraitsFixer.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public function getDefinition()
2929
'Trait `use` statements must be sorted alphabetically.',
3030
[
3131
new CodeSample("<?php class Foo { \nuse Z; use A; }\n"),
32-
]
32+
],
33+
null,
34+
'Risky when depending on order of the imports.'
3335
);
3436
}
3537

@@ -41,6 +43,14 @@ public function isCandidate(Tokens $tokens)
4143
return $tokens->isTokenKindFound(CT::T_USE_TRAIT);
4244
}
4345

46+
/**
47+
* {@inheritdoc}
48+
*/
49+
public function isRisky()
50+
{
51+
return true;
52+
}
53+
4454
/**
4555
* {@inheritdoc}
4656
*/

0 commit comments

Comments
 (0)