You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ju...@apache.org on 2023/08/30 04:24:22 UTC
[netbeans] branch master updated: Keep existing order of use type kinds(types, functions, constants) if possible #6274
This is an automated email from the ASF dual-hosted git repository.
junichi11 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new ae10b6f5d8 Keep existing order of use type kinds(types, functions, constants) if possible #6274
new be5e477b1a Merge pull request #6322 from junichi11/php-gh-6274-fix-imports-keep-existing-order
ae10b6f5d8 is described below
commit ae10b6f5d8242f5251c6a953b55aff43b62a9b07
Author: Junichi Yamamoto <ju...@apache.org>
AuthorDate: Mon Aug 7 12:40:22 2023 +0900
Keep existing order of use type kinds(types, functions, constants) if possible #6274
- https://github.com/apache/netbeans/issues/6274
- Add the option (Keep existing order of use types(types, functions, constants) if possible)
- Add unit tests
---
.../modules/php/editor/actions/FixUsesAction.java | 21 +-
.../php/editor/actions/FixUsesPerformer.java | 157 ++--
.../modules/php/editor/indent/CodeStyle.java | 4 +
.../modules/php/editor/indent/FmtOptions.java | 4 +-
.../modules/php/editor/indent/ui/Bundle.properties | 1 +
.../modules/php/editor/indent/ui/FmtUses.form | 12 +-
.../modules/php/editor/indent/ui/FmtUses.java | 12 +-
.../testKeepExistingUseTypeOrder_Group01a.php | 83 +++
...stKeepExistingUseTypeOrder_Group01a.php.fixUses | 91 +++
.../testKeepExistingUseTypeOrder_Group01b.php | 83 +++
...stKeepExistingUseTypeOrder_Group01b.php.fixUses | 91 +++
.../testKeepExistingUseTypeOrder_Group02a.php | 90 +++
...stKeepExistingUseTypeOrder_Group02a.php.fixUses | 91 +++
.../testKeepExistingUseTypeOrder_Group02b.php | 90 +++
...stKeepExistingUseTypeOrder_Group02b.php.fixUses | 91 +++
.../testKeepExistingUseTypeOrder_Group03a.php | 77 ++
...stKeepExistingUseTypeOrder_Group03a.php.fixUses | 78 ++
.../testKeepExistingUseTypeOrder_Group03b.php | 77 ++
...stKeepExistingUseTypeOrder_Group03b.php.fixUses | 78 ++
.../testKeepExistingUseTypeOrder_Group04a.php | 77 ++
...stKeepExistingUseTypeOrder_Group04a.php.fixUses | 76 ++
.../testKeepExistingUseTypeOrder_Group04b.php | 77 ++
...stKeepExistingUseTypeOrder_Group04b.php.fixUses | 76 ++
.../testKeepExistingUseTypeOrder_Group05a.php | 73 ++
...stKeepExistingUseTypeOrder_Group05a.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_Group05b.php | 73 ++
...stKeepExistingUseTypeOrder_Group05b.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_GroupPSR01a.php | 83 +++
...eepExistingUseTypeOrder_GroupPSR01a.php.fixUses | 91 +++
.../testKeepExistingUseTypeOrder_GroupPSR01b.php | 83 +++
...eepExistingUseTypeOrder_GroupPSR01b.php.fixUses | 91 +++
.../testKeepExistingUseTypeOrder_GroupPSR02a.php | 90 +++
...eepExistingUseTypeOrder_GroupPSR02a.php.fixUses | 91 +++
.../testKeepExistingUseTypeOrder_GroupPSR02b.php | 90 +++
...eepExistingUseTypeOrder_GroupPSR02b.php.fixUses | 91 +++
.../testKeepExistingUseTypeOrder_GroupPSR03a.php | 77 ++
...eepExistingUseTypeOrder_GroupPSR03a.php.fixUses | 78 ++
.../testKeepExistingUseTypeOrder_GroupPSR03b.php | 77 ++
...eepExistingUseTypeOrder_GroupPSR03b.php.fixUses | 78 ++
.../testKeepExistingUseTypeOrder_GroupPSR04a.php | 77 ++
...eepExistingUseTypeOrder_GroupPSR04a.php.fixUses | 76 ++
.../testKeepExistingUseTypeOrder_GroupPSR04b.php | 77 ++
...eepExistingUseTypeOrder_GroupPSR04b.php.fixUses | 76 ++
.../testKeepExistingUseTypeOrder_GroupPSR05a.php | 73 ++
...eepExistingUseTypeOrder_GroupPSR05a.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_GroupPSR05b.php | 73 ++
...eepExistingUseTypeOrder_GroupPSR05b.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_Multiple01a.php | 81 +++
...eepExistingUseTypeOrder_Multiple01a.php.fixUses | 81 +++
.../testKeepExistingUseTypeOrder_Multiple01b.php | 81 +++
...eepExistingUseTypeOrder_Multiple01b.php.fixUses | 81 +++
.../testKeepExistingUseTypeOrder_Multiple02a.php | 80 +++
...eepExistingUseTypeOrder_Multiple02a.php.fixUses | 81 +++
.../testKeepExistingUseTypeOrder_Multiple02b.php | 80 +++
...eepExistingUseTypeOrder_Multiple02b.php.fixUses | 81 +++
.../testKeepExistingUseTypeOrder_Multiple03a.php | 71 ++
...eepExistingUseTypeOrder_Multiple03a.php.fixUses | 72 ++
.../testKeepExistingUseTypeOrder_Multiple03b.php | 71 ++
...eepExistingUseTypeOrder_Multiple03b.php.fixUses | 72 ++
.../testKeepExistingUseTypeOrder_Multiple04a.php | 71 ++
...eepExistingUseTypeOrder_Multiple04a.php.fixUses | 72 ++
.../testKeepExistingUseTypeOrder_Multiple04b.php | 71 ++
...eepExistingUseTypeOrder_Multiple04b.php.fixUses | 72 ++
.../testKeepExistingUseTypeOrder_Multiple05a.php | 69 ++
...eepExistingUseTypeOrder_Multiple05a.php.fixUses | 70 ++
.../testKeepExistingUseTypeOrder_Multiple05b.php | 69 ++
...eepExistingUseTypeOrder_Multiple05b.php.fixUses | 70 ++
...testKeepExistingUseTypeOrder_MultiplePSR01a.php | 81 +++
...ExistingUseTypeOrder_MultiplePSR01a.php.fixUses | 81 +++
...testKeepExistingUseTypeOrder_MultiplePSR01b.php | 81 +++
...ExistingUseTypeOrder_MultiplePSR01b.php.fixUses | 81 +++
...testKeepExistingUseTypeOrder_MultiplePSR02a.php | 80 +++
...ExistingUseTypeOrder_MultiplePSR02a.php.fixUses | 81 +++
...testKeepExistingUseTypeOrder_MultiplePSR02b.php | 80 +++
...ExistingUseTypeOrder_MultiplePSR02b.php.fixUses | 81 +++
...testKeepExistingUseTypeOrder_MultiplePSR03a.php | 71 ++
...ExistingUseTypeOrder_MultiplePSR03a.php.fixUses | 72 ++
...testKeepExistingUseTypeOrder_MultiplePSR03b.php | 71 ++
...ExistingUseTypeOrder_MultiplePSR03b.php.fixUses | 72 ++
...testKeepExistingUseTypeOrder_MultiplePSR04a.php | 71 ++
...ExistingUseTypeOrder_MultiplePSR04a.php.fixUses | 72 ++
...testKeepExistingUseTypeOrder_MultiplePSR04b.php | 71 ++
...ExistingUseTypeOrder_MultiplePSR04b.php.fixUses | 72 ++
...testKeepExistingUseTypeOrder_MultiplePSR05a.php | 69 ++
...ExistingUseTypeOrder_MultiplePSR05a.php.fixUses | 70 ++
...testKeepExistingUseTypeOrder_MultiplePSR05b.php | 69 ++
...ExistingUseTypeOrder_MultiplePSR05b.php.fixUses | 70 ++
.../testKeepExistingUseTypeOrder_Single01a.php | 77 ++
...tKeepExistingUseTypeOrder_Single01a.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_Single01b.php | 77 ++
...tKeepExistingUseTypeOrder_Single01b.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_Single02a.php | 76 ++
...tKeepExistingUseTypeOrder_Single02a.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_Single02b.php | 76 ++
...tKeepExistingUseTypeOrder_Single02b.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_Single03a.php | 68 ++
...tKeepExistingUseTypeOrder_Single03a.php.fixUses | 69 ++
.../testKeepExistingUseTypeOrder_Single03b.php | 68 ++
...tKeepExistingUseTypeOrder_Single03b.php.fixUses | 69 ++
.../testKeepExistingUseTypeOrder_Single04a.php | 68 ++
...tKeepExistingUseTypeOrder_Single04a.php.fixUses | 72 ++
.../testKeepExistingUseTypeOrder_Single04b.php | 68 ++
...tKeepExistingUseTypeOrder_Single04b.php.fixUses | 72 ++
.../testKeepExistingUseTypeOrder_Single05a.php | 67 ++
...tKeepExistingUseTypeOrder_Single05a.php.fixUses | 68 ++
.../testKeepExistingUseTypeOrder_Single05b.php | 67 ++
...tKeepExistingUseTypeOrder_Single05b.php.fixUses | 68 ++
.../testKeepExistingUseTypeOrder_SinglePSR01a.php | 77 ++
...epExistingUseTypeOrder_SinglePSR01a.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_SinglePSR01b.php | 77 ++
...epExistingUseTypeOrder_SinglePSR01b.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_SinglePSR02a.php | 76 ++
...epExistingUseTypeOrder_SinglePSR02a.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_SinglePSR02b.php | 76 ++
...epExistingUseTypeOrder_SinglePSR02b.php.fixUses | 77 ++
.../testKeepExistingUseTypeOrder_SinglePSR03a.php | 67 ++
...epExistingUseTypeOrder_SinglePSR03a.php.fixUses | 68 ++
.../testKeepExistingUseTypeOrder_SinglePSR03b.php | 67 ++
...epExistingUseTypeOrder_SinglePSR03b.php.fixUses | 68 ++
.../testKeepExistingUseTypeOrder_SinglePSR04a.php | 68 ++
...epExistingUseTypeOrder_SinglePSR04a.php.fixUses | 69 ++
.../testKeepExistingUseTypeOrder_SinglePSR04b.php | 68 ++
...epExistingUseTypeOrder_SinglePSR04b.php.fixUses | 69 ++
.../testKeepExistingUseTypeOrder_SinglePSR05a.php | 67 ++
...epExistingUseTypeOrder_SinglePSR05a.php.fixUses | 69 ++
.../testKeepExistingUseTypeOrder_SinglePSR05b.php | 67 ++
...epExistingUseTypeOrder_SinglePSR05b.php.fixUses | 69 ++
.../php/editor/actions/FixUsesPerformerTest.java | 794 +++++++++++++++++++++
128 files changed, 10054 insertions(+), 63 deletions(-)
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesAction.java b/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesAction.java
index 1acdd81b62..75e31a6d18 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesAction.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesAction.java
@@ -283,6 +283,7 @@ public class FixUsesAction extends BaseAction {
private final boolean startUseWithNamespaceSeparator;
private final boolean aliasesCapitalsOfNamespaces;
private final boolean putInPSR12Order;
+ private final boolean keepExistingUseTypeOrder;
private final int blankLinesBetweenUseTypes;
private final PhpVersion phpVersion;
@@ -294,6 +295,7 @@ public class FixUsesAction extends BaseAction {
private boolean startUseWithNamespaceSeparator = false;
private boolean aliasesCapitalsOfNamespaces = false;
private boolean putInPSR12Order = false;
+ private boolean keepExistingUseTypeOrder = false;
private int blankLinesBetweenUseTypes = 0;
private final PhpVersion phpVersion;
@@ -331,6 +333,11 @@ public class FixUsesAction extends BaseAction {
return this;
}
+ public Builder keepExistingUseTypeOrder(boolean keepExistingUseTypeOrder) {
+ this.keepExistingUseTypeOrder = keepExistingUseTypeOrder;
+ return this;
+ }
+
public Builder setBlankLinesBetweenUseTypes(int blankLinesBetweenUseTypes) {
this.blankLinesBetweenUseTypes = blankLinesBetweenUseTypes;
return this;
@@ -348,6 +355,7 @@ public class FixUsesAction extends BaseAction {
this.startUseWithNamespaceSeparator = builder.startUseWithNamespaceSeparator;
this.aliasesCapitalsOfNamespaces = builder.aliasesCapitalsOfNamespaces;
this.putInPSR12Order = builder.putInPSR12Order;
+ this.keepExistingUseTypeOrder = builder.keepExistingUseTypeOrder;
this.blankLinesBetweenUseTypes = builder.blankLinesBetweenUseTypes;
this.phpVersion = builder.phpVersion;
}
@@ -360,6 +368,7 @@ public class FixUsesAction extends BaseAction {
boolean startUseWithNamespaceSeparator,
boolean aliasesCapitalsOfNamespaces,
boolean putInPSR12Order,
+ boolean keepExistingUseTypeOrder,
int blankLinesBetweenUseTypes,
PhpVersion phpVersion) {
this.preferFullyQualifiedNames = preferFullyQualifiedNames;
@@ -368,6 +377,7 @@ public class FixUsesAction extends BaseAction {
this.startUseWithNamespaceSeparator = startUseWithNamespaceSeparator;
this.aliasesCapitalsOfNamespaces = aliasesCapitalsOfNamespaces;
this.putInPSR12Order = putInPSR12Order;
+ this.keepExistingUseTypeOrder = keepExistingUseTypeOrder;
this.blankLinesBetweenUseTypes = blankLinesBetweenUseTypes;
this.phpVersion = phpVersion;
}
@@ -379,7 +389,7 @@ public class FixUsesAction extends BaseAction {
boolean startUseWithNamespaceSeparator,
boolean aliasesCapitalsOfNamespaces,
PhpVersion phpVersion) {
- this(preferFullyQualifiedNames, preferMultipleUseStatementsCombined, preferGroupUses, startUseWithNamespaceSeparator, aliasesCapitalsOfNamespaces, false, 0, phpVersion);
+ this(preferFullyQualifiedNames, preferMultipleUseStatementsCombined, preferGroupUses, startUseWithNamespaceSeparator, aliasesCapitalsOfNamespaces, false, false, 0, phpVersion);
}
// legacy, for unit tests
@@ -389,7 +399,7 @@ public class FixUsesAction extends BaseAction {
boolean startUseWithNamespaceSeparator,
boolean aliasesCapitalsOfNamespaces,
boolean isPhp56OrGreater) {
- this(preferFullyQualifiedNames, preferMultipleUseStatementsCombined, false, startUseWithNamespaceSeparator, aliasesCapitalsOfNamespaces, false, 0,
+ this(preferFullyQualifiedNames, preferMultipleUseStatementsCombined, false, startUseWithNamespaceSeparator, aliasesCapitalsOfNamespaces, false, false, 0,
isPhp56OrGreater ? PhpVersion.PHP_56 : PhpVersion.PHP_5);
}
@@ -401,7 +411,7 @@ public class FixUsesAction extends BaseAction {
boolean startUseWithNamespaceSeparator,
boolean aliasesCapitalsOfNamespaces,
boolean isPhp56OrGreater) {
- this(preferFullyQualifiedNames, preferMultipleUseStatementsCombined, preferGroupUses, startUseWithNamespaceSeparator, aliasesCapitalsOfNamespaces, false, 0,
+ this(preferFullyQualifiedNames, preferMultipleUseStatementsCombined, preferGroupUses, startUseWithNamespaceSeparator, aliasesCapitalsOfNamespaces, false, false, 0,
isPhp56OrGreater ? PhpVersion.PHP_56 : PhpVersion.PHP_5);
}
@@ -412,6 +422,7 @@ public class FixUsesAction extends BaseAction {
this.startUseWithNamespaceSeparator = codeStyle.startUseWithNamespaceSeparator();
this.aliasesCapitalsOfNamespaces = codeStyle.aliasesFromCapitalsOfNamespaces();
this.putInPSR12Order = codeStyle.putInPSR12Order();
+ this.keepExistingUseTypeOrder = codeStyle.usesKeepExistingTypeOrder();
this.blankLinesBetweenUseTypes = codeStyle.getBlankLinesBetweenUseTypes();
this.phpVersion = CodeUtils.getPhpVersion(fileObject);
}
@@ -440,6 +451,10 @@ public class FixUsesAction extends BaseAction {
return putInPSR12Order;
}
+ public boolean keepExistingUseTypeOrder() {
+ return keepExistingUseTypeOrder;
+ }
+
public int getBlankLinesBetweenUseTypes() {
return blankLinesBetweenUseTypes;
}
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java b/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java
index e700f9bc2f..265ace02ff 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java
@@ -90,6 +90,7 @@ public class FixUsesPerformer {
private static final char CURLY_OPEN = '{'; //NOI18N
private static final char CURLY_CLOSE = '}'; //NOI18N
private static final Map<UsePart.Type, Integer> PSR12_TYPE_PRIORITIES = new HashMap<>();
+ private static final Map<UsePart.Type, Integer> DEFAULT_TYPE_PRIORITIES = new HashMap<>();
private final PHPParseResult parserResult;
private final ImportData importData;
private final List<ItemVariant> selections;
@@ -99,6 +100,9 @@ public class FixUsesPerformer {
private BaseDocument baseDocument;
static {
+ DEFAULT_TYPE_PRIORITIES.put(UsePart.Type.TYPE, 0);
+ DEFAULT_TYPE_PRIORITIES.put(UsePart.Type.CONST, 1);
+ DEFAULT_TYPE_PRIORITIES.put(UsePart.Type.FUNCTION, 2);
PSR12_TYPE_PRIORITIES.put(UsePart.Type.TYPE, 0);
PSR12_TYPE_PRIORITIES.put(UsePart.Type.FUNCTION, 1);
PSR12_TYPE_PRIORITIES.put(UsePart.Type.CONST, 2);
@@ -134,7 +138,12 @@ public class FixUsesPerformer {
: "The selections size must not be larger than the dataItems size. selections size: " + selections.size() + " > dataItems size: " + dataItems.size(); // NOI18N
NamespaceScope namespaceScope = ModelUtils.getNamespaceScope(parserResult, importData.caretPosition);
assert namespaceScope != null;
- int startOffset = getOffset(baseDocument, namespaceScope, parserResult, importData.caretPosition);
+ CheckVisitor checkVisitor = new CheckVisitor();
+ Program program = parserResult.getProgram();
+ if (program != null) {
+ program.accept(checkVisitor);
+ }
+ int startOffset = getOffset(namespaceScope, importData.caretPosition, checkVisitor);
List<UsePart> useParts = new ArrayList<>();
Collection<? extends GroupUseScope> declaredGroupUses = namespaceScope.getDeclaredGroupUses();
for (GroupUseScope groupUseElement : declaredGroupUses) {
@@ -163,16 +172,12 @@ public class FixUsesPerformer {
}
}
replaceUnimportedItems();
- String insertString = createInsertString(useParts);
- insertUses(startOffset, insertString);
+ Map<UsePart.Type, Integer> typePriorities = getTypeOrderPriorities(useParts, checkVisitor.getExistingTypeOrderPriorities());
+ String insertString = createInsertString(useParts, typePriorities);
+ insertUses(startOffset, insertString, checkVisitor);
}
- private void insertUses(int startOffset, String insertString) {
- ExistingUseStatementVisitor visitor = new ExistingUseStatementVisitor();
- Program program = parserResult.getProgram();
- if (program != null) {
- program.accept(visitor);
- }
+ private void insertUses(int startOffset, String insertString, CheckVisitor visitor) {
List<OffsetRange> usedRanges = visitor.getUsedRanges();
String existingUses = getExistingUses(usedRanges);
// avoid being recognized as a modified file
@@ -272,9 +277,9 @@ public class FixUsesPerformer {
return result;
}
- private String createInsertString(final List<UsePart> useParts) {
+ private String createInsertString(final List<UsePart> useParts, final Map<UsePart.Type, Integer> typeOrderPriorities) {
StringBuilder insertString = new StringBuilder();
- sort(useParts);
+ sort(useParts, typeOrderPriorities);
if (!useParts.isEmpty()) {
insertString.append(NEW_LINE);
}
@@ -287,7 +292,7 @@ public class FixUsesPerformer {
if (options.preferGroupUses()
&& options.getPhpVersion().compareTo(PhpVersion.PHP_70) >= 0) {
- insertString.append(createStringForGroupUse(useParts, indentString));
+ insertString.append(createStringForGroupUse(useParts, indentString, typeOrderPriorities));
} else if (options.preferMultipleUseStatementsCombined()) {
insertString.append(createStringForMultipleUse(useParts, indentString));
} else {
@@ -296,12 +301,20 @@ public class FixUsesPerformer {
return insertString.toString();
}
- private void sort(List<UsePart> useParts) {
- if (options.putInPSR12Order()) {
- sort(useParts, PSR12_TYPE_PRIORITIES);
- } else {
- Collections.sort(useParts);
+ private Map<UsePart.Type, Integer> getTypeOrderPriorities(List<UsePart> useParts, Map<UsePart.Type, Integer> existingTypeOrderPriorities) {
+ boolean useExistingOrder = true;
+ for (UsePart usePart : useParts) {
+ if (existingTypeOrderPriorities.get(usePart.getType()) == null) {
+ useExistingOrder = false;
+ break;
+ }
}
+ if (options.keepExistingUseTypeOrder() && useExistingOrder) {
+ return existingTypeOrderPriorities;
+ } else if (options.putInPSR12Order()) {
+ return Collections.unmodifiableMap(PSR12_TYPE_PRIORITIES);
+ }
+ return Collections.unmodifiableMap(DEFAULT_TYPE_PRIORITIES);
}
private void sort(List<UsePart> useParts, final Map<UsePart.Type, Integer> typePriorities) {
@@ -316,7 +329,7 @@ public class FixUsesPerformer {
});
}
- private String createStringForGroupUse(List<UsePart> useParts, String indentString) {
+ private String createStringForGroupUse(List<UsePart> useParts, String indentString, Map<UsePart.Type, Integer> typePriorities) {
List<UsePart> typeUseParts = new ArrayList<>(useParts.size());
List<UsePart> constUseParts = new ArrayList<>(useParts.size());
List<UsePart> functionUseParts = new ArrayList<>(useParts.size());
@@ -340,7 +353,7 @@ public class FixUsesPerformer {
groupUseParts.put(USE_PREFIX, typeUseParts);
groupUseParts.put(USE_CONST_PREFIX, constUseParts);
groupUseParts.put(USE_FUNCTION_PREFIX, functionUseParts);
- createStringForGroupUse(insertString, indentString, groupUseParts);
+ createStringForGroupUse(insertString, indentString, groupUseParts, typePriorities);
return insertString.toString();
}
@@ -350,30 +363,35 @@ public class FixUsesPerformer {
.collect(Collectors.toList());
}
- private void createStringForGroupUse(StringBuilder insertString, String indentString, Map<String, List<UsePart>> useParts) {
- if (options.putInPSR12Order()) {
- createStringForGroupUsePSR12(insertString, indentString, useParts);
- } else {
- createStringForGroupUseDefault(insertString, indentString, useParts);
- }
+ private void createStringForGroupUse(StringBuilder insertString, String indentString, Map<String, List<UsePart>> useParts, Map<UsePart.Type, Integer> typePriorities) {
+ createStringForGroupUse(getOrderedUseTypePrefixes(typePriorities), useParts, insertString, indentString);
}
- private void createStringForGroupUsePSR12(StringBuilder insertString, String indentString, Map<String, List<UsePart>> useParts) {
- // use Type;
- // use function func;
- // use const CONSTANT;
- createStringForGroupUse(Arrays.asList(USE_PREFIX, USE_FUNCTION_PREFIX, USE_CONST_PREFIX), useParts, insertString, indentString);
+ private List<String> getOrderedUseTypePrefixes(Map<UsePart.Type, Integer> typePriorities) {
+ String[] priorities = new String[typePriorities.size()];
+ for (Map.Entry<UsePart.Type, Integer> entry : typePriorities.entrySet()) {
+ Integer position = entry.getValue();
+ priorities[position] = getUseTypePrefix(entry.getKey());
+ }
+ return Arrays.asList(priorities);
}
- private void createStringForGroupUseDefault(StringBuilder insertString, String indentString, Map<String, List<UsePart>> useParts) {
- // use Type;
- // use const CONSTANT;
- // use function func;
- createStringForGroupUse(Arrays.asList(USE_PREFIX, USE_CONST_PREFIX, USE_FUNCTION_PREFIX), useParts, insertString, indentString);
+ private String getUseTypePrefix(UsePart.Type type) {
+ switch (type) {
+ case TYPE:
+ return USE_PREFIX;
+ case FUNCTION:
+ return USE_FUNCTION_PREFIX;
+ case CONST:
+ return USE_CONST_PREFIX;
+ default:
+ assert false : "Unkown type: " + type; // NOI18N
+ return USE_PREFIX;
+ }
}
- private void createStringForGroupUse(List<String> useTypes, Map<String, List<UsePart>> useParts, StringBuilder insertString, String indentString) {
- for (String useType : useTypes) {
+ private void createStringForGroupUse(List<String> orderedUseTypePrefixes, Map<String, List<UsePart>> useParts, StringBuilder insertString, String indentString) {
+ for (String useType : orderedUseTypePrefixes) {
createStringForGroupUse(Pair.of(useType, useParts), insertString, indentString);
}
}
@@ -550,7 +568,7 @@ public class FixUsesPerformer {
return result;
}
- private static int getOffset(BaseDocument baseDocument, NamespaceScope namespaceScope, PHPParseResult parserResult, int caretPosition) {
+ private int getOffset(NamespaceScope namespaceScope, int caretPosition, CheckVisitor checkVisitor) {
try {
ModelElement lastSingleUse = getLastUse(namespaceScope, false);
ModelElement lastGroupUse = getLastUse(namespaceScope, true);
@@ -588,8 +606,6 @@ public class FixUsesPerformer {
// ?>
offset = Integer.max(offset, getFirstPhpTagPosition(parserResult, namespaceScope));
}
- CheckVisitor checkVisitor = new CheckVisitor();
- parserResult.getProgram().accept(checkVisitor);
if (namespaceScope.isDefaultNamespace()) {
List<NamespaceDeclaration> globalNamespaceDeclarations = checkVisitor.getGlobalNamespaceDeclarations();
if (!globalNamespaceDeclarations.isEmpty()) {
@@ -704,8 +720,10 @@ public class FixUsesPerformer {
//~ inner classes
private static class CheckVisitor extends DefaultVisitor {
- private List<DeclareStatement> declareStatements = new ArrayList<>();
- private List<NamespaceDeclaration> globalNamespaceDeclarations = new ArrayList<>();
+ private final List<DeclareStatement> declareStatements = new ArrayList<>();
+ private final List<NamespaceDeclaration> globalNamespaceDeclarations = new ArrayList<>();
+ private final List<OffsetRange> usedRanges = new LinkedList<>();
+ private final Map<UsePart.Type, Integer> existingTypeOrderPriorities = new HashMap<>();
public List<DeclareStatement> getDeclareStatements() {
return Collections.unmodifiableList(declareStatements);
@@ -715,6 +733,14 @@ public class FixUsesPerformer {
return Collections.unmodifiableList(globalNamespaceDeclarations);
}
+ public List<OffsetRange> getUsedRanges() {
+ return Collections.unmodifiableList(usedRanges);
+ }
+
+ public Map<UsePart.Type, Integer> getExistingTypeOrderPriorities() {
+ return Collections.unmodifiableMap(existingTypeOrderPriorities);
+ }
+
@Override
public void visit(DeclareStatement node) {
if (CancelSupport.getDefault().isCancelled()) {
@@ -734,6 +760,20 @@ public class FixUsesPerformer {
}
super.visit(declaration);
}
+
+ @Override
+ public void visit(UseStatement node) {
+ if (CancelSupport.getDefault().isCancelled()) {
+ return;
+ }
+ usedRanges.add(new OffsetRange(node.getStartOffset(), node.getEndOffset()));
+ UsePart.Type usePartType = UsePart.Type.create(node.getType());
+ Integer priority = existingTypeOrderPriorities.get(usePartType);
+ if (priority == null) {
+ existingTypeOrderPriorities.put(usePartType, existingTypeOrderPriorities.size());
+ }
+ super.visit(node);
+ }
}
private interface AliasStrategy {
@@ -871,20 +911,6 @@ public class FixUsesPerformer {
}
}
- private static class ExistingUseStatementVisitor extends DefaultVisitor {
-
- private final List<OffsetRange> usedRanges = new LinkedList<>();
-
- public List<OffsetRange> getUsedRanges() {
- return Collections.unmodifiableList(usedRanges);
- }
-
- @Override
- public void visit(UseStatement node) {
- usedRanges.add(new OffsetRange(node.getStartOffset(), node.getEndOffset()));
- }
- }
-
private static class UsePart implements Comparable<UsePart> {
enum Type {
@@ -947,6 +973,25 @@ public class FixUsesPerformer {
}
return result;
}
+
+ static Type create(UseStatement.Type type) {
+ Type usePartType = TYPE;
+ switch (type) {
+ case TYPE:
+ usePartType = TYPE;
+ break;
+ case FUNCTION:
+ usePartType = FUNCTION;
+ break;
+ case CONST:
+ usePartType = CONST;
+ break;
+ default:
+ assert false : "Unknown Type: " + type; // NOI18N
+ break;
+ }
+ return usePartType;
+ }
}
private final String textPart;
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/CodeStyle.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/CodeStyle.java
index 320f8ace37..a1ba761f73 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/CodeStyle.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/CodeStyle.java
@@ -753,6 +753,10 @@ public final class CodeStyle {
return preferences.getBoolean(PUT_IN_PSR12_ORDER, getDefaultAsBoolean(PUT_IN_PSR12_ORDER));
}
+ public boolean usesKeepExistingTypeOrder() {
+ return preferences.getBoolean(USES_KEEP_EXISTING_TYPE_ORDER, getDefaultAsBoolean(USES_KEEP_EXISTING_TYPE_ORDER));
+ }
+
private static class Producer implements FmtOptions.CodeStyleProducer {
@Override
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java
index bd3c87ea9d..24d05c20a4 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java
@@ -227,6 +227,7 @@ public final class FmtOptions {
public static final String START_USE_WITH_NAMESPACE_SEPARATOR = "startUseWithNamespaceSeparator"; //NOI18N
public static final String ALIASES_CAPITALS_OF_NAMESPACES = "aliasesCapitalsOfNamespacesNames"; //NOI18N
public static final String PUT_IN_PSR12_ORDER = "putInPSR12Order"; //NOI18N
+ public static final String USES_KEEP_EXISTING_TYPE_ORDER = "usesKeepExistingTypeOrder"; //NOI18N
public static CodeStyleProducer codeStyleProducer;
private FmtOptions() {
@@ -421,7 +422,8 @@ public final class FmtOptions {
{PREFER_GROUP_USES, FALSE},
{START_USE_WITH_NAMESPACE_SEPARATOR, FALSE},
{ALIASES_CAPITALS_OF_NAMESPACES, FALSE},
- {PUT_IN_PSR12_ORDER, FALSE}
+ {PUT_IN_PSR12_ORDER, FALSE},
+ {USES_KEEP_EXISTING_TYPE_ORDER, TRUE},
};
defaults = new HashMap<>();
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Bundle.properties b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Bundle.properties
index 19a93357b5..60f568d079 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Bundle.properties
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Bundle.properties
@@ -455,3 +455,4 @@ FmtBlankLines.betweenUseTypesLabel.AccessibleContext.accessibleDescription=Betwe
FmtBlankLines.betweenUseTypesField.text=
FmtBlankLines.endOfFileCheckBox.text=En&d of File
FmtUses.putInPSR12OrderCheckBox.text=Put in PSR-12 &Order
+FmtUses.keepExistingUseTypeOrderCheckBox.text=&Keep Existing Order of Use Types(types, functions, constants) If Possible
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtUses.form b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtUses.form
index e30edbd702..aee303e252 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtUses.form
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtUses.form
@@ -52,6 +52,7 @@
<Component id="aliasesCapitalsOfNamespacesCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="preferGroupUsesCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="putInPSR12OrderCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="keepExistingUseTypeOrderCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
@@ -72,7 +73,9 @@
<Component id="aliasesCapitalsOfNamespacesCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="putInPSR12OrderCheckBox" min="-2" max="-2" attributes="0"/>
- <EmptySpace pref="12" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="keepExistingUseTypeOrderCheckBox" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -124,5 +127,12 @@
</Property>
</Properties>
</Component>
+ <Component class="javax.swing.JCheckBox" name="keepExistingUseTypeOrderCheckBox">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/netbeans/modules/php/editor/indent/ui/Bundle.properties" key="FmtUses.keepExistingUseTypeOrderCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
</SubComponents>
</Form>
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtUses.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtUses.java
index 0f803ea642..b98e520462 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtUses.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtUses.java
@@ -49,6 +49,7 @@ public class FmtUses extends JPanel {
startUseWithNamespaceSeparatorCheckBox.putClientProperty(OPTION_ID, FmtOptions.START_USE_WITH_NAMESPACE_SEPARATOR);
aliasesCapitalsOfNamespacesCheckBox.putClientProperty(OPTION_ID, FmtOptions.ALIASES_CAPITALS_OF_NAMESPACES);
putInPSR12OrderCheckBox.putClientProperty(OPTION_ID, FmtOptions.PUT_IN_PSR12_ORDER);
+ keepExistingUseTypeOrderCheckBox.putClientProperty(OPTION_ID, FmtOptions.USES_KEEP_EXISTING_TYPE_ORDER);
}
public static PreferencesCustomizer.Factory getController() {
@@ -76,6 +77,7 @@ public class FmtUses extends JPanel {
startUseWithNamespaceSeparatorCheckBox = new JCheckBox();
aliasesCapitalsOfNamespacesCheckBox = new JCheckBox();
putInPSR12OrderCheckBox = new JCheckBox();
+ keepExistingUseTypeOrderCheckBox = new JCheckBox();
setName(NbBundle.getMessage(FmtUses.class, "LBL_Uses")); // NOI18N
setOpaque(false);
@@ -96,6 +98,8 @@ public class FmtUses extends JPanel {
Mnemonics.setLocalizedText(putInPSR12OrderCheckBox, NbBundle.getMessage(FmtUses.class, "FmtUses.putInPSR12OrderCheckBox.text")); // NOI18N
+ Mnemonics.setLocalizedText(keepExistingUseTypeOrderCheckBox, NbBundle.getMessage(FmtUses.class, "FmtUses.keepExistingUseTypeOrderCheckBox.text")); // NOI18N
+
GroupLayout layout = new GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
@@ -107,7 +111,8 @@ public class FmtUses extends JPanel {
.addComponent(startUseWithNamespaceSeparatorCheckBox)
.addComponent(aliasesCapitalsOfNamespacesCheckBox)
.addComponent(preferGroupUsesCheckBox)
- .addComponent(putInPSR12OrderCheckBox))
+ .addComponent(putInPSR12OrderCheckBox)
+ .addComponent(keepExistingUseTypeOrderCheckBox))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
@@ -124,11 +129,14 @@ public class FmtUses extends JPanel {
.addComponent(aliasesCapitalsOfNamespacesCheckBox)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(putInPSR12OrderCheckBox)
- .addContainerGap(12, Short.MAX_VALUE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(keepExistingUseTypeOrderCheckBox)
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private JCheckBox aliasesCapitalsOfNamespacesCheckBox;
+ private JCheckBox keepExistingUseTypeOrderCheckBox;
private JCheckBox preferFullyQualifiedNamesCheckBox;
private JCheckBox preferGroupUsesCheckBox;
private JCheckBox preferMultipleUseStatementsCombinedCheckBox;
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01a/testKeepExistingUseTypeOrder_Group01a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01a/testKeepExistingUseTypeOrder_Group01a.php
new file mode 100644
index 0000000000..f8eaf63a11
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01a/testKeepExistingUseTypeOrder_Group01a.php
@@ -0,0 +1,83 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function1;
+use function NS2\ns2Function2;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use const NS2\NS2_CONSTANT2;
+
+NS1\ns1Function();
+NS2\ns2Function();
+NS2\ns2Function2();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01a/testKeepExistingUseTypeOrder_Group01a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01a/testKeepExistingUseTypeOrder_Group01a.php.fixUses
new file mode 100644
index 0000000000..5226091fc7
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01a/testKeepExistingUseTypeOrder_Group01a.php.fixUses
@@ -0,0 +1,91 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+
+ns1Function();
+NS2\ns2Function();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01b/testKeepExistingUseTypeOrder_Group01b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01b/testKeepExistingUseTypeOrder_Group01b.php
new file mode 100644
index 0000000000..f8eaf63a11
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01b/testKeepExistingUseTypeOrder_Group01b.php
@@ -0,0 +1,83 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function1;
+use function NS2\ns2Function2;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use const NS2\NS2_CONSTANT2;
+
+NS1\ns1Function();
+NS2\ns2Function();
+NS2\ns2Function2();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01b/testKeepExistingUseTypeOrder_Group01b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01b/testKeepExistingUseTypeOrder_Group01b.php.fixUses
new file mode 100644
index 0000000000..22107b06c5
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group01b/testKeepExistingUseTypeOrder_Group01b.php.fixUses
@@ -0,0 +1,91 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+NS2\ns2Function();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02a/testKeepExistingUseTypeOrder_Group02a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02a/testKeepExistingUseTypeOrder_Group02a.php
new file mode 100644
index 0000000000..585eaad205
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02a/testKeepExistingUseTypeOrder_Group02a.php
@@ -0,0 +1,90 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02a/testKeepExistingUseTypeOrder_Group02a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02a/testKeepExistingUseTypeOrder_Group02a.php.fixUses
new file mode 100644
index 0000000000..8d918bc852
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02a/testKeepExistingUseTypeOrder_Group02a.php.fixUses
@@ -0,0 +1,91 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02b/testKeepExistingUseTypeOrder_Group02b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02b/testKeepExistingUseTypeOrder_Group02b.php
new file mode 100644
index 0000000000..585eaad205
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02b/testKeepExistingUseTypeOrder_Group02b.php
@@ -0,0 +1,90 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02b/testKeepExistingUseTypeOrder_Group02b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02b/testKeepExistingUseTypeOrder_Group02b.php.fixUses
new file mode 100644
index 0000000000..8f814a3c56
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group02b/testKeepExistingUseTypeOrder_Group02b.php.fixUses
@@ -0,0 +1,91 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03a/testKeepExistingUseTypeOrder_Group03a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03a/testKeepExistingUseTypeOrder_Group03a.php
new file mode 100644
index 0000000000..6e07908833
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03a/testKeepExistingUseTypeOrder_Group03a.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03a/testKeepExistingUseTypeOrder_Group03a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03a/testKeepExistingUseTypeOrder_Group03a.php.fixUses
new file mode 100644
index 0000000000..0bef85ef70
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03a/testKeepExistingUseTypeOrder_Group03a.php.fixUses
@@ -0,0 +1,78 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03b/testKeepExistingUseTypeOrder_Group03b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03b/testKeepExistingUseTypeOrder_Group03b.php
new file mode 100644
index 0000000000..6e07908833
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03b/testKeepExistingUseTypeOrder_Group03b.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03b/testKeepExistingUseTypeOrder_Group03b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03b/testKeepExistingUseTypeOrder_Group03b.php.fixUses
new file mode 100644
index 0000000000..48b34533d3
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group03b/testKeepExistingUseTypeOrder_Group03b.php.fixUses
@@ -0,0 +1,78 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04a/testKeepExistingUseTypeOrder_Group04a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04a/testKeepExistingUseTypeOrder_Group04a.php
new file mode 100644
index 0000000000..6e07908833
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04a/testKeepExistingUseTypeOrder_Group04a.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04a/testKeepExistingUseTypeOrder_Group04a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04a/testKeepExistingUseTypeOrder_Group04a.php.fixUses
new file mode 100644
index 0000000000..ad55230e1f
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04a/testKeepExistingUseTypeOrder_Group04a.php.fixUses
@@ -0,0 +1,76 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04b/testKeepExistingUseTypeOrder_Group04b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04b/testKeepExistingUseTypeOrder_Group04b.php
new file mode 100644
index 0000000000..6e07908833
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04b/testKeepExistingUseTypeOrder_Group04b.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04b/testKeepExistingUseTypeOrder_Group04b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04b/testKeepExistingUseTypeOrder_Group04b.php.fixUses
new file mode 100644
index 0000000000..ad55230e1f
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group04b/testKeepExistingUseTypeOrder_Group04b.php.fixUses
@@ -0,0 +1,76 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05a/testKeepExistingUseTypeOrder_Group05a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05a/testKeepExistingUseTypeOrder_Group05a.php
new file mode 100644
index 0000000000..d87ab35d67
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05a/testKeepExistingUseTypeOrder_Group05a.php
@@ -0,0 +1,73 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05a/testKeepExistingUseTypeOrder_Group05a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05a/testKeepExistingUseTypeOrder_Group05a.php.fixUses
new file mode 100644
index 0000000000..4bb862a878
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05a/testKeepExistingUseTypeOrder_Group05a.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05b/testKeepExistingUseTypeOrder_Group05b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05b/testKeepExistingUseTypeOrder_Group05b.php
new file mode 100644
index 0000000000..d87ab35d67
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05b/testKeepExistingUseTypeOrder_Group05b.php
@@ -0,0 +1,73 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05b/testKeepExistingUseTypeOrder_Group05b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05b/testKeepExistingUseTypeOrder_Group05b.php.fixUses
new file mode 100644
index 0000000000..4bb862a878
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Group05b/testKeepExistingUseTypeOrder_Group05b.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01a/testKeepExistingUseTypeOrder_GroupPSR01a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01a/testKeepExistingUseTypeOrder_GroupPSR01a.php
new file mode 100644
index 0000000000..3c75acbd6b
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01a/testKeepExistingUseTypeOrder_GroupPSR01a.php
@@ -0,0 +1,83 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use const NS2\NS2_CONSTANT2;
+use function NS1\ns1Function;
+use function NS2\ns2Function1;
+use function NS2\ns2Function2;
+
+NS1\ns1Function();
+NS2\ns2Function();
+NS2\ns2Function2();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01a/testKeepExistingUseTypeOrder_GroupPSR01a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01a/testKeepExistingUseTypeOrder_GroupPSR01a.php.fixUses
new file mode 100644
index 0000000000..22107b06c5
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01a/testKeepExistingUseTypeOrder_GroupPSR01a.php.fixUses
@@ -0,0 +1,91 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+NS2\ns2Function();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01b/testKeepExistingUseTypeOrder_GroupPSR01b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01b/testKeepExistingUseTypeOrder_GroupPSR01b.php
new file mode 100644
index 0000000000..3c75acbd6b
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01b/testKeepExistingUseTypeOrder_GroupPSR01b.php
@@ -0,0 +1,83 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use const NS2\NS2_CONSTANT2;
+use function NS1\ns1Function;
+use function NS2\ns2Function1;
+use function NS2\ns2Function2;
+
+NS1\ns1Function();
+NS2\ns2Function();
+NS2\ns2Function2();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01b/testKeepExistingUseTypeOrder_GroupPSR01b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01b/testKeepExistingUseTypeOrder_GroupPSR01b.php.fixUses
new file mode 100644
index 0000000000..5226091fc7
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR01b/testKeepExistingUseTypeOrder_GroupPSR01b.php.fixUses
@@ -0,0 +1,91 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+
+ns1Function();
+NS2\ns2Function();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02a/testKeepExistingUseTypeOrder_GroupPSR02a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02a/testKeepExistingUseTypeOrder_GroupPSR02a.php
new file mode 100644
index 0000000000..b454d27c2e
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02a/testKeepExistingUseTypeOrder_GroupPSR02a.php
@@ -0,0 +1,90 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02a/testKeepExistingUseTypeOrder_GroupPSR02a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02a/testKeepExistingUseTypeOrder_GroupPSR02a.php.fixUses
new file mode 100644
index 0000000000..8f814a3c56
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02a/testKeepExistingUseTypeOrder_GroupPSR02a.php.fixUses
@@ -0,0 +1,91 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02b/testKeepExistingUseTypeOrder_GroupPSR02b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02b/testKeepExistingUseTypeOrder_GroupPSR02b.php
new file mode 100644
index 0000000000..b454d27c2e
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02b/testKeepExistingUseTypeOrder_GroupPSR02b.php
@@ -0,0 +1,90 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02b/testKeepExistingUseTypeOrder_GroupPSR02b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02b/testKeepExistingUseTypeOrder_GroupPSR02b.php.fixUses
new file mode 100644
index 0000000000..8d918bc852
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR02b/testKeepExistingUseTypeOrder_GroupPSR02b.php.fixUses
@@ -0,0 +1,91 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\{
+ NS1Class,
+ NS1Enum,
+ NS1Interface,
+ NS1Trait
+};
+use NS2\{
+ NS2Class,
+ NS2Enum,
+ NS2Interface,
+ NS2Trait
+};
+use function NS1\ns1Function;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03a/testKeepExistingUseTypeOrder_GroupPSR03a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03a/testKeepExistingUseTypeOrder_GroupPSR03a.php
new file mode 100644
index 0000000000..8fbc08e164
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03a/testKeepExistingUseTypeOrder_GroupPSR03a.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03a/testKeepExistingUseTypeOrder_GroupPSR03a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03a/testKeepExistingUseTypeOrder_GroupPSR03a.php.fixUses
new file mode 100644
index 0000000000..48b34533d3
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03a/testKeepExistingUseTypeOrder_GroupPSR03a.php.fixUses
@@ -0,0 +1,78 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03b/testKeepExistingUseTypeOrder_GroupPSR03b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03b/testKeepExistingUseTypeOrder_GroupPSR03b.php
new file mode 100644
index 0000000000..8fbc08e164
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03b/testKeepExistingUseTypeOrder_GroupPSR03b.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03b/testKeepExistingUseTypeOrder_GroupPSR03b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03b/testKeepExistingUseTypeOrder_GroupPSR03b.php.fixUses
new file mode 100644
index 0000000000..0bef85ef70
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR03b/testKeepExistingUseTypeOrder_GroupPSR03b.php.fixUses
@@ -0,0 +1,78 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04a/testKeepExistingUseTypeOrder_GroupPSR04a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04a/testKeepExistingUseTypeOrder_GroupPSR04a.php
new file mode 100644
index 0000000000..6e07908833
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04a/testKeepExistingUseTypeOrder_GroupPSR04a.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04a/testKeepExistingUseTypeOrder_GroupPSR04a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04a/testKeepExistingUseTypeOrder_GroupPSR04a.php.fixUses
new file mode 100644
index 0000000000..1601186792
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04a/testKeepExistingUseTypeOrder_GroupPSR04a.php.fixUses
@@ -0,0 +1,76 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04b/testKeepExistingUseTypeOrder_GroupPSR04b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04b/testKeepExistingUseTypeOrder_GroupPSR04b.php
new file mode 100644
index 0000000000..6e07908833
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04b/testKeepExistingUseTypeOrder_GroupPSR04b.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\{
+ NS2_CONSTANT1,
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04b/testKeepExistingUseTypeOrder_GroupPSR04b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04b/testKeepExistingUseTypeOrder_GroupPSR04b.php.fixUses
new file mode 100644
index 0000000000..1601186792
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR04b/testKeepExistingUseTypeOrder_GroupPSR04b.php.fixUses
@@ -0,0 +1,76 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05a/testKeepExistingUseTypeOrder_GroupPSR05a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05a/testKeepExistingUseTypeOrder_GroupPSR05a.php
new file mode 100644
index 0000000000..d87ab35d67
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05a/testKeepExistingUseTypeOrder_GroupPSR05a.php
@@ -0,0 +1,73 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05a/testKeepExistingUseTypeOrder_GroupPSR05a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05a/testKeepExistingUseTypeOrder_GroupPSR05a.php.fixUses
new file mode 100644
index 0000000000..8ebb797f99
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05a/testKeepExistingUseTypeOrder_GroupPSR05a.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05b/testKeepExistingUseTypeOrder_GroupPSR05b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05b/testKeepExistingUseTypeOrder_GroupPSR05b.php
new file mode 100644
index 0000000000..d87ab35d67
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05b/testKeepExistingUseTypeOrder_GroupPSR05b.php
@@ -0,0 +1,73 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05b/testKeepExistingUseTypeOrder_GroupPSR05b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05b/testKeepExistingUseTypeOrder_GroupPSR05b.php.fixUses
new file mode 100644
index 0000000000..8ebb797f99
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/GroupPSR05b/testKeepExistingUseTypeOrder_GroupPSR05b.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS2\{
+ ns2Function1,
+ ns2Function2
+};
+use const NS2\{
+ NS2_CONSTANT1,
+ NS2_CONSTANT2
+};
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function1() {}
+function ns2Function2() {}
+
+const NS2_CONSTANT1 = "NS2_CONSTANT1";
+const NS2_CONSTANT2 = "NS2_CONSTANT2";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01a/testKeepExistingUseTypeOrder_Multiple01a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01a/testKeepExistingUseTypeOrder_Multiple01a.php
new file mode 100644
index 0000000000..22c61c3729
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01a/testKeepExistingUseTypeOrder_Multiple01a.php
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function1;
+use function NS2\ns2Function2;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use const NS2\NS2_CONSTANT2;
+
+NS1\ns1Function();
+NS2\ns2Function1();
+NS2\ns2Function2();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01a/testKeepExistingUseTypeOrder_Multiple01a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01a/testKeepExistingUseTypeOrder_Multiple01a.php.fixUses
new file mode 100644
index 0000000000..05dcd72ca5
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01a/testKeepExistingUseTypeOrder_Multiple01a.php.fixUses
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1,
+ NS2\NS2_CONSTANT2;
+
+ns1Function();
+NS2\ns2Function1();
+NS2\ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01b/testKeepExistingUseTypeOrder_Multiple01b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01b/testKeepExistingUseTypeOrder_Multiple01b.php
new file mode 100644
index 0000000000..22c61c3729
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01b/testKeepExistingUseTypeOrder_Multiple01b.php
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function1;
+use function NS2\ns2Function2;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use const NS2\NS2_CONSTANT2;
+
+NS1\ns1Function();
+NS2\ns2Function1();
+NS2\ns2Function2();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01b/testKeepExistingUseTypeOrder_Multiple01b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01b/testKeepExistingUseTypeOrder_Multiple01b.php.fixUses
new file mode 100644
index 0000000000..049a8f3f47
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple01b/testKeepExistingUseTypeOrder_Multiple01b.php.fixUses
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1,
+ NS2\NS2_CONSTANT2;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+
+ns1Function();
+NS2\ns2Function1();
+NS2\ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02a/testKeepExistingUseTypeOrder_Multiple02a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02a/testKeepExistingUseTypeOrder_Multiple02a.php
new file mode 100644
index 0000000000..4f92324580
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02a/testKeepExistingUseTypeOrder_Multiple02a.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02a/testKeepExistingUseTypeOrder_Multiple02a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02a/testKeepExistingUseTypeOrder_Multiple02a.php.fixUses
new file mode 100644
index 0000000000..d979a10233
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02a/testKeepExistingUseTypeOrder_Multiple02a.php.fixUses
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1,
+ NS2\NS2_CONSTANT2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02b/testKeepExistingUseTypeOrder_Multiple02b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02b/testKeepExistingUseTypeOrder_Multiple02b.php
new file mode 100644
index 0000000000..4f92324580
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02b/testKeepExistingUseTypeOrder_Multiple02b.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02b/testKeepExistingUseTypeOrder_Multiple02b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02b/testKeepExistingUseTypeOrder_Multiple02b.php.fixUses
new file mode 100644
index 0000000000..4316a8e455
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple02b/testKeepExistingUseTypeOrder_Multiple02b.php.fixUses
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1,
+ NS2\NS2_CONSTANT2;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03a/testKeepExistingUseTypeOrder_Multiple03a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03a/testKeepExistingUseTypeOrder_Multiple03a.php
new file mode 100644
index 0000000000..59ae757911
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03a/testKeepExistingUseTypeOrder_Multiple03a.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03a/testKeepExistingUseTypeOrder_Multiple03a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03a/testKeepExistingUseTypeOrder_Multiple03a.php.fixUses
new file mode 100644
index 0000000000..a3feeea642
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03a/testKeepExistingUseTypeOrder_Multiple03a.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03b/testKeepExistingUseTypeOrder_Multiple03b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03b/testKeepExistingUseTypeOrder_Multiple03b.php
new file mode 100644
index 0000000000..59ae757911
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03b/testKeepExistingUseTypeOrder_Multiple03b.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03b/testKeepExistingUseTypeOrder_Multiple03b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03b/testKeepExistingUseTypeOrder_Multiple03b.php.fixUses
new file mode 100644
index 0000000000..2bf7a3d552
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple03b/testKeepExistingUseTypeOrder_Multiple03b.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04a/testKeepExistingUseTypeOrder_Multiple04a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04a/testKeepExistingUseTypeOrder_Multiple04a.php
new file mode 100644
index 0000000000..59ae757911
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04a/testKeepExistingUseTypeOrder_Multiple04a.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04a/testKeepExistingUseTypeOrder_Multiple04a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04a/testKeepExistingUseTypeOrder_Multiple04a.php.fixUses
new file mode 100644
index 0000000000..4c97285301
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04a/testKeepExistingUseTypeOrder_Multiple04a.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04b/testKeepExistingUseTypeOrder_Multiple04b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04b/testKeepExistingUseTypeOrder_Multiple04b.php
new file mode 100644
index 0000000000..59ae757911
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04b/testKeepExistingUseTypeOrder_Multiple04b.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04b/testKeepExistingUseTypeOrder_Multiple04b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04b/testKeepExistingUseTypeOrder_Multiple04b.php.fixUses
new file mode 100644
index 0000000000..4c97285301
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple04b/testKeepExistingUseTypeOrder_Multiple04b.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05a/testKeepExistingUseTypeOrder_Multiple05a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05a/testKeepExistingUseTypeOrder_Multiple05a.php
new file mode 100644
index 0000000000..d80c5dd01f
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05a/testKeepExistingUseTypeOrder_Multiple05a.php
@@ -0,0 +1,69 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05a/testKeepExistingUseTypeOrder_Multiple05a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05a/testKeepExistingUseTypeOrder_Multiple05a.php.fixUses
new file mode 100644
index 0000000000..3be38e7013
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05a/testKeepExistingUseTypeOrder_Multiple05a.php.fixUses
@@ -0,0 +1,70 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05b/testKeepExistingUseTypeOrder_Multiple05b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05b/testKeepExistingUseTypeOrder_Multiple05b.php
new file mode 100644
index 0000000000..d80c5dd01f
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05b/testKeepExistingUseTypeOrder_Multiple05b.php
@@ -0,0 +1,69 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05b/testKeepExistingUseTypeOrder_Multiple05b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05b/testKeepExistingUseTypeOrder_Multiple05b.php.fixUses
new file mode 100644
index 0000000000..3be38e7013
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Multiple05b/testKeepExistingUseTypeOrder_Multiple05b.php.fixUses
@@ -0,0 +1,70 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01a/testKeepExistingUseTypeOrder_MultiplePSR01a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01a/testKeepExistingUseTypeOrder_MultiplePSR01a.php
new file mode 100644
index 0000000000..f871f7f42e
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01a/testKeepExistingUseTypeOrder_MultiplePSR01a.php
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use const NS2\NS2_CONSTANT2;
+use function NS1\ns1Function;
+use function NS2\ns2Function1;
+use function NS2\ns2Function2;
+
+NS1\ns1Function();
+NS2\ns2Function1();
+NS2\ns2Function2();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01a/testKeepExistingUseTypeOrder_MultiplePSR01a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01a/testKeepExistingUseTypeOrder_MultiplePSR01a.php.fixUses
new file mode 100644
index 0000000000..049a8f3f47
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01a/testKeepExistingUseTypeOrder_MultiplePSR01a.php.fixUses
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1,
+ NS2\NS2_CONSTANT2;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+
+ns1Function();
+NS2\ns2Function1();
+NS2\ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01b/testKeepExistingUseTypeOrder_MultiplePSR01b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01b/testKeepExistingUseTypeOrder_MultiplePSR01b.php
new file mode 100644
index 0000000000..f871f7f42e
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01b/testKeepExistingUseTypeOrder_MultiplePSR01b.php
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT1;
+use const NS2\NS2_CONSTANT2;
+use function NS1\ns1Function;
+use function NS2\ns2Function1;
+use function NS2\ns2Function2;
+
+NS1\ns1Function();
+NS2\ns2Function1();
+NS2\ns2Function2();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01b/testKeepExistingUseTypeOrder_MultiplePSR01b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01b/testKeepExistingUseTypeOrder_MultiplePSR01b.php.fixUses
new file mode 100644
index 0000000000..05dcd72ca5
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR01b/testKeepExistingUseTypeOrder_MultiplePSR01b.php.fixUses
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1,
+ NS2\NS2_CONSTANT2;
+
+ns1Function();
+NS2\ns2Function1();
+NS2\ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT1;
+$const2 = NS2\NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02a/testKeepExistingUseTypeOrder_MultiplePSR02a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02a/testKeepExistingUseTypeOrder_MultiplePSR02a.php
new file mode 100644
index 0000000000..c847fc9870
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02a/testKeepExistingUseTypeOrder_MultiplePSR02a.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02a/testKeepExistingUseTypeOrder_MultiplePSR02a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02a/testKeepExistingUseTypeOrder_MultiplePSR02a.php.fixUses
new file mode 100644
index 0000000000..4316a8e455
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02a/testKeepExistingUseTypeOrder_MultiplePSR02a.php.fixUses
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1,
+ NS2\NS2_CONSTANT2;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02b/testKeepExistingUseTypeOrder_MultiplePSR02b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02b/testKeepExistingUseTypeOrder_MultiplePSR02b.php
new file mode 100644
index 0000000000..c847fc9870
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02b/testKeepExistingUseTypeOrder_MultiplePSR02b.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02b/testKeepExistingUseTypeOrder_MultiplePSR02b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02b/testKeepExistingUseTypeOrder_MultiplePSR02b.php.fixUses
new file mode 100644
index 0000000000..d979a10233
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR02b/testKeepExistingUseTypeOrder_MultiplePSR02b.php.fixUses
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class,
+ NS1\NS1Enum,
+ NS1\NS1Interface,
+ NS1\NS1Trait,
+ NS2\NS2Class,
+ NS2\NS2Enum,
+ NS2\NS2Interface,
+ NS2\NS2Trait;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1,
+ NS2\NS2_CONSTANT2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03a/testKeepExistingUseTypeOrder_MultiplePSR03a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03a/testKeepExistingUseTypeOrder_MultiplePSR03a.php
new file mode 100644
index 0000000000..9cf9c5063b
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03a/testKeepExistingUseTypeOrder_MultiplePSR03a.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03a/testKeepExistingUseTypeOrder_MultiplePSR03a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03a/testKeepExistingUseTypeOrder_MultiplePSR03a.php.fixUses
new file mode 100644
index 0000000000..2bf7a3d552
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03a/testKeepExistingUseTypeOrder_MultiplePSR03a.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03b/testKeepExistingUseTypeOrder_MultiplePSR03b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03b/testKeepExistingUseTypeOrder_MultiplePSR03b.php
new file mode 100644
index 0000000000..9cf9c5063b
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03b/testKeepExistingUseTypeOrder_MultiplePSR03b.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03b/testKeepExistingUseTypeOrder_MultiplePSR03b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03b/testKeepExistingUseTypeOrder_MultiplePSR03b.php.fixUses
new file mode 100644
index 0000000000..a3feeea642
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR03b/testKeepExistingUseTypeOrder_MultiplePSR03b.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function,
+ NS2\ns2Function1,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04a/testKeepExistingUseTypeOrder_MultiplePSR04a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04a/testKeepExistingUseTypeOrder_MultiplePSR04a.php
new file mode 100644
index 0000000000..9cf9c5063b
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04a/testKeepExistingUseTypeOrder_MultiplePSR04a.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04a/testKeepExistingUseTypeOrder_MultiplePSR04a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04a/testKeepExistingUseTypeOrder_MultiplePSR04a.php.fixUses
new file mode 100644
index 0000000000..b0f185f942
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04a/testKeepExistingUseTypeOrder_MultiplePSR04a.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04b/testKeepExistingUseTypeOrder_MultiplePSR04b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04b/testKeepExistingUseTypeOrder_MultiplePSR04b.php
new file mode 100644
index 0000000000..9cf9c5063b
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04b/testKeepExistingUseTypeOrder_MultiplePSR04b.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04b/testKeepExistingUseTypeOrder_MultiplePSR04b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04b/testKeepExistingUseTypeOrder_MultiplePSR04b.php.fixUses
new file mode 100644
index 0000000000..b0f185f942
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR04b/testKeepExistingUseTypeOrder_MultiplePSR04b.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use function NS1\ns1Function,
+ NS2\ns2Function2;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05a/testKeepExistingUseTypeOrder_MultiplePSR05a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05a/testKeepExistingUseTypeOrder_MultiplePSR05a.php
new file mode 100644
index 0000000000..d80c5dd01f
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05a/testKeepExistingUseTypeOrder_MultiplePSR05a.php
@@ -0,0 +1,69 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05a/testKeepExistingUseTypeOrder_MultiplePSR05a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05a/testKeepExistingUseTypeOrder_MultiplePSR05a.php.fixUses
new file mode 100644
index 0000000000..3be38e7013
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05a/testKeepExistingUseTypeOrder_MultiplePSR05a.php.fixUses
@@ -0,0 +1,70 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05b/testKeepExistingUseTypeOrder_MultiplePSR05b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05b/testKeepExistingUseTypeOrder_MultiplePSR05b.php
new file mode 100644
index 0000000000..d80c5dd01f
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05b/testKeepExistingUseTypeOrder_MultiplePSR05b.php
@@ -0,0 +1,69 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05b/testKeepExistingUseTypeOrder_MultiplePSR05b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05b/testKeepExistingUseTypeOrder_MultiplePSR05b.php.fixUses
new file mode 100644
index 0000000000..3be38e7013
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/MultiplePSR05b/testKeepExistingUseTypeOrder_MultiplePSR05b.php.fixUses
@@ -0,0 +1,70 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS2\NS2Class;
+use const NS1\NS1_CONSTANT,
+ NS2\NS2_CONSTANT1;
+
+ns1Function();
+ns2Function1();
+ns2Function2();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT1;
+$const2 = NS2_CONSTANT2;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01a/testKeepExistingUseTypeOrder_Single01a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01a/testKeepExistingUseTypeOrder_Single01a.php
new file mode 100644
index 0000000000..ddbfb0b404
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01a/testKeepExistingUseTypeOrder_Single01a.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+
+NS1\ns1Function();
+NS2\ns2Function();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01a/testKeepExistingUseTypeOrder_Single01a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01a/testKeepExistingUseTypeOrder_Single01a.php.fixUses
new file mode 100644
index 0000000000..804da660b0
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01a/testKeepExistingUseTypeOrder_Single01a.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01b/testKeepExistingUseTypeOrder_Single01b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01b/testKeepExistingUseTypeOrder_Single01b.php
new file mode 100644
index 0000000000..ddbfb0b404
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01b/testKeepExistingUseTypeOrder_Single01b.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+
+NS1\ns1Function();
+NS2\ns2Function();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01b/testKeepExistingUseTypeOrder_Single01b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01b/testKeepExistingUseTypeOrder_Single01b.php.fixUses
new file mode 100644
index 0000000000..70290162cc
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single01b/testKeepExistingUseTypeOrder_Single01b.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02a/testKeepExistingUseTypeOrder_Single02a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02a/testKeepExistingUseTypeOrder_Single02a.php
new file mode 100644
index 0000000000..92645f6fc9
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02a/testKeepExistingUseTypeOrder_Single02a.php
@@ -0,0 +1,76 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02a/testKeepExistingUseTypeOrder_Single02a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02a/testKeepExistingUseTypeOrder_Single02a.php.fixUses
new file mode 100644
index 0000000000..804da660b0
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02a/testKeepExistingUseTypeOrder_Single02a.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02b/testKeepExistingUseTypeOrder_Single02b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02b/testKeepExistingUseTypeOrder_Single02b.php
new file mode 100644
index 0000000000..92645f6fc9
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02b/testKeepExistingUseTypeOrder_Single02b.php
@@ -0,0 +1,76 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02b/testKeepExistingUseTypeOrder_Single02b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02b/testKeepExistingUseTypeOrder_Single02b.php.fixUses
new file mode 100644
index 0000000000..70290162cc
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single02b/testKeepExistingUseTypeOrder_Single02b.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03a/testKeepExistingUseTypeOrder_Single03a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03a/testKeepExistingUseTypeOrder_Single03a.php
new file mode 100644
index 0000000000..39cbf14d58
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03a/testKeepExistingUseTypeOrder_Single03a.php
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03a/testKeepExistingUseTypeOrder_Single03a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03a/testKeepExistingUseTypeOrder_Single03a.php.fixUses
new file mode 100644
index 0000000000..b9e7b14294
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03a/testKeepExistingUseTypeOrder_Single03a.php.fixUses
@@ -0,0 +1,69 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03b/testKeepExistingUseTypeOrder_Single03b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03b/testKeepExistingUseTypeOrder_Single03b.php
new file mode 100644
index 0000000000..39cbf14d58
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03b/testKeepExistingUseTypeOrder_Single03b.php
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03b/testKeepExistingUseTypeOrder_Single03b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03b/testKeepExistingUseTypeOrder_Single03b.php.fixUses
new file mode 100644
index 0000000000..d663b843f4
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single03b/testKeepExistingUseTypeOrder_Single03b.php.fixUses
@@ -0,0 +1,69 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04a/testKeepExistingUseTypeOrder_Single04a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04a/testKeepExistingUseTypeOrder_Single04a.php
new file mode 100644
index 0000000000..39cbf14d58
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04a/testKeepExistingUseTypeOrder_Single04a.php
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04a/testKeepExistingUseTypeOrder_Single04a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04a/testKeepExistingUseTypeOrder_Single04a.php.fixUses
new file mode 100644
index 0000000000..3a72ec1d6c
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04a/testKeepExistingUseTypeOrder_Single04a.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Interface;
+use NS2\NS2Enum;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04b/testKeepExistingUseTypeOrder_Single04b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04b/testKeepExistingUseTypeOrder_Single04b.php
new file mode 100644
index 0000000000..39cbf14d58
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04b/testKeepExistingUseTypeOrder_Single04b.php
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04b/testKeepExistingUseTypeOrder_Single04b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04b/testKeepExistingUseTypeOrder_Single04b.php.fixUses
new file mode 100644
index 0000000000..3a72ec1d6c
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single04b/testKeepExistingUseTypeOrder_Single04b.php.fixUses
@@ -0,0 +1,72 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Interface;
+use NS2\NS2Enum;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05a/testKeepExistingUseTypeOrder_Single05a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05a/testKeepExistingUseTypeOrder_Single05a.php
new file mode 100644
index 0000000000..d327fde883
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05a/testKeepExistingUseTypeOrder_Single05a.php
@@ -0,0 +1,67 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05a/testKeepExistingUseTypeOrder_Single05a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05a/testKeepExistingUseTypeOrder_Single05a.php.fixUses
new file mode 100644
index 0000000000..0398693e72
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05a/testKeepExistingUseTypeOrder_Single05a.php.fixUses
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05b/testKeepExistingUseTypeOrder_Single05b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05b/testKeepExistingUseTypeOrder_Single05b.php
new file mode 100644
index 0000000000..d327fde883
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05b/testKeepExistingUseTypeOrder_Single05b.php
@@ -0,0 +1,67 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05b/testKeepExistingUseTypeOrder_Single05b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05b/testKeepExistingUseTypeOrder_Single05b.php.fixUses
new file mode 100644
index 0000000000..0398693e72
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/Single05b/testKeepExistingUseTypeOrder_Single05b.php.fixUses
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01a/testKeepExistingUseTypeOrder_SinglePSR01a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01a/testKeepExistingUseTypeOrder_SinglePSR01a.php
new file mode 100644
index 0000000000..60ac8531b8
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01a/testKeepExistingUseTypeOrder_SinglePSR01a.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+NS1\ns1Function();
+NS2\ns2Function();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01a/testKeepExistingUseTypeOrder_SinglePSR01a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01a/testKeepExistingUseTypeOrder_SinglePSR01a.php.fixUses
new file mode 100644
index 0000000000..70290162cc
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01a/testKeepExistingUseTypeOrder_SinglePSR01a.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01b/testKeepExistingUseTypeOrder_SinglePSR01b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01b/testKeepExistingUseTypeOrder_SinglePSR01b.php
new file mode 100644
index 0000000000..60ac8531b8
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01b/testKeepExistingUseTypeOrder_SinglePSR01b.php
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+NS1\ns1Function();
+NS2\ns2Function();
+$const1 = NS1\NS1_CONSTANT;
+$const2 = NS2\NS2_CONSTANT;
+
+class Test implements NS1\NS1Interface, NS2\NS2Interface {
+ public const CONSTANT1 = NS1\NS1Enum::Case1;
+ public const CONSTANT2 = NS2\NS2Enum::Case1;
+ use NS1\NS1Trait;
+ use NS2\NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1\NS1Class();
+ $ns2 = new NS2\NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01b/testKeepExistingUseTypeOrder_SinglePSR01b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01b/testKeepExistingUseTypeOrder_SinglePSR01b.php.fixUses
new file mode 100644
index 0000000000..804da660b0
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR01b/testKeepExistingUseTypeOrder_SinglePSR01b.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02a/testKeepExistingUseTypeOrder_SinglePSR02a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02a/testKeepExistingUseTypeOrder_SinglePSR02a.php
new file mode 100644
index 0000000000..fec933c55a
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02a/testKeepExistingUseTypeOrder_SinglePSR02a.php
@@ -0,0 +1,76 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02a/testKeepExistingUseTypeOrder_SinglePSR02a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02a/testKeepExistingUseTypeOrder_SinglePSR02a.php.fixUses
new file mode 100644
index 0000000000..70290162cc
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02a/testKeepExistingUseTypeOrder_SinglePSR02a.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02b/testKeepExistingUseTypeOrder_SinglePSR02b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02b/testKeepExistingUseTypeOrder_SinglePSR02b.php
new file mode 100644
index 0000000000..fec933c55a
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02b/testKeepExistingUseTypeOrder_SinglePSR02b.php
@@ -0,0 +1,76 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use const NS1\NS1_CONSTANT;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02b/testKeepExistingUseTypeOrder_SinglePSR02b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02b/testKeepExistingUseTypeOrder_SinglePSR02b.php.fixUses
new file mode 100644
index 0000000000..804da660b0
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR02b/testKeepExistingUseTypeOrder_SinglePSR02b.php.fixUses
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use NS1\NS1Enum;
+use NS1\NS1Interface;
+use NS1\NS1Trait;
+use NS2\NS2Class;
+use NS2\NS2Enum;
+use NS2\NS2Interface;
+use NS2\NS2Trait;
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03a/testKeepExistingUseTypeOrder_SinglePSR03a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03a/testKeepExistingUseTypeOrder_SinglePSR03a.php
new file mode 100644
index 0000000000..590b3a42d1
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03a/testKeepExistingUseTypeOrder_SinglePSR03a.php
@@ -0,0 +1,67 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT;
+use NS1\NS1Class;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03a/testKeepExistingUseTypeOrder_SinglePSR03a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03a/testKeepExistingUseTypeOrder_SinglePSR03a.php.fixUses
new file mode 100644
index 0000000000..c07ea4997a
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03a/testKeepExistingUseTypeOrder_SinglePSR03a.php.fixUses
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+use NS1\NS1Class;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03b/testKeepExistingUseTypeOrder_SinglePSR03b.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03b/testKeepExistingUseTypeOrder_SinglePSR03b.php
new file mode 100644
index 0000000000..590b3a42d1
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03b/testKeepExistingUseTypeOrder_SinglePSR03b.php
@@ -0,0 +1,67 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use const NS1\NS1_CONSTANT;
+use NS1\NS1Class;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03b/testKeepExistingUseTypeOrder_SinglePSR03b.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03b/testKeepExistingUseTypeOrder_SinglePSR03b.php.fixUses
new file mode 100644
index 0000000000..b5ab8b9a0c
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR03b/testKeepExistingUseTypeOrder_SinglePSR03b.php.fixUses
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use NS1\NS1Class;
+use const NS1\NS1_CONSTANT;
+use const NS2\NS2_CONSTANT;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR04a/testKeepExistingUseTypeOrder_SinglePSR04a.php b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR04a/testKeepExistingUseTypeOrder_SinglePSR04a.php
new file mode 100644
index 0000000000..dce45d1701
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR04a/testKeepExistingUseTypeOrder_SinglePSR04a.php
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace NS\Test;
+
+use function NS1\ns1Function;
+use function NS2\ns2Function;
+use NS1\NS1Class;
+
+ns1Function();
+ns2Function();
+$const1 = NS1_CONSTANT;
+$const2 = NS2_CONSTANT;
+
+class Test implements NS1Interface, NS2Interface {
+ public const CONSTANT1 = NS1Enum::Case1;
+ public const CONSTANT2 = NS2Enum::Case1;
+ use NS1Trait;
+ use NS2Trait;
+ public function method(): void {
+ $ns1 = new NS1Class();
+ $ns2 = new NS2Class();
+ }
+}
+
+namespace NS1;
+
+function ns1Function() {}
+
+const NS1_CONSTANT = "NS1_CONSTANT";
+
+class NS1Class {}
+interface NS1Interface {}
+trait NS1Trait {}
+enum NS1Enum {
+ case CASE1;
+}
+
+namespace NS2;
+
+function ns2Function() {}
+
+const NS2_CONSTANT = "NS2_CONSTANT";
+
+class NS2Class {}
+interface NS2Interface {}
+trait NS2Trait {}
+enum NS2Enum {
+ case CASE1;
+}
+
diff --git a/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR04a/testKeepExistingUseTypeOrder_SinglePSR04a.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR04a/testKeepExistingUseTypeOrder_SinglePSR04a.php.fixUses
new file mode 100644
index 0000000000..1600ba9911
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/actions/testKeepExistingUseTypeOrder/SinglePSR04a/testKeepExistingUseTypeOrder_SinglePSR04a.php.fixUses
@@ -0,0 +1,69 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
... 1311 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists