Sort allow-plugins
and preferred-install
when feasible
#980
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following on from the discussion in #775 (comment), this pull request re-adds sorting of
allow-plugins
andpreferred-install
, but takes into account the difficult case of a wildcard in the middle of a package name.This pull request
config.allow-plugins
incomposer.json
when there are no wildcards used.config.allow-plugins
incomposer.json
when there are wildcards used, but only at the end of package names.config.allow-plugins
incomposer.json
unsorted when there are wildcards used in the middle of a package name.config.preferred-install
incomposer.json
when there are no wildcards used.config.preferred-install
incomposer.json
when there are wildcards used, but only at the end of package names.config.preferred-install
incomposer.json
unsorted when there are wildcards used in the middle of a package name.Follows #775 (comment)
I considered only sorting the packages when there are no wildcards. This would make the code much more simple, and remove any chance of messing up the wildcard parsing process. I opted to sort the list whenever possible, including when wildcards are used, but kept the not-sorted behaviour when a wildcard is found part-way-through a package name.
Another approach that I considered was to remove entries which are unreachable (see the '.../IsUseful/No/' test fixtures). I decided to keep these as users may have added entries thinking that the list sorts the other way (last match, whereas it is actually first-match). Correcting this seems most useful to end users. They can then make their own decision if the entry should exist or not.