Requests Utility Classes
Utility classes for the Requests library.
Source files:
wp-includes/Requests/src/Utility/CaseInsensitiveDictionary.phpwp-includes/Requests/src/Utility/FilteredIterator.phpwp-includes/Requests/src/Utility/InputValidator.php
WpOrgRequestsUtilityCaseInsensitiveDictionary
Case-insensitive dictionary, suitable for HTTP headers.
Namespace: WpOrgRequestsUtility
Package: RequestsUtilities
Implements: ArrayAccess, IteratorAggregate
Properties
| Property | Type | Visibility | Default | Description |
|---|---|---|---|---|
$data | array | protected | [] | Actual item data (keys stored lowercased) |
Methods
__construct()
public function __construct( array $data = [] )Iterates over $data and calls offsetSet() for each entry (lowercasing keys).
offsetExists()
public function offsetExists( string $offset ): boolLowercases the key before checking. Uses #[ReturnTypeWillChange] attribute.
offsetGet()
public function offsetGet( string $offset ): string|nullReturns null if the key doesn’t exist. Lowercases the key before lookup.
offsetSet()
public function offsetSet( string $offset, string $value ): voidThrows: Exception (invalidset) when $offset is null (prevents list-style $dict[] = value usage).
Lowercases the key before storing.
offsetUnset()
public function offsetUnset( string $offset ): voidLowercases the key before unsetting.
getIterator()
public function getIterator(): ArrayIteratorReturns an ArrayIterator over the internal data.
getAll()
public function getAll(): arrayReturns the raw $data array.
WpOrgRequestsUtilityFilteredIterator
Iterator that applies a callback filter to values on access.
Namespace: WpOrgRequestsUtility
Package: RequestsUtilities
Modifier: final
Extends: ArrayIterator
Properties
| Property | Type | Visibility | Description |
|---|---|---|---|
$callback | callable | private | Filter callback applied to each value |
Methods
__construct()
public function __construct( iterable $data, callable $callback )| Parameter | Type | Description |
|---|---|---|
$data | iterable | Array or traversable to iterate |
$callback | callable | Filter function applied to each value via current() |
Throws: InvalidArgument when $data is not iterable.
The callback is only stored if is_callable() returns true.
current()
public function current(): stringReturns parent::current() passed through the callback (if callable).
__unserialize()
public function __unserialize( array $data ): voidEmpty implementation — prevents unserialization for security.
__wakeup()
public function __wakeup(): voidUnsets the callback to prevent injection during unserialization.
unserialize()
public function unserialize( string $data ): voidEmpty implementation — prevents creating an object from serialized data.
WpOrgRequestsUtilityInputValidator
Static input validation utilities used throughout the library.
Namespace: WpOrgRequestsUtility
Package: RequestsUtilities
Modifier: final
Methods
is_string_or_stringable()
public static function is_string_or_stringable( mixed $input ): boolReturns true if $input is a string or an object with __toString().
is_numeric_array_key()
public static function is_numeric_array_key( mixed $input ): boolReturns true if $input is an int, or a string matching /^-?[0-9]+$/.
is_stringable_object()
public static function is_stringable_object( mixed $input ): boolReturns true if $input is an object with a __toString() method.
has_array_access()
public static function has_array_access( mixed $input ): boolReturns true if $input is an array or implements ArrayAccess.
is_iterable()
public static function is_iterable( mixed $input ): boolReturns true if $input is an array or implements Traversable. Exists for PHP 5.6 compatibility (native is_iterable() was added in PHP 7.1).
is_curl_handle()
public static function is_curl_handle( mixed $input ): boolReturns true if $input is a cURL resource (pre-PHP 8.0) or a CurlHandle instance (PHP 8.0+).