RuleCustomisationPolicyInterface
in
EXPERIMENTAL: This feature is experimental and does not fall under the backward compatibility promise.
Tags
Table of Contents
Methods
- getPolicyVersionForCache() : non-empty-string
- Returns a string that changes when the policy implementation changes in a way that would affect the cache validity.
- getRuleCustomisers() : array<non-empty-string, _RuleCustomisationPolicyCallback>
- Customise fixers for given files.
Methods
getPolicyVersionForCache()
Returns a string that changes when the policy implementation changes in a way that would affect the cache validity.
public
getPolicyVersionForCache() : non-empty-string
Tags
Return values
non-empty-stringgetRuleCustomisers()
Customise fixers for given files.
public
getRuleCustomisers() : array<non-empty-string, _RuleCustomisationPolicyCallback>
Array keys are fixer names, values are closures that will be invoked before applying the fixer to a specific file. The closures receive the file as argument and must return:
- true to apply the fixer as is to the file
- false to skip applying the fixer to the file
- a new fixer instance to apply a customised version of the fixer
When PHP CS Fixer is about to start fixing files, it will check that the currently used fixers include at least all the fixers for which customisation rules are defined. If a customiser is defined for a fixer that is not currently applied, an exception will be thrown. This ensures that customisers are actually used for expected fixerswhich may be replaced by newer fixers in newer versions of PHP CS Fixer. Since fixer sets may change even in patch releases, this also means that your implementation of this interface may need to be updated accordingly, even in patch releases. So, we can't guarantee semver compatibility for Rule Customisation Policies.