diff --git a/potx.inc b/potx.inc index ba6f75f..d423836 100644 --- a/potx.inc +++ b/potx.inc @@ -401,7 +401,8 @@ function potx_finish_processing($save_callback = '_potx_save_string', $api_versi foreach ($_potx_module_metadata as $module_qualified_name => $module_metadata) { $_potx_callbacks['store_module_metadata']($module_qualified_name, $module_metadata); } - // Parsing shipped configuration has to happen after processing all schemas. + // Parsing shipped configuration has to happen after processing all + // schemas. _potx_parse_shipped_configuration($save_callback, $api_version); } // Clear yaml translation patterns, so translation patterns for a module @@ -1399,7 +1400,7 @@ function _potx_skip_args($here) { $nesting = 0; // Continue until we reach a semicolon or the end of the function call. - while($_potx_tokens[$here] !== ';' && $nesting >= -1) { + while ($_potx_tokens[$here] !== ';' && $nesting >= -1) { if (!is_array($_potx_tokens[$here])) { if ($_potx_tokens[$here] == ')' || $_potx_tokens[$here] == ']') { $nesting--; @@ -1413,7 +1414,7 @@ function _potx_skip_args($here) { // call, we have skipped past the function arguments. if (($_potx_tokens[$here] == ',' && $nesting == 0) || ($_potx_tokens[$here] == ')' && $nesting == -1)) { - break; + break; } $here++; @@ -2299,7 +2300,7 @@ function _potx_parse_yaml_file($code, $file_name, $file_path, $save_callback) { if (isset($yaml['dependencies'])) { $_potx_module_metadata[$module_qualified_name]['dependencies'] = $yaml['dependencies']; } - else if ($yaml['type'] == 'profile' && isset($yaml['install'])) { + elseif ($yaml['type'] == 'profile' && isset($yaml['install'])) { $_potx_module_metadata[$module_qualified_name]['dependencies'] = $yaml['install']; } else { @@ -2781,8 +2782,9 @@ function _potx_parse_shipped_configuration($save_callback = '_potx_save_string', } /** - * Returns the fully qualified module name (in the project:module format) - * matching each module name in the $module_names list. + * Returns the fully qualified module name (in the project:module format). + * + * This matches each module name in the $module_names list. * * @param array $module_names * The list of module names. @@ -2790,9 +2792,9 @@ function _potx_parse_shipped_configuration($save_callback = '_potx_save_string', * @return array * The list of fully qualified module names. */ -function _potx_load_matching_qualified_modules($module_names) { +function _potx_load_matching_qualified_modules(array $module_names) { global $_potx_callbacks; - $qualified_modules = array(); + $qualified_modules = []; foreach ($module_names as $module_name) { $qualified_name = $_potx_callbacks['find_matching_qualified_module']($module_name); if ($qualified_name !== FALSE) { diff --git a/potx.local.inc b/potx.local.inc index b11930d..8d77d71 100644 --- a/potx.local.inc +++ b/potx.local.inc @@ -59,38 +59,38 @@ function _potx_find_all_modules($module_path) { break; } $search_path = dirname($search_path); - } while($search_path != '/'); + } while ($search_path != '/'); if (!isset($root_dir)) { return; } // The Drupal core directory contains a config/schema subdirectory, which - // is not part of any module or theme. + // is not part of any module or theme. $_potx_found_modules['drupal:core']['path'] = $root_dir . '/core'; // The list of paths that contain drupal core modules or themes. - $core_paths = array( + $core_paths = [ $root_dir . '/core/profiles', $root_dir . '/core/modules', $root_dir . '/core/themes', - ); + ]; foreach ($core_paths as $core_path) { _potx_find_modules($core_path, 'drupal'); } // The list of paths that could contain drupal modules or themes. - $search_paths = array( + $search_paths = [ $root_dir . '/profiles', $root_dir . '/modules', $root_dir . '/themes', - ); + ]; $sites = glob($root_dir . '/sites/*', GLOB_ONLYDIR); foreach ($sites as $site) { - foreach (array('/modules', '/themes') as $sub) { + foreach (['/modules', '/themes'] as $sub) { if (is_dir($site . $sub)) { $search_paths[] = $site . $sub; } @@ -120,23 +120,25 @@ function _potx_find_modules($path, $project = NULL) { if (!preg_match("!(^|.+/)(CVS|\.svn|\.git|tests|vendor)$!", $dir)) { $module_info_paths = glob($dir . '/*.info.yml', GLOB_MARK); if (!empty($module_info_paths)) { - foreach($module_info_paths as $module_info_path) { + foreach ($module_info_paths as $module_info_path) { $module_name = basename($module_info_path, '.info.yml'); if ($project != NULL) { $module_project = $project; - } else { + } + else { // All module releases on drupal.org contain a project: key in - // their .info.yml files, but this may not be the case when - // running potx locally (e.g. custom or dev modules); so, we use - // the directory name as the project name for this module and any - // submodules in the same directory + // their .info.yml files, but this may not be the case when + // running potx locally (e.g. custom or dev modules); so, we use + // the directory name as the project name for this module and any + // submodules in the same directory. $module_dir = dirname($module_info_path); $module_project = basename($module_dir); } $_potx_found_modules["$module_project:$module_name"]['path'] = $dir; _potx_find_modules($dir, $module_project); } - } else { + } + else { _potx_find_modules($dir, $project); } } @@ -338,21 +340,24 @@ function _potx_schema_load($module_qualified_name) { } /** - * Returns a fully qualified module name (in the project:module format) - * matching $module_name from the list of modules found in the Drupal install - * directory, or FALSE if no matching module is found. + * Find a fully qualified module name (in the project:module format). + * + * This matches the $module_name from the list of modules found in the Drupal + * install directory. * * @param string $module_name * The module name. * - * @return string - * The fully qualified name of the module. + * @return string|false + * The fully qualified name of the module, or FALSE if no matching module + * is found. */ function _potx_find_matching_qualified_module($module_name) { global $_potx_found_modules; if (strpos($module_name, ':') !== FALSE) { return isset($_potx_found_modules[$module_name]) ? $module_name : FALSE; - } else { + } + else { $matches = preg_grep('/:' . $module_name . '$/', array_keys($_potx_found_modules)); return end($matches); } diff --git a/src/Tests/PotxTest.php b/src/Tests/PotxTest.php index 32bf288..9e88941 100644 --- a/src/Tests/PotxTest.php +++ b/src/Tests/PotxTest.php @@ -764,12 +764,12 @@ class TestConstraint { } /** - * Assert the list of expected errors generated by potx from parsing the input files. + * Assert the list of expected errors from parsing the input files. * * @param array $expected_errors * The list of expected errors. */ - private function assertPotxErrors($expected_errors) { + private function assertPotxErrors(array $expected_errors) { $this->assert(count($this->potx_status) == count($expected_errors), count($expected_errors) . ' error messages found'); $potx_errors = array_column($this->potx_status, 0);