API Index — Namespaces, Packages, Reports, Indices
RequestInput
in package
Backs the mod_php-parity filter_input() / filter_input_array() overrides.
Under the CLI SAPI, PHP's native filter_input() reads the internal SAPI request
tables, which OpenSwoole never populates — so legacy code using INPUT_GET /
INPUT_POST / INPUT_COOKIE / INPUT_SERVER silently gets null. ZealPHP routes
request input through RequestContext ($g) instead; this class resolves the
right bag and applies the same filters PHP's filter extension would.
The filtering methods are pure (bag in, result out) so they unit-test without
a server. bagFor() is the only context-dependent method and is fully guarded —
a diagnostics/compat shim must never fatal.
Table of Contents
Methods
- bagFor() : array<string, mixed>
- Resolve a PHP
INPUT_*type to the matching request bag fromRequestContext. - filterArray() : array<string, mixed>
- Filter a whole bag, mirroring
filter_input_array()— delegates to the nativefilter_var_array()so per-key definitions andadd_emptybehave identically to PHP's filter extension. - filterValue() : mixed
- Filter a single value from a bag, mirroring
filter_input()semantics: missing key →null; otherwisefilter_var()(falseon failed validation). - stringKeyed() : array<string, mixed>
- Normalize a bag to string-keyed entries (
filter_inputaddresses by name).
Methods
bagFor()
Resolve a PHP INPUT_* type to the matching request bag from RequestContext.
public
static bagFor(int $type) : array<string, mixed>
Parameters
- $type : int
Return values
array<string, mixed>filterArray()
Filter a whole bag, mirroring filter_input_array() — delegates to the
native filter_var_array() so per-key definitions and add_empty behave
identically to PHP's filter extension.
public
static filterArray(array<string, mixed> $bag, array<string, mixed>|int $definition, bool $addEmpty) : array<string, mixed>
Parameters
- $bag : array<string, mixed>
- $definition : array<string, mixed>|int
- $addEmpty : bool
Return values
array<string, mixed>filterValue()
Filter a single value from a bag, mirroring filter_input() semantics:
missing key → null; otherwise filter_var() (false on failed validation).
public
static filterValue(array<string, mixed> $bag, string $name, int $filter, array<string, mixed>|int $options) : mixed
Parameters
- $bag : array<string, mixed>
- $name : string
- $filter : int
- $options : array<string, mixed>|int
stringKeyed()
Normalize a bag to string-keyed entries (filter_input addresses by name).
private
static stringKeyed(array<string|int, mixed> $bag) : array<string, mixed>
Parameters
- $bag : array<string|int, mixed>