The return type for Adjustment::getLabel() is string.
But when generating adjustments in LocalTaxTypeBase::apply() the label is assigned the return value of $zone->getDisplayLabel() which returns t('VAT') or a variation of this: a TranslatableMarkup object.

So is the LocalTaxTypeBase function wrong in setting the label to TranslatableMarkup, or is the Adjustment definition wrong?

Comments

finne created an issue. See original summary.

bojanz’s picture

Title: Adjustment::getLabel wrong return type? » The adjustment label is not guaranteed to be a string

Drupal is kinda liberal with TranslatableMarkup vs string, since TranslatableMarkup is automatically casted to string.

However, Adjustments are serialized into the database, so we definitely want to cast the label explicitly, to avoid storing the entire TranslatableMarkup object.

(We have the same problem in many other places, but it's not as critical since those other objects are not serialized this way)

  • bojanz committed cd76ada on 8.x-2.x
    Issue #2883382 by finne, bojanz: The adjustment label is not guaranteed...
bojanz’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.