Actions
Task #100168
closedIntroduce Map data-structure
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2023-03-14
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Sprint Focus:
Description
Unfortunately PHP emphasizes "weak" over "map" in their new PHP 8
data-structure \WeakMap
. As a result it cannot be passed to other
functions that would enrich an existing \WeakMap
- since objects
created in that function scope would not exist outside and thus
directly trigger garbage collection of \WeakMap
.
As a substitute, \TYPO3\CMS\Core\Type\Map
is introduce with has a
similar behavior and got an additional Map::fromEntries()
factory.
Example:
$map = new \TYPO3\CMS\Core\Type\Map(); $key = new \stdClass(); $value = new \stdClass(); $map[$key] = $value; foreach ($map as $key => $value) { ... }
- example of
\WeakMap
draw-backs: https://3v4l.org/TSO37#v8.1.16 - example of
\SplObjectStorage
draw-backs withforeach
: https://3v4l.org/gloDO#v8.1.16
Actions