Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast to string in strip_tags #780

Draft
wants to merge 4 commits into
base: 7.2.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading