Documentation

NamedParameterMap extends AbstractMap
in package
Uses TypeTrait, ValueToStringTrait

`NamedParameterMap` represents a mapping of values to a set of named keys that may optionally be typed

Tags
extends

AbstractMap

Table of Contents

$data  : array<array-key, T>
The items of this array.
$namedParameters  : array<string, string>
Named parameters defined for this map.
__construct()  : mixed
Constructs a new `NamedParameterMap`.
__serialize()  : array<array-key, T>
Returns data suitable for PHP serialization.
__unserialize()  : void
Adds unserialized data to the object.
clear()  : void
Removes all items from this array.
containsKey()  : bool
Returns `true` if this map contains a mapping for the specified key.
containsValue()  : bool
Returns `true` if this map maps one or more keys to the specified value.
count()  : int
Returns the number of items in this array.
get()  : T|null
Returns the value to which the specified key is mapped, `null` if this map contains no mapping for the key, or (optionally) `$defaultValue` if this map contains no mapping for the key.
getIterator()  : Traversable<array-key, T>
Returns an iterator for this array.
getNamedParameters()  : array<string, string>
Returns named parameters set for this `NamedParameterMap`.
isEmpty()  : bool
Returns `true` if this array is empty.
keys()  : array<int, array-key>
Return an array of the keys contained in this map.
offsetExists()  : bool
Returns `true` if the given offset exists in this array.
offsetGet()  : T|null
Returns the value at the specified offset.
offsetSet()  : void
Sets the given value to the given offset in the array.
offsetUnset()  : void
Removes the given offset and its value from the array.
put()  : T|null
Associates the specified value with the specified key in this map.
putIfAbsent()  : T|null
Associates the specified value with the specified key in this map only if it is not already set.
remove()  : T|null
Removes the mapping for a key from this map if it is present.
removeIf()  : bool
Removes the entry for the specified key only if it is currently mapped to the specified value.
replace()  : T|null
Replaces the entry for the specified key only if it is currently mapped to some value.
replaceIf()  : bool
Replaces the entry for the specified key only if currently mapped to the specified value.
serialize()  : string
Returns a serialized string representation of this array object.
toArray()  : array<array-key, T>
Returns a native PHP array representation of this array object.
unserialize()  : void
Converts a serialized string representation into an instance object.
checkType()  : bool
Returns `true` if value is of the specified type.
filterNamedParameters()  : array<string, string>
Given an array of named parameters, constructs a proper mapping of named parameters to types.
toolValueToString()  : string
Returns a string representation of the value.

Properties

$data

The items of this array.

protected array<array-key, T> $data = []

$namedParameters

Named parameters defined for this map.

protected array<string, string> $namedParameters

Methods

__construct()

Constructs a new `NamedParameterMap`.

public __construct(array<array-key, string> $namedParameters[, array<array-key, mixed> $data = [] ]) : mixed
Parameters
$namedParameters : array<array-key, string>

The named parameters defined for this map.

$data : array<array-key, mixed> = []

An initial set of data to set on this map.

Return values
mixed

__unserialize()

Adds unserialized data to the object.

public __unserialize(array<array-key, T$data) : void
Parameters
$data : array<array-key, T>
Return values
void

clear()

Removes all items from this array.

public clear() : void
Return values
void

containsKey()

Returns `true` if this map contains a mapping for the specified key.

public containsKey(mixed $key) : bool
Parameters
$key : mixed

The key to check in the map.

Tags
inheritDoc
Return values
bool

containsValue()

Returns `true` if this map maps one or more keys to the specified value.

public containsValue(mixed $value) : bool
Parameters
$value : mixed

The value to check in the map.

Tags
inheritDoc
Return values
bool

get()

Returns the value to which the specified key is mapped, `null` if this map contains no mapping for the key, or (optionally) `$defaultValue` if this map contains no mapping for the key.

public get(mixed $key[, mixed $defaultValue = null ]) : T|null
Parameters
$key : mixed

The key to return from the map.

$defaultValue : mixed = null

The default value to use if $key is not found.

Tags
inheritDoc
Return values
T|null

the value or null if the key could not be found.

getNamedParameters()

Returns named parameters set for this `NamedParameterMap`.

public getNamedParameters() : array<string, string>
Return values
array<string, string>

isEmpty()

Returns `true` if this array is empty.

public isEmpty() : bool
Return values
bool

keys()

Return an array of the keys contained in this map.

public keys() : array<int, array-key>
Tags
inheritDoc
Return values
array<int, array-key>

offsetExists()

Returns `true` if the given offset exists in this array.

public offsetExists(string|int $offset) : bool
Parameters
$offset : string|int

The offset to check.

Tags
link

ArrayAccess::offsetExists()

Return values
bool

offsetGet()

Returns the value at the specified offset.

public offsetGet(string|int $offset) : T|null
Parameters
$offset : string|int

The offset for which a value should be returned.

Tags
link

ArrayAccess::offsetGet()

psalm-suppress

InvalidAttribute

Return values
T|null

the value stored at the offset, or null if the offset does not exist.

offsetSet()

Sets the given value to the given offset in the array.

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed

The offset to set. If null, the value may be set at a numerically-indexed offset.

$value : mixed

The value to set at the given offset.

Tags
inheritDoc
Return values
void

offsetUnset()

Removes the given offset and its value from the array.

public offsetUnset(string|int $offset) : void
Parameters
$offset : string|int

The offset to remove from the array.

Tags
link

ArrayAccess::offsetUnset()

Return values
void

put()

Associates the specified value with the specified key in this map.

public put(mixed $key, mixed $value) : T|null
Parameters
$key : mixed

The key to put or replace in the map.

$value : mixed

The value to store at $key.

Tags
inheritDoc
Return values
T|null

the previous value associated with key, or null if there was no mapping for $key.

putIfAbsent()

Associates the specified value with the specified key in this map only if it is not already set.

public putIfAbsent(mixed $key, mixed $value) : T|null
Parameters
$key : mixed

The key to put in the map.

$value : mixed

The value to store at $key.

Tags
inheritDoc
Return values
T|null

the previous value associated with key, or null if there was no mapping for $key.

remove()

Removes the mapping for a key from this map if it is present.

public remove(mixed $key) : T|null
Parameters
$key : mixed

The key to remove from the map.

Tags
inheritDoc
Return values
T|null

the previous value associated with key, or null if there was no mapping for $key.

removeIf()

Removes the entry for the specified key only if it is currently mapped to the specified value.

public removeIf(mixed $key, mixed $value) : bool
Parameters
$key : mixed

The key to remove from the map.

$value : mixed

The value to match.

Tags
inheritDoc
Return values
bool

true if the value was removed.

replace()

Replaces the entry for the specified key only if it is currently mapped to some value.

public replace(mixed $key, mixed $value) : T|null
Parameters
$key : mixed

The key to replace.

$value : mixed

The value to set at $key.

Tags
inheritDoc
Return values
T|null

the previous value associated with key, or null if there was no mapping for $key.

replaceIf()

Replaces the entry for the specified key only if currently mapped to the specified value.

public replaceIf(mixed $key, mixed $oldValue, mixed $newValue) : bool
Parameters
$key : mixed

The key to remove from the map.

$oldValue : mixed

The value to match.

$newValue : mixed

The value to use as a replacement.

Tags
inheritDoc
Return values
bool

true if the value was replaced.

serialize()

Returns a serialized string representation of this array object.

public serialize() : string
Tags
deprecated

The Serializable interface will go away in PHP 9.

link

Serializable::serialize()

Return values
string

a PHP serialized string.

toArray()

Returns a native PHP array representation of this array object.

public toArray() : array<array-key, T>
Tags
inheritDoc
Return values
array<array-key, T>

unserialize()

Converts a serialized string representation into an instance object.

public unserialize(string $serialized) : void
Parameters
$serialized : string

A PHP serialized string to unserialize.

Tags
deprecated

The Serializable interface will go away in PHP 9.

link

Serializable::unserialize()

phpcsSuppress

SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint

Return values
void

checkType()

Returns `true` if value is of the specified type.

protected checkType(string $type, mixed $value) : bool
Parameters
$type : string

The type to check the value against.

$value : mixed

The value to check.

Return values
bool

filterNamedParameters()

Given an array of named parameters, constructs a proper mapping of named parameters to types.

protected filterNamedParameters(array<array-key, string> $namedParameters) : array<string, string>
Parameters
$namedParameters : array<array-key, string>

The named parameters to filter.

Return values
array<string, string>

toolValueToString()

Returns a string representation of the value.

protected toolValueToString(mixed $value) : string
  • null value: 'NULL'
  • boolean: 'TRUE', 'FALSE'
  • array: 'Array'
  • scalar: converted-value
  • resource: '(type resource #number)'
  • object with __toString(): result of __toString()
  • object DateTime: ISO 8601 date
  • object: '(className Object)'
  • anonymous function: same as object
Parameters
$value : mixed

the value to return as a string.

Return values
string

Search results