SensitiveDataRedactor
API reference › Debug Core › Helper › SensitiveDataRedactor
Replaces values whose array keys match configured exact names, prefixes, or PCRE patterns.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
isSensitiveKey() static | Returns whether a key matches a configured exact name, literal prefix, or PCRE pattern. | SensitiveDataRedactor |
patterns() static | Resolves the pattern list a redaction rule set applies, preserving exact-list override behavior. | SensitiveDataRedactor |
redact() static | Redacts configured keys case-insensitively throughout a bounded nested array. | SensitiveDataRedactor |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
DEFAULT_KEYS | ['access_token', | Common credential and session fields that must never be persisted by default. | SensitiveDataRedactor |
DEFAULT_PATTERNS | ['~(?:^| | Segment-aware defaults for environment-style credential keys. | SensitiveDataRedactor |
PLACEHOLDER | '[redacted]' | Replacement written in place of a sensitive value. | SensitiveDataRedactor |
TRUNCATED | '[truncated]' | Replacement written where the depth or node budget stops traversal. | SensitiveDataRedactor |
Method details
Section titled “Method details”isSensitiveKey()
Section titled “isSensitiveKey() ”public static function isSensitiveKey(string $key, list<string> $sensitiveKeys = \self::DEFAULT_KEYS, list<string> $sensitiveKeyPrefixes = [], list<string>|null $sensitiveKeyPatterns = null): boolReturns whether a key matches a configured exact name, literal prefix, or PCRE pattern.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Original key to inspect. Exact names and literal prefixes ignore case; PCRE patterns retain their own case-sensitivity modifiers. |
$sensitiveKeys | list<string> | Exact key names to inspect. |
$sensitiveKeyPrefixes | list<string> | Literal key prefixes to inspect case-insensitively. |
$sensitiveKeyPatterns | list<string>| | PCRE patterns applied to the complete original key. null uses defaults only with the default exact-key list; [] explicitly disables patterns. |
Returns
bool: true when the key matches any configured rule; false otherwise.
patterns()
Section titled “patterns() ”public static function patterns(list<string> $keys, list<string>|null $patterns): list<string>Resolves the pattern list a redaction rule set applies, preserving exact-list override behavior.
An explicit list wins. Otherwise DEFAULT_PATTERNS applies only alongside the unmodified
DEFAULT_KEYS list, so a custom exact-key list never inherits the segment-aware defaults.
Parameters
| Parameter | Type | Description |
|---|---|---|
$keys | list<string> | Configured exact key names. |
$patterns | list<string>| | Configured PCRE patterns, or null to resolve the defaults. |
Returns
list<string>: Patterns applied to complete original keys.
redact()
Section titled “redact() ”public static function redact(array<PHPForge\Debug\Helper\TKey, mixed> $value, list<string> $sensitiveKeys = \self::DEFAULT_KEYS, list<string> $sensitiveKeyPrefixes = [], list<string>|null $sensitiveKeyPatterns = null): array<PHPForge\Debug\Helper\TKey, mixed>Redacts configured keys case-insensitively throughout a bounded nested array.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | array<PHPForge\ | Value tree to sanitize. |
$sensitiveKeys | list<string> | Exact key names to redact. |
$sensitiveKeyPrefixes | list<string> | Literal key prefixes to redact case-insensitively. |
$sensitiveKeyPatterns | list<string>| | PCRE patterns applied to complete original keys. null uses defaults only with the default exact-key list; [] explicitly disables patterns. |
Returns
array<PHPForge\Debug\Helper\TKey, mixed>: Sanitized tree with keys and non-sensitive values preserved.