Allow passing MarkupInterface to AssertContentTrait::setRawContent

Created on 4 September 2024, 4 months ago
Updated 10 September 2024, 3 months ago

Problem/Motivation

The typehint in the docblock for \Drupal\KernelTests\AssertContentTrait::setRawContent says you should pass a string, but there are at least 57 instances in core that pass a \Drupal\Component\Render\MarkupInterface. Usually this comes from either RendererInterface::renderRoot or RendererInterface::renderInIsolation. For convenience sake we should update the typehint to allow this, rather than forcing callers to cast to string.

Steps to reproduce

Add to phpstan.neon.dist:

parameters:
  checkFunctionArgumentTypes: true

Run phpstan

Grep output for something like this:
grep "MarkupInterface given" output.txt | grep setRawContent

Proposed resolution

Update typehint of \Drupal\KernelTests\AssertContentTrait::setRawContent to one of the following:

  • @param string|\Stringable $content
  • @param string|\Drupal\Component\Render\MarkupInterface $content

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

RTBC

Version

11.0 🔥

Component
PHPUnit 

Last updated about 12 hours ago

Created by

🇦🇺Australia mstrelan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024