[TASK] Introduce Map data-structure
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`. `\SplObjectStorage` has a strange behavior when using an iteration like `foreach ($map as $key => $value)` - the `$value` is actually the `$key` for BC reasons. As a substitute, `\TYPO3\CMS\Core\Type\Map` is introduced which has a similar behavior and got an additional `Map::fromEntries()` factory. It acts as a wrapper of `\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) { ... } Resolves: #100168 Releases: main Change-Id: I5c26dc4aa9b4679112a27bd4cbebcfbe0899b094 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78127 Tested-by:Benni Mack <benni@typo3.org> Reviewed-by:
Oliver Hader <oliver.hader@typo3.org> Tested-by:
Oliver Hader <oliver.hader@typo3.org> Reviewed-by:
Benni Mack <benni@typo3.org> Tested-by:
core-ci <typo3@b13.com> Tested-by:
Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by:
Andreas Fernandez <a.fernandez@scripting-base.de>
parent
3be034e6
Please register or sign in to comment