Problem/Motivation

Core is trying to stop using FormattableMarkup (see many other issues in this one's family tree).

AssertContentTrait is full of docblocks that recommend using FormattableMarkup.

Steps to reproduce

View core/tests/Drupal/KernelTests/AssertContentTrait.php

Proposed resolution

Remove usages of FormattableMarkup.

Before

   * @param string $message
   *   (optional) A message to display with the assertion. Do not translate
   *   messages: use \Drupal\Component\Render\FormattableMarkup to embed
   *   variables in the message text, not t(). If left blank, a default message
   *   will be displayed.

After

   *   (optional) A message to display with the assertion. Do not translate
   *   messages with t(). Use double quotes and embed variables directly in
   *   message text, or use sprintf() if necessary. Avoid the use of
   *   \Drupal\Component\Render\FormattableMarkup unless you cast the object to
   *   a string. If left blank, a default message will be displayed.

Remaining tasks

  1. Decide on the exact text.
  2. Search/replace in AssertContentTrait to update everything.
  3. Open an MR and push the commit that makes the changes.
  4. Review / refinement.
  5. RTBC.
  6. Commit.

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#7 tmp.sh_.txt882 bytesquietone

Issue fork drupal-3405364

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dww created an issue. See original summary.

mstrelan’s picture

dww’s picture

Indeed, I'm wondering. Do we want to majorly expand the scope of that to update dozens of docblocks?

mstrelan’s picture

I think you're right. The important thing for enabling strict types is adding the casts, we can improve on docs and allowed types in this issue and / or follow ups.

quietone’s picture

Title: Fix AssertContentTrait to stop recommending FormattableMarkup » Fix usages of AssertContentTrait and stop recommending FormattableMarkup
Issue summary: View changes

quietone’s picture

Status: Active » Needs review
StatusFileSize
new882 bytes

I think the new text is fine. I used this script to change the instances in the issue summary.

quietone’s picture

Title: Fix usages of AssertContentTrait and stop recommending FormattableMarkup » Update docs to stop recommending FormattableMarkup
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Applied MR and searched for "use \Drupal\Component\Render\FormattableMarkup to embed" and all instances in core has been replaced.

Replacement also reads well.

nod_’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 19b213dbef to 11.x and 0a510d5c05 to 11.0.x and ca5b45e08a to 10.4.x and c3fe5c10d9 to 10.3.x. Thanks!

  • nod_ committed c3fe5c10 on 10.3.x
    Issue #3405364 by quietone, dww, mstrelan, smustgrave: Update docs to...

  • nod_ committed ca5b45e0 on 10.4.x
    Issue #3405364 by quietone, dww, mstrelan, smustgrave: Update docs to...

  • nod_ committed 0a510d5c on 11.0.x
    Issue #3405364 by quietone, dww, mstrelan, smustgrave: Update docs to...

  • nod_ committed 19b213db on 11.x
    Issue #3405364 by quietone, dww, mstrelan, smustgrave: Update docs to...
nod_’s picture

Status: Fixed » Closed (fixed)

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