Skip to content

Commit

Permalink
Cast to string in strip_tags
Browse files Browse the repository at this point in the history
* Cast to string in strip_tags

* remove more warnings

---------

Co-authored-by: Christian Fritsch <[email protected]>
  • Loading branch information
dbosen and chrfritsch authored Dec 18, 2024
1 parent 4120888 commit c4744c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions modules/thunder_article/src/Twig/FilterExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getName(): string {
*/
public static function plainText($value): string {
$element = self::render($value);
$element = strip_tags($element);
$element = strip_tags((string) $element);
return html_entity_decode($element, ENT_QUOTES);
}

Expand All @@ -59,7 +59,7 @@ public static function plainText($value): string {
*/
public static function basicFormat($value): string {
$element = self::render($value);
return strip_tags($element, '<a><em><strong><b><i>');
return strip_tags((string) $element, '<a><em><strong><b><i>');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function testSchema(): void {
$query = $this->getQueryFromFile($schema);
$variables = $this->getVariablesFromFile($schema);

$responseData = $this->jsonDecode(strip_tags($this->getResponseData($query, $variables)['jsonld']));
$expectedData = $this->jsonDecode(strip_tags($this->jsonDecode($this->getExpectedResponseFromFile($schema))['data']['jsonld']));
$responseData = $this->jsonDecode(strip_tags((string) $this->getResponseData($query, $variables)['jsonld']));
$expectedData = $this->jsonDecode(strip_tags((string) $this->jsonDecode($this->getExpectedResponseFromFile($schema))['data']['jsonld']));

$this->assertEqualsCanonicalizing($expectedData, $responseData);

Expand Down
14 changes: 7 additions & 7 deletions tests/src/Traits/ThunderTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected function tearDown(): void {
// Output all errors for modules tested.
$errors = [];
foreach ($query->execute()->fetchAll() as $row) {
$errors[] = Unicode::truncate(Html::decodeEntities(strip_tags($controller->formatMessage($row))), 256, TRUE, TRUE);
$errors[] = Unicode::truncate(Html::decodeEntities(strip_tags((string) $controller->formatMessage($row))), 256, TRUE, TRUE);
}
throw new \Exception(print_r($errors, TRUE));
}
Expand All @@ -185,12 +185,12 @@ protected function tearDown(): void {
* @param string $uuid
* The uuid.
*
* @return \Drupal\media\MediaInterface|false|null
* @return \Drupal\media\MediaInterface
* The media entity.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
protected function loadMediaByUuid(string $uuid) {
protected function loadMediaByUuid(string $uuid): MediaInterface {
$media = \Drupal::getContainer()->get('entity.repository')->loadEntityByUuid('media', $uuid);
assert($media instanceof MediaInterface);
return $media;
Expand All @@ -202,12 +202,12 @@ protected function loadMediaByUuid(string $uuid) {
* @param string $uuid
* The uuid.
*
* @return \Drupal\node\NodeInterface|false|null
* @return \Drupal\node\NodeInterface
* The node entity.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
protected function loadNodeByUuid(string $uuid) {
protected function loadNodeByUuid(string $uuid): NodeInterface {
$node = \Drupal::getContainer()->get('entity.repository')->loadEntityByUuid('node', $uuid);
assert($node instanceof NodeInterface);
return $node;
Expand All @@ -219,12 +219,12 @@ protected function loadNodeByUuid(string $uuid) {
* @param string $uuid
* The uuid.
*
* @return \Drupal\taxonomy\TermInterface|false|null
* @return \Drupal\taxonomy\TermInterface
* The term entity.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
protected function loadTermByUuid(string $uuid) {
protected function loadTermByUuid(string $uuid): TermInterface {
$term = \Drupal::getContainer()->get('entity.repository')->loadEntityByUuid('taxonomy_term', $uuid);
assert($term instanceof TermInterface);
return $term;
Expand Down

0 comments on commit c4744c1

Please sign in to comment.