RuleOverrides
in package
Changes to the PHP rules by rule code: rules switched off, findings with another severity and rules replaced by own implementations. Codes match exactly or, with a trailing "*", by prefix (e.g. "DE-USTG-*"). The overrides apply to the PHP rules only; the findings of the XSD schema, KoSIT and veraPDF are never changed.
The rules of EN 16931 (BR-) and Peppol (PEPPOL-) are official: switching them off, changing their severity or replacing them needs $allowOfficial, because an invoice that breaks them is rejected by the receiver.
Table of Contents
Properties
- $allowOfficial : bool
- $disabled : array<string|int, mixed>
- $replacements : array<string|int, mixed>
- $severities : array<string|int, mixed>
Methods
- __construct() : mixed
- apply() : array<int, Rule>
- The rules without the disabled ones, replaced rules exchanged in place.
- applyToMessages() : array<int, ValidationMessage>
- The findings without those of disabled codes, with the configured severities. Rules may report other codes than their own (e.g. QUITTIO-PROFILE-REQUIRED), so the findings are filtered as well.
- fromArray() : self
- From the configuration keys disabled (list of codes), severity (code => error, warning or info) and allow_official.
- isDisabled() : bool
- Whether findings with this code are dropped.
- isEmpty() : bool
- Whether nothing is disabled, re-rated or replaced.
- matches() : bool
- Whether a pattern matches a code: exactly, or by prefix with a trailing "*".
- merge() : self
- These overrides with those of $other on top: $other wins for the same code.
- patterns() : array<int, string>
- Every pattern of these overrides, e.g. to check them against the known rule codes.
Properties
$allowOfficial
public
bool
$allowOfficial
= false
$disabled
public
array<string|int, mixed>
$disabled
= []
$replacements
public
array<string|int, mixed>
$replacements
= []
$severities
public
array<string|int, mixed>
$severities
= []
Methods
__construct()
public
__construct([array<int, string> $disabled = [] ][, array<string, Severity> $severities = [] ][, array<string, Rule> $replacements = [] ][, bool $allowOfficial = false ]) : mixed
Parameters
- $disabled : array<int, string> = []
-
codes or prefixes ending with "*" whose rules and findings are dropped
- $severities : array<string, Severity> = []
-
severity of the findings per code or prefix
- $replacements : array<string, Rule> = []
-
rules that replace the rule with the code of the key
- $allowOfficial : bool = false
Tags
apply()
The rules without the disabled ones, replaced rules exchanged in place.
public
apply(array<int, Rule> $rules) : array<int, Rule>
Parameters
- $rules : array<int, Rule>
Return values
array<int, Rule>applyToMessages()
The findings without those of disabled codes, with the configured severities. Rules may report other codes than their own (e.g. QUITTIO-PROFILE-REQUIRED), so the findings are filtered as well.
public
applyToMessages(array<int, ValidationMessage> $messages) : array<int, ValidationMessage>
Parameters
- $messages : array<int, ValidationMessage>
Return values
array<int, ValidationMessage>fromArray()
From the configuration keys disabled (list of codes), severity (code => error, warning or info) and allow_official.
public
static fromArray(array<string|int, mixed> $config) : self
Parameters
- $config : array<string|int, mixed>
Tags
Return values
selfisDisabled()
Whether findings with this code are dropped.
public
isDisabled(string $code) : bool
Parameters
- $code : string
Return values
boolisEmpty()
Whether nothing is disabled, re-rated or replaced.
public
isEmpty() : bool
Return values
boolmatches()
Whether a pattern matches a code: exactly, or by prefix with a trailing "*".
public
static matches(string $pattern, string $code) : bool
Parameters
- $pattern : string
- $code : string
Return values
boolmerge()
These overrides with those of $other on top: $other wins for the same code.
public
merge(self $other) : self
Parameters
- $other : self
Return values
selfpatterns()
Every pattern of these overrides, e.g. to check them against the known rule codes.
public
patterns() : array<int, string>