Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #115: Coding standards revisited #116

Merged
merged 2 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion i18n.install
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function i18n_install() {
* necessary when additional implementations of hook_schema_alter() have
* become available since the schema was originally built.
*/
function i18n_install_create_fields($table, $fields, $force_rebuild_schema = FALSE) {
function i18n_install_create_fields($table, array $fields, $force_rebuild_schema = FALSE) {
static $schema;
$rebuild_schema = !isset($schema) || $force_rebuild_schema;
$schema = backdrop_get_schema($table, $rebuild_schema);
Expand Down
2 changes: 1 addition & 1 deletion i18n.module
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function i18n_preprocess_html(&$variables) {
* @return string
* Translated string, $string if not found.
*/
function i18n_string($name, $string, $options = array()) {
function i18n_string($name, $string, array $options = array()) {
$options += array('translate' => TRUE, 'update' => FALSE);
if ($options['update']) {
$result = function_exists('i18n_string_update') ? i18n_string_update($name, $string, $options) : FALSE;
Expand Down
1 change: 0 additions & 1 deletion i18n_field/i18n_field.i18n.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function i18n_field_i18n_object_info() {
'title' => t('Label'),
),
),
// 'translate path' => 'admin/structure/block/manage/%module/%delta/translate/%i18n_language',
),
);
$info['field_instance'] = array(
Expand Down
2 changes: 1 addition & 1 deletion i18n_field/i18n_field.module
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ function i18n_field_instance_update_strings($instance) {
* The array of allowed values. Keys of the array are the raw stored values
* (number or text), values of the array are the display labels.
*/
function i18n_field_translate_allowed_values($field, $langcode = NULL) {
function i18n_field_translate_allowed_values(array $field, $langcode = NULL) {
if (!empty($field['settings']['allowed_values'])) {
$context = array(
'field',
Expand Down
1 change: 0 additions & 1 deletion i18n_field/i18n_field.pages.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function i18n_field_page_translate($instance, $language = NULL) {
// language object loader is not working.
$language = i18n_language_object($language);
backdrop_set_title(t('Translate to !language', array('!language' => i18n_language_name($language->langcode))));
// Return backdrop_get_form('i18n_field_page_translate_form', $instance, $language->language);
// Create form with two tabs, one for instance, once for field.
$groups = array(
'instance' => t('Field instance'),
Expand Down
4 changes: 3 additions & 1 deletion i18n_menu/i18n_menu.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ function i18n_menu_translation_form_submit($form, &$form_state) {
* @param array $item
* The menu item or the node type for which to generate a list of parents.
* If $item['mlid'] == 0 then the complete tree is returned.
* @param string $langcode
* Language code.
*
* @return array
* An array of menu link titles keyed on the a string containing the menu name
Expand All @@ -147,7 +149,7 @@ function i18n_menu_translation_form_submit($form, &$form_state) {
* @todo This has to be turned into a #process form element callback. The
* 'menu_override_parent_selector' variable is entirely superfluous.
*/
function i18n_menu_parent_options($menus, $item, $langcode) {
function i18n_menu_parent_options(array $menus, array $item, $langcode) {
// The menu_links table can be practically any size and we need a way to
// allow contrib modules to provide more scalable pattern choosers.
// hook_form_alter is too late in itself because all the possible parents are
Expand Down
2 changes: 2 additions & 0 deletions i18n_menu/i18n_menu.module
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ function i18n_menu_localize_tree($tree, $langcode = NULL) {

/**
* Localize menu renderable array.
*
* @todo This might be dead code, for example $tree in if clause is never set.
*/
function i18n_menu_localize_elements(&$elements) {
foreach (element_children($elements) as $mlid) {
Expand Down
2 changes: 1 addition & 1 deletion i18n_node/i18n_node.module
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function i18n_node_get_lang($nid, $default = '') {
* This allows node types to define its own language list
* implementing hook 'language_list'.
*
* @param object $node
* @param Node $node
* Node to retrieve language list for.
* @param bool $translate
* Only languages available for translation.
Expand Down
4 changes: 2 additions & 2 deletions i18n_node/i18n_node.pages.inc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function i18n_node_nid2autocomplete($nid) {
* @param string $field
* Form field name attribute.
*/
function i18n_node_autocomplete2nid($name, $type, $language, $field = NULL) {
function i18n_node_autocomplete2nid($name, $type, array $language, $field = NULL) {
if (!empty($name)) {
preg_match('/^(?:\s*|(.*) )?\[\s*nid\s*:\s*(\d+)\s*\]$/', $name, $matches);
if (!empty($matches)) {
Expand Down Expand Up @@ -316,7 +316,7 @@ function i18n_node_autocomplete2nid($name, $type, $language, $field = NULL) {
* @param array $params
* Other query arguments: type, language or numeric ones.
*/
function _i18n_node_references($string, $match = 'contains', $params = array(), $limit = 10) {
function _i18n_node_references($string, $match = 'contains', array $params = array(), $limit = 10) {
$query = db_select('node', 'n')
->fields('n', array('nid', 'title', 'type'))
->orderBy('n.title')
Expand Down
15 changes: 0 additions & 15 deletions i18n_path/i18n_path.module
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,6 @@ function i18n_path_menu() {
return $items;
}

/**
* Implements hook_url_outbound_alter()
*/
/*
function i18n_path_url_outbound_alter(&$path, &$options, $original_path) {
if (!empty($options['language'])) {
$langcode = $options['language']->language;
$original = $options['alias'] ? backdrop_get_normal_path($path, $langcode) : $original_path;
if (($translations = i18n_path_get_translations($path)) && !empty($translations[$langcode])) {
$path = $options['alias'] ? backdrop_get_path_alias($translations[$langcode], $langcode) : $translations[$langcode];
}
}
}
*/

/**
* Get translations for path.
*/
Expand Down
2 changes: 1 addition & 1 deletion i18n_string/i18n_string.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function i18n_string_refresh_string_list($strings) {
* @param bool $delete
* Optional, delete existing (but not refresed, strings and translations)
*/
function i18n_string_refresh_batch($groups, $delete = FALSE) {
function i18n_string_refresh_batch(array $groups, $delete = FALSE) {
$operations = array();
foreach ($groups as $group) {
$operations[] = array('_i18n_string_batch_refresh_prepare', array($group));
Expand Down
3 changes: 0 additions & 3 deletions i18n_string/i18n_string.i18n.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ function i18n_string_object_type_string_list($type) {
* @see backdrop_array_merge_deep()
* @see array_merge_recursive()
*
* @param ...
* Arrays to merge.
*
* @return array
* The merged array.
*/
Expand Down
22 changes: 11 additions & 11 deletions i18n_string/i18n_string.inc
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class i18n_string_object {
/**
* Get source string provided a string object.
*
* @return object
* @return object|null
* String object if source exists.
*/
public function get_source() {
Expand Down Expand Up @@ -609,7 +609,7 @@ class i18n_string_textgroup_default {
* @param array $options
* Additional options.
*
* @return status
* @return int|false
* SAVED_UPDATED | SAVED_NEW | SAVED_DELETED | FALSE (If the string is
* to be removed but has no source)
*/
Expand Down Expand Up @@ -865,7 +865,7 @@ class i18n_string_textgroup_default {
* - 'check', whether to check string format and then update/delete
* if not allowed.
*/
public function context_update($context, $string, $options = array()) {
public function context_update($context, $string, array $options = array()) {
$options += array(
'format' => FALSE,
'messages' => $this->debug,
Expand Down Expand Up @@ -916,7 +916,7 @@ class i18n_string_textgroup_default {
* @return array
* Array of i18n string objects.
*/
protected function multiple_translation_build($translations, $langcode) {
protected function multiple_translation_build(array $translations, $langcode) {
$strings = array();
foreach ($translations as $translation) {
// The string object may be already in list.
Expand Down Expand Up @@ -954,7 +954,7 @@ class i18n_string_textgroup_default {
* @return array
* Array of string objects with translation set.
*/
protected function multiple_translation_load($conditions, $langcode) {
protected function multiple_translation_load(array $conditions, $langcode) {
$conditions += array(
'language' => $langcode,
'textgroup' => $this->textgroup,
Expand Down Expand Up @@ -1061,7 +1061,7 @@ class i18n_string_textgroup_default {
* @param array $strings
* Array of strings (may be empty) to cache.
*/
protected function multiple_cache_set($context, $strings) {
protected function multiple_cache_set(array $context, array $strings) {
$cache_key = implode(':', $context);
$this->cache_multiple[$cache_key] = $strings;
}
Expand All @@ -1076,7 +1076,7 @@ class i18n_string_textgroup_default {
* Array of strings (may be empty) if we've got a cache hit.
* Null otherwise.
*/
protected function multiple_cache_get($context) {
protected function multiple_cache_get(array $context) {
$cache_key = implode(':', $context);
if (isset($this->cache_multiple[$cache_key])) {
return $this->cache_multiple[$cache_key];
Expand Down Expand Up @@ -1116,7 +1116,7 @@ class i18n_string_textgroup_default {
* Array of string objects (with translation)
* indexed by the placeholder field.
*/
public function multiple_translate($context, $strings = array(), $options = array()) {
public function multiple_translate(array $context, array $strings = array(), array $options = array()) {
// First, build conditions and identify the variable field.
$search = $context = array_combine(array('type', 'objectid', 'property'), $context);
$langcode = isset($options['langcode']) ? $options['langcode'] : i18n_langcode();
Expand Down Expand Up @@ -1169,7 +1169,7 @@ class i18n_string_textgroup_default {
* @param object $translation
* String translation for this language.
*/
public function update_translation($context, $langcode, $translation) {
public function update_translation(array $context, $langcode, $translation) {
$i18nstring = $this->build_string($context);
if ($source = $i18nstring->get_source()) {
$source->set_translation($translation, $langcode);
Expand Down Expand Up @@ -1219,7 +1219,7 @@ class i18n_string_object_wrapper extends i18n_object_wrapper {
* Array with processing options.
* - 'empty', whether to return empty strings, defaults to FALSE.
*/
public function get_strings($options = array()) {
public function get_strings(array $options = array()) {
$options += array('empty' => FALSE);
$strings = array();
foreach ($this->get_properties() as $textgroup => $textgroup_list) {
Expand Down Expand Up @@ -1585,7 +1585,7 @@ class i18n_string_textgroup_cached extends i18n_string_textgroup_default {
* Array of strings (may be empty) if we've got a cache hit.
* Null otherwise.
*/
protected function multiple_cache_get($context) {
protected function multiple_cache_get(array $context) {
// Ensure the values from the persistent cache are properly re-build.
$cache_key = implode(':', $context);
if (isset($this->cache_multiple[$cache_key])) {
Expand Down
4 changes: 2 additions & 2 deletions i18n_string/i18n_string.module
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,8 @@ function i18n_string_translation_search($name, $langcode = NULL) {
* @param array|string $name
* Array or string concatenated with ':' that contains
* textgroup and string context.
* @param string $translation
* Translation string for this language code.
* @param array|string $translation
* Translation string for this language code. Might be an array with multiple.
* @param string $langcode
* The language code to translate to a language other than
* what is used to display the page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class i18n_string_views_handler_argument_locale_group extends views_handler_argu
* Set up.
*/
public function construct() {
parent::construct('group');
parent::construct();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions i18n_sync/i18n_sync.module
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ function i18n_sync_node_check($node) {
/**
* Get node translations if any, excluding the node itself.
*
* @param Node $node
* The node object.
* @param bool $reset
* Whether to reset the translation_node_get_translations cache.
*/
Expand Down
5 changes: 5 additions & 0 deletions i18n_sync/i18n_sync.node.inc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ function i18n_sync_node_translation_nodereference_field(&$node, &$translation, $
* English A and B are translated to German A and B, but English C is not.
* The syncronization from English A to German A
* would it German B and English C.
*
* @param Node $reference_node
* The node object.
* @param string $langcode
* The language code.
*/
function i18n_sync_node_translation_reference_field(&$reference_node, $default_value, $langcode) {
if (isset($reference_node->tnid) && translation_supported_type($reference_node->type)) {
Expand Down
6 changes: 3 additions & 3 deletions i18n_taxonomy/i18n_taxonomy.install
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function i18n_taxonomy_install() {
if (isset($data['language']) && $data['language'] == TAXONOMY_LANGUAGE_ENABLED) {
// But only if multilingual support is enabled.
$data['i18n_mode'] = I18N_MODE_NONE;
$data['langcode'] = LANGAGE_NONE;
$config->save($data);
$data['langcode'] = LANGUAGE_NONE;
$config->save();
}
}
}
Expand All @@ -39,7 +39,7 @@ function i18n_taxonomy_uninstall() {
$data = $config->get();
unset($data['i18n_mode']);
unset($data['langcode']);
$config->save($data);
$config->save();
}
}

Expand Down
9 changes: 6 additions & 3 deletions i18n_taxonomy/i18n_taxonomy.module
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ function i18n_taxonomy_term_description($term, $langcode = NULL) {
/**
* Find term translation from translation set.
*
* @param object $term
* @param TaxonomyTerm $term
* Term object to find translation.
* @param string $langcode
* Language code to find translation for.
*
* @return object
* @return TaxonomyTerm|null
* Taxonomy Term, translated if exists.
*/
function i18n_taxonomy_term_get_translation($term, $langcode) {
Expand Down Expand Up @@ -623,6 +623,9 @@ function i18n_taxonomy_taxonomy_term_update($term) {

/**
* Implements hook_taxonomy_term_delete().
*
* @param TaxonomyTerm $term
* The term object.
*/
function i18n_taxonomy_taxonomy_term_delete($term) {
// If a translation set exists for this term, remove this term from the set.
Expand Down Expand Up @@ -1087,7 +1090,7 @@ function i18n_taxonomy_form_all_localize(&$item) {
* Array with translated terms: tid -> $term
* Array with vid and term array.
*/
function i18n_taxonomy_translate_terms($taxonomy, $langcode, $fullterms = TRUE) {
function i18n_taxonomy_translate_terms(array $taxonomy, $langcode, $fullterms = TRUE) {
$translation = array();
if (is_array($taxonomy) && $taxonomy) {
foreach ($taxonomy as $index => $tdata) {
Expand Down