Skip to content
Snippets Groups Projects
Commit b8d0636b authored by Tim Rohaly's avatar Tim Rohaly
Browse files

Issue #3477441 by tr: Parameter typing in PlaceholderResolver service

parent 725f280f
No related branches found
No related tags found
1 merge request!35Issue #3477441 by tr: Parameter typing in PlaceholderResolver service
Pipeline #294887 passed
<?php <?php
declare(strict_types=1);
namespace Drupal\typed_data; namespace Drupal\typed_data;
use Drupal\Component\Render\HtmlEscapedText; use Drupal\Component\Render\HtmlEscapedText;
...@@ -45,7 +47,7 @@ class PlaceholderResolver implements PlaceholderResolverInterface { ...@@ -45,7 +47,7 @@ class PlaceholderResolver implements PlaceholderResolverInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function resolvePlaceholders(string $text, array $data = [], BubbleableMetadata $bubbleable_metadata = NULL, array $options = []): array { public function resolvePlaceholders(string $text, array $data = [], ?BubbleableMetadata $bubbleable_metadata = NULL, array $options = []): array {
$options += [ $options += [
'langcode' => NULL, 'langcode' => NULL,
'clear' => FALSE, 'clear' => FALSE,
...@@ -163,7 +165,7 @@ class PlaceholderResolver implements PlaceholderResolverInterface { ...@@ -163,7 +165,7 @@ class PlaceholderResolver implements PlaceholderResolverInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function replacePlaceHolders(string $text, array $data = [], BubbleableMetadata $bubbleable_metadata = NULL, array $options = []): string { public function replacePlaceHolders(string $text, array $data = [], ?BubbleableMetadata $bubbleable_metadata = NULL, array $options = []): string {
$replacements = $this->resolvePlaceholders($text, $data, $bubbleable_metadata, $options); $replacements = $this->resolvePlaceholders($text, $data, $bubbleable_metadata, $options);
$placeholders = array_keys($replacements); $placeholders = array_keys($replacements);
......
...@@ -45,7 +45,7 @@ interface PlaceholderResolverInterface { ...@@ -45,7 +45,7 @@ interface PlaceholderResolverInterface {
* An array of replacement values for the placeholders contained in the * An array of replacement values for the placeholders contained in the
* text, keyed by placeholder. * text, keyed by placeholder.
*/ */
public function resolvePlaceholders(string $text, array $data = [], BubbleableMetadata $bubbleable_metadata = NULL, array $options = []): array; public function resolvePlaceholders(string $text, array $data = [], ?BubbleableMetadata $bubbleable_metadata = NULL, array $options = []): array;
/** /**
* Replaces the placeholders in the given text. * Replaces the placeholders in the given text.
...@@ -87,7 +87,7 @@ interface PlaceholderResolverInterface { ...@@ -87,7 +87,7 @@ interface PlaceholderResolverInterface {
* otherwise for example the result can be put into #markup, in which case * otherwise for example the result can be put into #markup, in which case
* it would be sanitized by Xss::filterAdmin(). * it would be sanitized by Xss::filterAdmin().
*/ */
public function replacePlaceHolders(string $text, array $data = [], BubbleableMetadata $bubbleable_metadata = NULL, array $options = []): string; public function replacePlaceHolders(string $text, array $data = [], ?BubbleableMetadata $bubbleable_metadata = NULL, array $options = []): string;
/** /**
* Builds a list of all placeholder tokens that appear in the text. * Builds a list of all placeholder tokens that appear in the text.
......
<?php <?php
declare(strict_types=1);
namespace Drupal\typed_data; namespace Drupal\typed_data;
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment