diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php
index 29fef78..a4c1e5e 100644
--- a/core/lib/Drupal/Core/Utility/Token.php
+++ b/core/lib/Drupal/Core/Utility/Token.php
@@ -98,11 +98,12 @@ public function __construct(ModuleHandlerInterface $module_handler) {
    *   replacement process. Supported options are:
    *   - langcode: A language code to be used when generating locale-sensitive
    *     tokens.
-   *   - callback: A callback function that will be used to post-process the
-   *     array of token replacements after they are generated. For example, a
-   *     module using tokens in a text-only email might provide a callback to
-   *     strip HTML entities from token values before they are inserted into the
-   *     final text.
+   *   - callback: A callable that will be used to post-process the array of
+   *     token replacements after they are generated. For example, a module
+   *     using tokens in a text-only email might provide a callback to strip
+   *     HTML entities from token values before they are inserted into the
+   *     final text. The callback receives the existing replacements, the data,
+   *     and the options as parameters. It must return an array of replacements.
    *   - clear: A boolean flag indicating that tokens should be removed from the
    *     final text if no replacement value can be generated.
    *   - sanitize: A boolean flag indicating that tokens should be sanitized for
@@ -130,8 +131,8 @@ public function replace($text, array $data = array(), array $options = array())
 
     // Optionally alter the list of replacement values.
     if (!empty($options['callback'])) {
-      $function = $options['callback'];
-      $function($replacements, $data, $options);
+      $callback = $options['callback'];
+      $replacements = call_user_func($callback, $replacements, $data, $options);
     }
 
     $tokens = array_keys($replacements);
