Ruleset: allow for extending pre-existing array values #1025
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.
Description
As things were, using
extend="true"
when setting an array property in a ruleset XML file could only extend another array property setting set in an (included) ruleset file.A potential default array value set on the sniff itself could not be extended.
This commit changes this behaviour.
If a default array value is defined on a sniff, setting additional array values via a ruleset with
extend="true"
will now add these values to the pre-existing sniff property default value.This also now allows for redefining the array value for a predefined associative key.
Includes plenty of tests documenting and safeguarding the feature.
Suggested changelog entry
Support for extending a default value for an array property on a sniff from an XML ruleset file.
- Previously, using
extend="true"
on an property tag for setting an array value could already extend a property value set elsewhere in an (inluded) ruleset.- Now, you can also add to (extend) a default value as set on the sniff itself.
- Note: the property default value and the values set via the ruleset will be merged.
- This also means that for associative arrays, you can redefine the value for a particular array key.
- For numerically indexed arrays, this means the array will be renumbered. Keep this in mind if the numeric indexes hold meaning.
Related issues/external references
Fixes #15