diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index 67ce5d8aef96830834fc5fe0c579020f4c040d82..22e55447a3c2f5e7b1b4bfe88ab874b6d7e1f3a0 100644 --- a/core/modules/locale/locale.batch.inc +++ b/core/modules/locale/locale.batch.inc @@ -25,7 +25,7 @@ * @param string $langcode * Language code of the language for which to check the translation. * @param array $options - * Optional, an array with options that can have the following elements: + * An array with options that can have the following elements: * - 'finish_feedback': Whether or not to give feedback to the user when the * batch is finished. Optional, defaults to TRUE. * - 'use_remote': Whether or not to check the remote translation file. @@ -33,7 +33,7 @@ * @param array $context * The batch context. */ -function locale_translation_batch_status_check($project, $langcode, $options = array(), &$context) { +function locale_translation_batch_status_check($project, $langcode, array $options, array &$context) { $failure = $checked = FALSE; $options += array( 'finish_feedback' => TRUE, diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 83cd4254fea93e6a2341cdb31c784d87f76f6da1..991a89ce41d44f4e0e2327f1b0b3e4d50180de08 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -24,15 +24,18 @@ * LOCALE_NOT_CUSTOMIZED. * - 'finish_feedback': Whether or not to give feedback to the user when the * batch is finished. Optional, defaults to TRUE. - * @param $force + * @param bool $force * (optional) Import all available files, even if they were imported before. * + * @return array|bool + * The batch structure, or FALSE if no files are used to build the batch. + * * @todo * Integrate with update status to identify projects needed and integrate * l10n_update functionality to feed in translation files alike. * See http://drupal.org/node/1191488. */ -function locale_translate_batch_import_files($options, $force = FALSE) { +function locale_translate_batch_import_files(array $options, $force = FALSE) { $options += array( 'overwrite_options' => array(), 'customized' => LOCALE_NOT_CUSTOMIZED, @@ -71,16 +74,16 @@ function locale_translate_batch_import_files($options, $force = FALSE) { * Get interface translation files present in the translations directory. * * @param array $projects - * Project names from which to get the translation files and history. - * Defaults to all projects. + * (optional) Project names from which to get the translation files and + * history. Defaults to all projects. * @param array $langcodes - * Language codes from which to get the translation files and history. - * Defaults to all languages. + * (optional) Language codes from which to get the translation files and + * history. Defaults to all languages. * * @return array * An array of interface translation files keyed by their URI. */ -function locale_translate_get_interface_translation_files($projects = array(), $langcodes = array()) { +function locale_translate_get_interface_translation_files(array $projects = array(), array $langcodes = array()) { module_load_include('compare.inc', 'locale'); $files = array(); $projects = $projects ? $projects : array_keys(locale_translation_get_projects()); @@ -109,7 +112,7 @@ function locale_translate_get_interface_translation_files($projects = array(), $ /** * Build a locale batch from an array of files. * - * @param $files + * @param array $files * Array of file objects to import. * @param array $options * An array with options that can have the following elements: @@ -124,10 +127,10 @@ function locale_translate_get_interface_translation_files($projects = array(), $ * - 'finish_feedback': Whether or not to give feedback to the user when the * batch is finished. Optional, defaults to TRUE. * - * @return + * @return array|bool * A batch structure or FALSE if $files was empty. */ -function locale_translate_batch_build($files, $options) { +function locale_translate_batch_build(array $files, array $options) { $options += array( 'overwrite_options' => array(), 'customized' => LOCALE_NOT_CUSTOMIZED, @@ -179,10 +182,10 @@ function locale_translate_batch_build($files, $options) { * LOCALE_NOT_CUSTOMIZED. * - 'message': Alternative message to display during import. Note, this must * be sanitized text. - * @param $context + * @param array $context * Contains a list of files imported. */ -function locale_translate_batch_import($file, $options, &$context) { +function locale_translate_batch_import($file, array $options, array &$context) { // Merge the default values in the $options array. $options += array( 'overwrite_options' => array(), @@ -260,10 +263,10 @@ function locale_translate_batch_import($file, $options, &$context) { /** * Batch callback: Save data of imported files. * - * @param $context + * @param array $context * Contains a list of imported files. */ -function locale_translate_batch_import_save($context) { +function locale_translate_batch_import_save(array $context) { if (isset($context['results']['files'])) { foreach ($context['results']['files'] as $file) { // Update the file history if both project and version are known. This @@ -343,8 +346,13 @@ function locale_translate_batch_refresh(array &$context) { /** * Finished callback of system page locale import batch. + * + * @param bool $success + * TRUE if batch successfully completed. + * @param array $results + * Batch results. */ -function locale_translate_batch_finished($success, $results) { +function locale_translate_batch_finished($success, array $results) { $logger = \Drupal::logger('locale'); if ($success) { $additions = $updates = $deletes = $skips = $config = 0; @@ -400,10 +408,10 @@ function locale_translate_batch_finished($success, $results) { /** * Creates a file object and populates the timestamp property. * - * @param $filepath + * @param string $filepath * The filepath of a file to import. * - * @return + * @return object * An object representing the file. */ function locale_translate_file_create($filepath) { @@ -431,7 +439,7 @@ function locale_translate_file_create($filepath) { * @return object * Modified file object. */ -function locale_translate_file_attach_properties($file, $options = array()) { +function locale_translate_file_attach_properties($file, array $options = array()) { // If $file is a file entity, convert it to a stdClass. if ($file instanceof FileInterface) { $file = (object) array( @@ -472,17 +480,17 @@ function locale_translate_file_attach_properties($file, $options = array()) { * Deletes interface translation files and translation history records. * * @param array $projects - * Project names from which to delete the translation files and history. - * Defaults to all projects. + * (optional) Project names from which to delete the translation files and + * history. Defaults to all projects. * @param array $langcodes - * Language codes from which to delete the translation files and history. - * Defaults to all languages. + * (optional) Language codes from which to delete the translation files and + * history. Defaults to all languages. * * @return bool * TRUE if files are removed successfully. FALSE if one or more files could * not be deleted. */ -function locale_translate_delete_translation_files($projects = array(), $langcodes = array()) { +function locale_translate_delete_translation_files(array $projects = array(), array $langcodes = array()) { $fail = FALSE; locale_translation_file_history_delete($projects, $langcodes); @@ -514,7 +522,7 @@ function locale_translate_delete_translation_files($projects = array(), $langcod * @return array * The batch definition. */ -function locale_config_batch_update_components(array $options, $langcodes = array(), $components = array()) { +function locale_config_batch_update_components(array $options, array $langcodes = array(), array $components = array()) { $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list()); if ($langcodes && $names = \Drupal\locale\Locale::config()->getComponentNames($components)) { return locale_config_batch_build($names, $langcodes, $options); @@ -538,7 +546,7 @@ function locale_config_batch_update_components(array $options, $langcodes = arra * * @see locale_config_batch_refresh_name() */ -function locale_config_batch_build(array $names, array $langcodes, $options = array()) { +function locale_config_batch_build(array $names, array $langcodes, array $options = array()) { $options += array('finish_feedback' => TRUE); $i = 0; $batch_names = array(); @@ -574,8 +582,8 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar /** * Performs configuration translation refresh as a batch step. * - * @param string $names - * Name of configuration object to update. + * @param array $names + * An array of names of configuration objects to update. * @param array $langcodes * (optional) Array of language codes to update. Defaults to all languages. * @param array $context @@ -630,7 +638,7 @@ function locale_config_batch_finished($success, array $results) { * @return int * Number of configuration objects retranslated. */ -function locale_config_update_multiple(array $names, $langcodes = array()) { +function locale_config_update_multiple(array $names, array $langcodes = array()) { $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list()); $count = 0; foreach ($names as $name) { diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 3ff2a15bf86c81cc13842a9c3dd589fbcc24d3e2..7a3ee6acdf16e49d1f7243d3793401abb972fe7f 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -44,10 +44,13 @@ function locale_translation_manual_status() { * An associative array containing: * - form: The form that contains the language information. * + * @return string + * The themed output. + * * @see locale_translate_edit_form() * @ingroup themeable */ -function theme_locale_translate_edit_form_strings($variables) { +function theme_locale_translate_edit_form_strings(array $variables) { $output = ''; $form = $variables['form']; $header = array( @@ -96,7 +99,7 @@ function theme_locale_translate_edit_form_strings($variables) { * * @see \Drupal\locale\Form\TranslationStatusForm */ -function template_preprocess_locale_translation_update_info(&$variables) { +function template_preprocess_locale_translation_update_info(array &$variables) { $details = array(); // Build output for available updates. @@ -148,13 +151,13 @@ function template_preprocess_locale_translation_update_info(&$variables) { * * Default template: locale-translation-last-check.html.twig. * - * @param $variables + * @param array $variables * An associative array containing: * - last: The timestamp when the site last checked for available updates. * * @see \Drupal\locale\Form\TranslationStatusForm */ -function template_preprocess_locale_translation_last_check(&$variables) { +function template_preprocess_locale_translation_last_check(array &$variables) { $last = $variables['last']; $variables['last_checked'] = ($last != NULL); $variables['time'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $last); diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc index 2208b1d4b83c7789f79ebbaead95d2594b7bef56..61083cd608597d4ff1117da7691ede05d11de28d 100644 --- a/core/modules/locale/locale.translation.inc +++ b/core/modules/locale/locale.translation.inc @@ -52,7 +52,7 @@ * * @see locale_translation_build_projects() */ -function locale_translation_get_projects($project_names = array()) { +function locale_translation_get_projects(array $project_names = array()) { $projects = &drupal_static(__FUNCTION__, array()); if (empty($projects)) { @@ -99,7 +99,7 @@ function locale_translation_clear_cache_projects() { * * @see locale_translation_source_build() */ -function locale_translation_load_sources($projects = NULL, $langcodes = NULL) { +function locale_translation_load_sources(array $projects = NULL, array $langcodes = NULL) { $sources = array(); $projects = $projects ? $projects : array_keys(locale_translation_get_projects()); $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list()); @@ -129,7 +129,7 @@ function locale_translation_load_sources($projects = NULL, $langcodes = NULL) { * * @see locale_translation_source_build() */ -function locale_translation_build_sources($projects = array(), $langcodes = array()) { +function locale_translation_build_sources(array $projects = array(), array $langcodes = array()) { $sources = array(); $projects = locale_translation_get_projects($projects); $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list()); @@ -191,7 +191,8 @@ function locale_translation_source_check_file($source) { * @param string $langcode * Language code. * @param string $filename - * File name of translation file. May contain placeholders. + * (optional) File name of translation file. May contain placeholders. + * Defaults to the default translation filename from the settings. * * @return object * Source object: diff --git a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php index 1ca2ad85fdb7bfa247d8670abaa1f63c09f6ebfb..1995214d094df2783f5b6ef510c39feb2717c939 100644 --- a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php @@ -338,10 +338,10 @@ public function testConfigPoFile() { /** * Helper function: import a standalone .po file in a given language. * - * @param $contents + * @param string $contents * Contents of the .po file to import. - * @param $options - * Additional options to pass to the translation import form. + * @param array $options + * (optional) Additional options to pass to the translation import form. */ public function importPoFile($contents, array $options = array()) { $name = tempnam('temporary://', "po_") . '.po'; diff --git a/core/modules/locale/src/Tests/LocalePluralFormatTest.php b/core/modules/locale/src/Tests/LocalePluralFormatTest.php index 7d9f1dc4a2da93231cf452c972902c66d5eedb38..1542f17186abda43a0283f3e1cda6bba8e0a0bf0 100644 --- a/core/modules/locale/src/Tests/LocalePluralFormatTest.php +++ b/core/modules/locale/src/Tests/LocalePluralFormatTest.php @@ -267,9 +267,9 @@ public function testPluralEditExport() { /** * Imports a standalone .po file in a given language. * - * @param $contents + * @param string $contents * Contents of the .po file to import. - * @param $options + * @param array $options * Additional options to pass to the translation import form. */ public function importPoFile($contents, array $options = array()) { diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php index 5e9b81e1ce52ac7015f3b3ff35431cbf5bcca336..37d4d7804eee7316cf2d2005d482b1b44643ebdc 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php @@ -83,7 +83,7 @@ protected function setTranslationsDirectory($path) { /** * Adds a language. * - * @param $langcode + * @param string $langcode * The language code of the language to add. */ protected function addLanguage($langcode) { @@ -101,13 +101,13 @@ protected function addLanguage($langcode) { * @param string $filename * Name of the file to create. * @param int $timestamp - * Timestamp to set the file to. Defaults to current time. + * (optional) Timestamp to set the file to. Defaults to current time. * @param array $translations - * Array of source/target value translation strings. Only singular strings - * are supported, no plurals. No double quotes are allowed in source and - * translations strings. + * (optional) Array of source/target value translation strings. Only + * singular strings are supported, no plurals. No double quotes are allowed + * in source and translations strings. */ - protected function makePoFile($path, $filename, $timestamp = NULL, $translations = array()) { + protected function makePoFile($path, $filename, $timestamp = NULL, array $translations = array()) { $timestamp = $timestamp ? $timestamp : REQUEST_TIME; $path = 'public://' . $path; $text = '';