Reviewed & tested by the community
Project:
Drupal core
Version:
main
Component:
typed data system
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Nov 2026 at 00:33 UTC
Updated:
21 Nov 2026 at 21:17 UTC
Jump to comment: Most recent
Comments
Comment #3
dries commentedThe MR adds
intto the seven types and removes both baseline entries from.phpstan-baseline.php.Comment #4
smustgrave commentedQuestion on
core/lib/Drupal/Core/TypedData/TypedData.phpwould an int in$nameforgetPropertyPathbe a delta?Comment #5
dries commented@smustgrave Yes. When the data is an item of a list, its
$nameis the item's delta, which is an integer.This is documented in lines 107 to 115 of TypedDataInterface.php: "If the data is an item of a list, the name is the numeric position of the item in the list, starting with 0."
The MR brings the other docblocks in line with that one.
Comment #6
smustgrave commentedI see thanks for clarifying!
Comment #7
dries commentedThanks for the review and RTBC.
To be honest, this part of the typed data API feels a bit off to me.
Today, every piece of typed data carries a
$namethat basically means different things depending on what holds the item. In a map it's a property name, a string. In a list it's a position, an int. Hence why the type has to bestring|int. And anything that uses$namehas to know which case it's in. I ran into this when working on #3627328: ListNormalizer does not provide a JSON Schema for lists, which let me to open this issue.This design comes with some strange workarounds or overhead. For example, when an item is removed from a list, every item after it has to move up one place.
ItemList::rekey()exists to "repair" the list afterremoveItem(). See lines 158-166 of ItemList.php.setContext()in that snippet updates$name.I feel a better and more standard approach would be to let the container own the keys. A map should know the names of its properties, and a list should know the position of each of its items. Then a map would return a string and a list an integer, each with a single type, and removing an item from a list would not require re-numbering.
Needless to say, that is beyond the scope of this issue. :-) I'm guessing, but it's probably not that hard to change technically. The hardest part would be managing the BC, but it might still be doable. If people think it's worth it, we could give it a shot.
Until then, this MR corrects the docblocks.
Comment #8
smustgrave commentedI’m the worst judge but maybe something to aim for before 13?