Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Nov 2017 at 15:06 UTC
Updated:
29 Nov 2018 at 14:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #4
heddnThis is a pretty frequent thing, to return markup. Let's update the docs.
Comment #5
mpp commentedComment #6
mpp commentedComment #7
heddnI don't think they always return TranslatableMarkup. Sometimes it is a string. So we should type hint both in many of these places.
string|\Drupal\Core\StringTranslation\TranslatableMarkup
Comment #8
phenaproxima+1 for what @heddn said. It needs to be "stringable", but not necessarily a primitive string. Kicking this back for that; also tagging as a novice issue since this issue is about copying-and-pasting a single change to many docblocks.
Comment #9
heddnAlso, based on #2990464: Breadcrumb markup should allow some tags such as italics or strong, anything renderable to a string. Which means sometimes render arrays (yikes!) and FormattableMarkup. So, anything castable to a string or renderable. Not sure how we handle these edges cases in a type hint. Or maybe we don't allow for render arrays in the hint so as to more better communicate we'd like to see string|FormattableMarkup... Which BTW, TranslatableMarkup is an implementation of FormattableMarkup, so maybe we want to hint on FormattableMarkup instead?
Comment #10
phenaproximaFormattableMarkup is an instance of MarkupInterface, so we could in theory type hint to that. I have never seen any of those methods return a render array, so I don't think we need to go that far.
string|TranslatableMarkupis probably fine, and would be my preference.Comment #11
hardikpandya commentedComment #12
mpp commentedFrom a theoretical perspective, I'd argue that methods should accept interfaces so it should probably be
MarkupInterfacebutstring|TranslatableMarkupshould be fine.Comment #13
phenaproximaOkay, then I think we're good to go.
Comment #14
catchCommitted 2728cbe and pushed to 8.7.x. Thanks!