FieldPath::create() #20

Closed
opened 2026-08-20 19:48:29 +02:00 by c.fahner · 1 comment
Owner

Currently FieldPath's can only be created through the constructor. However, some API's require methods for converting string's directly into single-element field paths (from array keys for example), but still may want to allow multi-element paths.

To prevent this conversion being recreated everywhere, a static FieldPath::create(non-empty-list<non-empty-string>|non-empty-string) method should be added.

Currently `FieldPath`'s can only be created through the constructor. However, some API's require methods for converting `string`'s directly into single-element field paths (from array keys for example), but still may want to allow multi-element paths. To prevent this conversion being recreated everywhere, a static `FieldPath::create(non-empty-list<non-empty-string>|non-empty-string)` method should be added.
c.fahner added this to the v0.1 milestone 2026-08-20 19:48:29 +02:00
Author
Owner

Doesn't really make sense, even in the array case it is easy to wrap the field in [] and just use the constructor. Most field names are already (should be) declared literally.

The only class that does this is the DocumentShape utility. To prevent unnecessary branching it might even be preferred to also force the array syntax here.

Doesn't really make sense, even in the array case it is easy to wrap the field in `[]` and just use the constructor. Most field names are already (should be) declared literally. The only class that does this is the `DocumentShape` utility. To prevent unnecessary branching it might even be preferred to also force the array syntax here.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
slendium/ocd#20
No description provided.