‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Type\Map Class Reference
Inheritance diagram for TYPO3\CMS\Core\Type\Map:

Public Member Functions

 __construct ()
 
 key ()
 
 current ()
 
 next ()
 
 rewind ()
 
 valid ()
 
 offsetExists (mixed $offset)
 
 offsetGet (mixed $offset)
 
 offsetSet (mixed $offset, mixed $value)
 
 offsetUnset (mixed $offset)
 
 count ()
 

Static Public Member Functions

static fromEntries (array ... $entries)
 

Private Attributes

SplObjectStorage $storage
 

Detailed Description

Map implementation that supports objects as keys.

PHP's \WeakMap is not an option in case object keys are created and assigned in an encapsulated scope (like passing a map to a function to enrich it). In case the original object is not referenced anymore, it also will vanish from a \WeakMap, when used as key (see https://www.php.net/manual/class.weakmap.php).

PHP's \SplObjectStorage has a strange behavior when using an iteration like foreach ($map as $key => $value) - the $value is actually the $key for BC reasons (see https://bugs.php.net/bug.php?id=49967).

This individual implementation works around the "weak" behavior of \WeakMap and the iteration issue with foreach of \SplObjectStorage by acting as a wrapper for \SplObjectStorage with reduced features.

Example:

$map = new \TYPO3\CMS\Core\Type\Map();
$key = new \stdClass();
$value = new \stdClass();
$map[$key] = $value;
foreach ($map as $key => $value) { ... }

Definition at line 46 of file Map.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Type\Map::__construct ( )

Definition at line 63 of file Map.php.

Member Function Documentation

◆ count()

TYPO3\CMS\Core\Type\Map::count ( )

Definition at line 116 of file Map.php.

◆ current()

TYPO3\CMS\Core\Type\Map::current ( )

Definition at line 73 of file Map.php.

◆ fromEntries()

static TYPO3\CMS\Core\Type\Map::fromEntries ( array ...  $entries)
static

@template E array{0:mixed, 1:mixed}

Parameters
list<E>‪$entries

Definition at line 54 of file Map.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Type\MapTest\mapIsCreatedFromEntries().

◆ key()

TYPO3\CMS\Core\Type\Map::key ( )

Definition at line 68 of file Map.php.

◆ next()

TYPO3\CMS\Core\Type\Map::next ( )

Definition at line 78 of file Map.php.

◆ offsetExists()

TYPO3\CMS\Core\Type\Map::offsetExists ( mixed  $offset)

Definition at line 93 of file Map.php.

Referenced by TYPO3\CMS\Core\Type\Map\offsetGet().

◆ offsetGet()

TYPO3\CMS\Core\Type\Map::offsetGet ( mixed  $offset)

Definition at line 98 of file Map.php.

References TYPO3\CMS\Core\Type\Map\offsetExists().

◆ offsetSet()

TYPO3\CMS\Core\Type\Map::offsetSet ( mixed  $offset,
mixed  $value 
)

Definition at line 106 of file Map.php.

◆ offsetUnset()

TYPO3\CMS\Core\Type\Map::offsetUnset ( mixed  $offset)

Definition at line 111 of file Map.php.

◆ rewind()

TYPO3\CMS\Core\Type\Map::rewind ( )

Definition at line 83 of file Map.php.

◆ valid()

TYPO3\CMS\Core\Type\Map::valid ( )

Definition at line 88 of file Map.php.

Member Data Documentation

◆ $storage

SplObjectStorage TYPO3\CMS\Core\Type\Map::$storage
private

Definition at line 48 of file Map.php.