Loading core/.phpstan-baseline.php +0 −30 Original line number Diff line number Diff line Loading @@ -14341,12 +14341,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/config/src/Form/ConfigSync.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\config\\\\Hook\\\\ConfigHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/config/src/Hook/ConfigHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\config\\\\Hook\\\\ConfigHooks\\:\\:help\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', Loading Loading @@ -17365,12 +17359,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/editor/src/Hook/EditorHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\editor\\\\Hook\\\\EditorHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/editor/src/Hook/EditorHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\editor\\\\Hook\\\\EditorHooks\\:\\:filterFormatPresave\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', Loading Loading @@ -19381,12 +19369,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\file_test\\\\Hook\\\\FileTestHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/file/tests/file_test/src/Hook/FileTestHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\file_test\\\\Hook\\\\FileTestHooks\\:\\:fileInsert\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', Loading Loading @@ -20761,12 +20743,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/image/src/Hook/ImageHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\image\\\\Hook\\\\ImageHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/image/src/Hook/ImageHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\image\\\\Hook\\\\ImageHooks\\:\\:filePredelete\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', Loading Loading @@ -34111,12 +34087,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/src/Form/ThemeSettingsForm.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\system\\\\Hook\\\\SystemHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/system/src/Hook/SystemHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\system\\\\Hook\\\\SystemHooks\\:\\:help\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', core/lib/Drupal/Core/File/file.api.php +3 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ * @param string $uri * The URI of the file. * * @return string[]|int * @return string[]|int|null * If the user does not have permission to access the file, return -1. If the * user has permission, return an array with the appropriate headers. If the * file is not controlled by the current module, the return value should be Loading @@ -31,7 +31,7 @@ * * @see \Drupal\system\FileDownloadController::download() */ function hook_file_download($uri) { function hook_file_download($uri): array|int|null { // Check to see if this is a config download. $scheme = StreamWrapperManager::getScheme($uri); $target = StreamWrapperManager::getTarget($uri); Loading @@ -40,6 +40,7 @@ function hook_file_download($uri) { 'Content-disposition' => 'attachment; filename="config.tar.gz"', ]; } return NULL; } /** Loading core/modules/config/src/Hook/ConfigHooks.php +2 −1 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ public function help($route_name, RouteMatchInterface $route_match) { * Implements hook_file_download(). */ #[Hook('file_download')] public function fileDownload($uri) { public function fileDownload($uri): array|int|null { $scheme = StreamWrapperManager::getScheme($uri); $target = StreamWrapperManager::getTarget($uri); if ($scheme == 'temporary' && $target == 'config.tar.gz') { Loading @@ -87,6 +87,7 @@ public function fileDownload($uri) { } return -1; } return NULL; } } core/modules/editor/src/Hook/EditorHooks.php +3 −3 Original line number Diff line number Diff line Loading @@ -268,13 +268,13 @@ public function entityRevisionDelete(EntityInterface $entity) { * @see file_get_file_references() */ #[Hook('file_download')] public function fileDownload($uri) { public function fileDownload($uri): array|int|null { // Get the file record based on the URI. If not in the database just return. /** @var \Drupal\file\FileRepositoryInterface $file_repository */ $file_repository = \Drupal::service('file.repository'); $file = $file_repository->loadByUri($uri); if (!$file) { return; return NULL; } // Temporary files are handled by file_file_download(), so nothing to do here // about them. Loading @@ -287,7 +287,7 @@ public function fileDownload($uri) { // an image preview on a node creation form) in which case, allow download by // the file's owner. if (empty($usage_list['editor']) && ($file->isPermanent() || $file->getOwnerId() != \Drupal::currentUser()->id())) { return; return NULL; } // Editor.module MUST NOT call $file->access() here (like file_file_download() // does) as checking the 'download' access to a file entity would end up in Loading core/modules/file/tests/file_test/src/FileTestHelper.php +1 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public static function logCall($op, $args): void { * * @param string $op * One of the hook_file_[validate,download] operations. * @param mixed $value * @param array|int $value * Value for the hook to return. * * @see Drupal\file_test\FileTestHelper::getReturn() Loading Loading
core/.phpstan-baseline.php +0 −30 Original line number Diff line number Diff line Loading @@ -14341,12 +14341,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/config/src/Form/ConfigSync.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\config\\\\Hook\\\\ConfigHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/config/src/Hook/ConfigHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\config\\\\Hook\\\\ConfigHooks\\:\\:help\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', Loading Loading @@ -17365,12 +17359,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/editor/src/Hook/EditorHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\editor\\\\Hook\\\\EditorHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/editor/src/Hook/EditorHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\editor\\\\Hook\\\\EditorHooks\\:\\:filterFormatPresave\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', Loading Loading @@ -19381,12 +19369,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\file_test\\\\Hook\\\\FileTestHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/file/tests/file_test/src/Hook/FileTestHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\file_test\\\\Hook\\\\FileTestHooks\\:\\:fileInsert\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', Loading Loading @@ -20761,12 +20743,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/image/src/Hook/ImageHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\image\\\\Hook\\\\ImageHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/image/src/Hook/ImageHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\image\\\\Hook\\\\ImageHooks\\:\\:filePredelete\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', Loading Loading @@ -34111,12 +34087,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/src/Form/ThemeSettingsForm.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\system\\\\Hook\\\\SystemHooks\\:\\:fileDownload\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/system/src/Hook/SystemHooks.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\system\\\\Hook\\\\SystemHooks\\:\\:help\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return',
core/lib/Drupal/Core/File/file.api.php +3 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ * @param string $uri * The URI of the file. * * @return string[]|int * @return string[]|int|null * If the user does not have permission to access the file, return -1. If the * user has permission, return an array with the appropriate headers. If the * file is not controlled by the current module, the return value should be Loading @@ -31,7 +31,7 @@ * * @see \Drupal\system\FileDownloadController::download() */ function hook_file_download($uri) { function hook_file_download($uri): array|int|null { // Check to see if this is a config download. $scheme = StreamWrapperManager::getScheme($uri); $target = StreamWrapperManager::getTarget($uri); Loading @@ -40,6 +40,7 @@ function hook_file_download($uri) { 'Content-disposition' => 'attachment; filename="config.tar.gz"', ]; } return NULL; } /** Loading
core/modules/config/src/Hook/ConfigHooks.php +2 −1 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ public function help($route_name, RouteMatchInterface $route_match) { * Implements hook_file_download(). */ #[Hook('file_download')] public function fileDownload($uri) { public function fileDownload($uri): array|int|null { $scheme = StreamWrapperManager::getScheme($uri); $target = StreamWrapperManager::getTarget($uri); if ($scheme == 'temporary' && $target == 'config.tar.gz') { Loading @@ -87,6 +87,7 @@ public function fileDownload($uri) { } return -1; } return NULL; } }
core/modules/editor/src/Hook/EditorHooks.php +3 −3 Original line number Diff line number Diff line Loading @@ -268,13 +268,13 @@ public function entityRevisionDelete(EntityInterface $entity) { * @see file_get_file_references() */ #[Hook('file_download')] public function fileDownload($uri) { public function fileDownload($uri): array|int|null { // Get the file record based on the URI. If not in the database just return. /** @var \Drupal\file\FileRepositoryInterface $file_repository */ $file_repository = \Drupal::service('file.repository'); $file = $file_repository->loadByUri($uri); if (!$file) { return; return NULL; } // Temporary files are handled by file_file_download(), so nothing to do here // about them. Loading @@ -287,7 +287,7 @@ public function fileDownload($uri) { // an image preview on a node creation form) in which case, allow download by // the file's owner. if (empty($usage_list['editor']) && ($file->isPermanent() || $file->getOwnerId() != \Drupal::currentUser()->id())) { return; return NULL; } // Editor.module MUST NOT call $file->access() here (like file_file_download() // does) as checking the 'download' access to a file entity would end up in Loading
core/modules/file/tests/file_test/src/FileTestHelper.php +1 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public static function logCall($op, $args): void { * * @param string $op * One of the hook_file_[validate,download] operations. * @param mixed $value * @param array|int $value * Value for the hook to return. * * @see Drupal\file_test\FileTestHelper::getReturn() Loading