diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index d7cc3beb104b07239deab2ece769fca68676cac7..1a75a9a6ac92dcc9d11572ebd1c51f1bd4e03a1f 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -281,9 +281,9 @@ public function getLink($text, $url, $attributes = []) {
    * @return string
    *   The file URL.
    */
-  public function getFileUrl(?string $uri) {
+  public function getFileUrl(?string $uri): string {
     if (is_null($uri)) {
-      return NULL;
+      return '';
     }
     return $this->fileUrlGenerator->generateString($uri);
   }