wppaste
WordPress

CaseInsensitiveDictionary

Source
wp-includes/Requests/src/Utility/CaseInsensitiveDictionary.php:21
Case-insensitive dictionary, suitable for HTTP headers

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 1

$dataarrayprotected
Actual item data

Methods · 7

Source code

class CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate {	/**	 * Actual item data	 *	 * @var array	 */	protected $data = []; 	/**	 * Creates a case insensitive dictionary.	 *	 * @param array $data Dictionary/map to convert to case-insensitive	 */	public function __construct(array $data = []) {		foreach ($data as $offset => $value) {			$this->offsetSet($offset, $value);		}	} 	/**	 * Check if the given item exists	 *	 * @param string $offset Item key	 * @return boolean Does the item exist?	 */	#[ReturnTypeWillChange]	public function offsetExists($offset) {		if (is_string($offset)) {			$offset = strtolower($offset);		} 		if ($offset === null) {			$offset = '';		} 		return isset($this->data[$offset]);	} 	/**	 * Get the value for the item	 *	 * @param string $offset Item key	 * @return string|null Item value (null if the item key doesn't exist)	 */	#[ReturnTypeWillChange]	public function offsetGet($offset) {		if (is_string($offset)) {			$offset = strtolower($offset);		} 		if ($offset === null) {			$offset = '';		} 		if (!isset($this->data[$offset])) {			return null;		} 		return $this->data[$offset];	} 	/**	 * Set the given item	 *	 * @param string $offset Item name	 * @param string $value Item value	 *	 * @throws \WpOrg\Requests\Exception On attempting to use dictionary as list (`invalidset`)	 */	#[ReturnTypeWillChange]	public function offsetSet($offset, $value) {		if ($offset === null) {			throw new Exception('Object is a dictionary, not a list', 'invalidset');		} 		if (is_string($offset)) {			$offset = strtolower($offset);		} 		$this->data[$offset] = $value;

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/Requests/src/Utility/CaseInsensitiveDictionary.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.