Unverified Commit e125ce28 authored by larowlan's avatar larowlan
Browse files

Issue #3222769 by bbrala, alexpott, longwave, Matroskeen: [November 8, 2021]...

Issue #3222769 by bbrala, alexpott, longwave, Matroskeen: [November 8, 2021] Replace all list (array destructuring) assignment to the array syntax

(cherry picked from commit 6d39cdee)
parent f436f7c0
......@@ -148,7 +148,7 @@ protected function findTokens($message) {
}
$tokens = [];
foreach ($matches as $matchSet) {
list($sourceText, $key) = $matchSet;
[$sourceText, $key] = $matchSet;
$tokens[$sourceText] = $key;
}
return $tokens;
......
......@@ -134,7 +134,7 @@ function _batch_needs_update($new_value = NULL) {
*/
function _batch_do() {
// Perform actual processing.
list($percentage, $message, $label) = _batch_process();
[$percentage, $message, $label] = _batch_process();
return new JsonResponse(['status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label]);
}
......@@ -179,11 +179,11 @@ function _batch_progress_page() {
// Just use the content of the response.
$fallback = $response->getContent();
list($fallback) = explode('<!--partial-->', $fallback);
[$fallback] = explode('<!--partial-->', $fallback);
print $fallback;
// Perform actual processing.
list($percentage, $message, $label) = _batch_process($batch);
[$percentage, $message, $label] = _batch_process($batch);
if ($percentage == 100) {
$new_op = 'finished';
}
......@@ -283,7 +283,7 @@ function _batch_process() {
$finished = 1;
if ($item = $queue->claimItem()) {
list($callback, $args) = $item->data;
[$callback, $args] = $item->data;
// Build the 'context' array and execute the function call.
$batch_context = [
......
......@@ -418,7 +418,7 @@ function drupal_valid_test_ua($new_prefix = NULL) {
$http_user_agent = $_SERVER['HTTP_USER_AGENT'] ?? NULL;
$user_agent = $_COOKIE['SIMPLETEST_USER_AGENT'] ?? $http_user_agent;
if (isset($user_agent) && preg_match("/^simple(\w+\d+):(.+):(.+):(.+)$/", $user_agent, $matches)) {
list(, $prefix, $time, $salt, $hmac) = $matches;
[, $prefix, $time, $salt, $hmac] = $matches;
$check_string = $prefix . ':' . $time . ':' . $salt;
// Read the hash salt prepared by drupal_generate_test_ua().
// This function is called before settings.php is read and Drupal's error
......
......@@ -58,7 +58,7 @@ function drupal_error_levels() {
function _drupal_error_handler_real($error_level, $message, $filename, $line) {
if ($error_level & error_reporting()) {
$types = drupal_error_levels();
list($severity_msg, $severity_level) = $types[$error_level];
[$severity_msg, $severity_level] = $types[$error_level];
$backtrace = debug_backtrace();
$caller = Error::getLastCaller($backtrace);
......
......@@ -282,7 +282,7 @@ function drupal_rewrite_settings($settings = [], $settings_file = NULL) {
$state = 'default';
foreach (token_get_all($contents) as $token) {
if (is_array($token)) {
list($type, $value) = $token;
[$type, $value] = $token;
}
else {
$type = -1;
......
......@@ -153,7 +153,7 @@ function drupal_find_theme_functions($cache, $prefixes) {
// intermediary suggestion.
$pattern = $info['pattern'] ?? ($hook . '__');
// Grep only the functions which are within the prefix group.
list($first_prefix,) = explode('_', $prefix, 2);
[$first_prefix] = explode('_', $prefix, 2);
if (!isset($info['base hook']) && !empty($pattern) && isset($grouped_functions[$first_prefix])) {
$matches = preg_grep('/^' . $prefix . '_' . $pattern . '/', $grouped_functions[$first_prefix]);
if ($matches) {
......
......@@ -286,7 +286,7 @@ function update_invoke_post_update($function, &$context) {
return;
}
list($module, $name) = explode('_post_update_', $function, 2);
[$module, $name] = explode('_post_update_', $function, 2);
module_load_include('php', $module, $module . '.post_update');
if (function_exists($function)) {
try {
......
......@@ -897,7 +897,7 @@ private function Constant()
$identifier = $this->Identifier();
if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) {
list($className, $const) = explode('::', $identifier);
[$className, $const] = explode('::', $identifier);
$alias = (false === $pos = strpos($className, '\\')) ? $className : substr($className, 0, $pos);
$found = false;
......@@ -1099,7 +1099,7 @@ private function Arrayx()
$this->match(DocLexer::T_CLOSE_CURLY_BRACES);
foreach ($values as $value) {
list ($key, $val) = $value;
[$key, $val] = $value;
if ($key !== null) {
$array[$key] = $val;
......
......@@ -165,7 +165,7 @@ protected function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) {
// Things seems faster (I'm not sure I understand why)
// when the shortest sequence in X.
$flip = TRUE;
list($xoff, $xlim, $yoff, $ylim) = [$yoff, $ylim, $xoff, $xlim];
[$xoff, $xlim, $yoff, $ylim] = [$yoff, $ylim, $xoff, $xlim];
}
if ($flip) {
......@@ -302,7 +302,7 @@ protected function _compareseq($xoff, $xlim, $yoff, $ylim) {
//$nchunks = sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5);
//$nchunks = max(2, min(8, (int)$nchunks));
$nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1;
list($lcs, $seps) = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
[$lcs, $seps] = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
}
if ($lcs == 0) {
......
......@@ -14,8 +14,8 @@ class WordLevelDiff extends MappedDiff {
const MAX_LINE_LENGTH = 10000;
public function __construct($orig_lines, $closing_lines) {
list($orig_words, $orig_stripped) = $this->_split($orig_lines);
list($closing_words, $closing_stripped) = $this->_split($closing_lines);
[$orig_words, $orig_stripped] = $this->_split($orig_lines);
[$closing_words, $closing_stripped] = $this->_split($closing_lines);
parent::__construct($orig_words, $closing_words, $orig_stripped, $closing_stripped);
}
......
......@@ -254,7 +254,7 @@ private function parseHeader($header) {
$lines = array_map('trim', explode("\n", $header));
foreach ($lines as $line) {
if ($line) {
list($tag, $contents) = explode(":", $line, 2);
[$tag, $contents] = explode(":", $line, 2);
$header_parsed[trim($tag)] = trim($contents);
}
}
......
......@@ -55,7 +55,7 @@ public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
// $base_plugin_id.
$plugin_definition = $this->decorated->getDefinition($plugin_id, FALSE);
list($base_plugin_id, $derivative_id) = $this->decodePluginId($plugin_id);
[$base_plugin_id, $derivative_id] = $this->decodePluginId($plugin_id);
$base_plugin_definition = $this->decorated->getDefinition($base_plugin_id, $exception_on_invalid);
if ($base_plugin_definition) {
$deriver = $this->getDeriver($base_plugin_id, $base_plugin_definition);
......
......@@ -69,7 +69,7 @@ public function getPluginId() {
public function getBaseId() {
$plugin_id = $this->getPluginId();
if (strpos($plugin_id, static::DERIVATIVE_SEPARATOR)) {
list($plugin_id) = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 2);
[$plugin_id] = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 2);
}
return $plugin_id;
}
......@@ -81,7 +81,7 @@ public function getDerivativeId() {
$plugin_id = $this->getPluginId();
$derivative_id = NULL;
if (strpos($plugin_id, static::DERIVATIVE_SEPARATOR)) {
list(, $derivative_id) = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 2);
[, $derivative_id] = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 2);
}
return $derivative_id;
}
......
......@@ -147,14 +147,14 @@ public static function parse($url) {
if ($scheme_delimiter_position !== FALSE && ($query_delimiter_position === FALSE || $scheme_delimiter_position < $query_delimiter_position)) {
// Split off the fragment, if any.
if (strpos($url, '#') !== FALSE) {
list($url, $options['fragment']) = explode('#', $url, 2);
[$url, $options['fragment']] = explode('#', $url, 2);
}
// Split off everything before the query string into 'path'.
$parts = explode('?', $url, 2);
// Don't support URLs without a path, like 'http://'.
list(, $path) = explode('://', $parts[0], 2);
[, $path] = explode('://', $parts[0], 2);
if ($path != '') {
$options['path'] = $parts[0];
}
......
......@@ -142,7 +142,7 @@ protected function buildAttachmentsCommands(AjaxResponse $response, Request $req
->setAlreadyLoadedLibraries(isset($ajax_page_state['libraries']) ? explode(',', $ajax_page_state['libraries']) : [])
->setSettings($attachments['drupalSettings'] ?? []);
$css_assets = $this->assetResolver->getCssAssets($assets, $optimize_css);
list($js_assets_header, $js_assets_footer) = $this->assetResolver->getJsAssets($assets, $optimize_js);
[$js_assets_header, $js_assets_footer] = $this->assetResolver->getJsAssets($assets, $optimize_js);
// First, AttachedAssets::setLibraries() ensures duplicate libraries are
// removed: it converts it to a set of libraries if necessary. Second,
......
......@@ -130,7 +130,7 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) {
];
foreach ($libraries_to_load as $library) {
list($extension, $name) = explode('/', $library, 2);
[$extension, $name] = explode('/', $library, 2);
$definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
if (isset($definition['css'])) {
foreach ($definition['css'] as $options) {
......@@ -196,7 +196,7 @@ protected function getJsSettingsAssets(AttachedAssetsInterface $assets) {
$settings = [];
foreach ($this->getLibrariesToLoad($assets) as $library) {
list($extension, $name) = explode('/', $library, 2);
[$extension, $name] = explode('/', $library, 2);
$definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
if (isset($definition['drupalSettings'])) {
$settings = NestedArray::mergeDeepArray([$settings, $definition['drupalSettings']], TRUE);
......@@ -218,7 +218,7 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) {
$cid = 'js:' . $theme_info->getName() . ':' . $this->languageManager->getCurrentLanguage()->getId() . ':' . Crypt::hashBase64(serialize($libraries_to_load)) . (int) (count($assets->getSettings()) > 0) . (int) $optimize;
if ($cached = $this->cache->get($cid)) {
list($js_assets_header, $js_assets_footer, $settings, $settings_in_header) = $cached->data;
[$js_assets_header, $js_assets_footer, $settings, $settings_in_header] = $cached->data;
}
else {
$javascript = [];
......@@ -236,7 +236,7 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) {
// Collect all libraries that contain JS assets and are in the header.
$header_js_libraries = [];
foreach ($libraries_to_load as $library) {
list($extension, $name) = explode('/', $library, 2);
[$extension, $name] = explode('/', $library, 2);
$definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
if (isset($definition['js']) && !empty($definition['header'])) {
$header_js_libraries[] = $library;
......@@ -248,7 +248,7 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) {
$header_js_libraries = $this->libraryDependencyResolver->getLibrariesWithDependencies($header_js_libraries);
foreach ($libraries_to_load as $library) {
list($extension, $name) = explode('/', $library, 2);
[$extension, $name] = explode('/', $library, 2);
$definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
if (isset($definition['js'])) {
foreach ($definition['js'] as $options) {
......
......@@ -64,7 +64,7 @@ public function getLibrariesWithDependencies(array $libraries) {
protected function doGetDependencies(array $libraries_with_unresolved_dependencies, array $final_libraries = []) {
foreach ($libraries_with_unresolved_dependencies as $library) {
if (!isset($final_libraries[$library])) {
list($extension, $name) = explode('/', $library, 2);
[$extension, $name] = explode('/', $library, 2);
$definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
if (!empty($definition['dependencies'])) {
$final_libraries = $this->doGetDependencies($definition['dependencies'], $final_libraries);
......
......@@ -96,7 +96,7 @@ protected function getLibraryDefinitions($extension) {
else {
// Otherwise replace with existing library definition if it exists.
// Throw an exception if it doesn't.
list($replacement_extension, $replacement_name) = explode('/', $definition['override']);
[$replacement_extension, $replacement_name] = explode('/', $definition['override']);
$replacement_definition = $this->get($replacement_extension);
if (isset($replacement_definition[$replacement_name])) {
$libraries[$name] = $replacement_definition[$replacement_name];
......@@ -145,7 +145,7 @@ protected function applyLibrariesExtend($extension, $library_name, $library_defi
// Only string library names are allowed.
throw new InvalidLibrariesExtendSpecificationException('The libraries-extend specification for each library must be a list of strings.');
}
list($new_extension, $new_library_name) = explode('/', $library_extend_name, 2);
[$new_extension, $new_library_name] = explode('/', $library_extend_name, 2);
$new_libraries = $this->get($new_extension);
if (isset($new_libraries[$new_library_name])) {
$library_definition = NestedArray::mergeDeep($library_definition, $new_libraries[$new_library_name]);
......
......@@ -106,7 +106,7 @@ public function convertTokensToKeys(array $context_tokens) {
// Iterate over cache contexts that have been optimized away and get their
// cacheability metadata.
foreach (static::parseTokens(array_diff($context_tokens, $optimized_tokens)) as $context_token) {
list($context_id, $parameter) = $context_token;
[$context_id, $parameter] = $context_token;
$context = $this->getService($context_id);
$cacheable_metadata = $cacheable_metadata->merge($context->getCacheableMetadata($parameter));
}
......@@ -114,7 +114,7 @@ public function convertTokensToKeys(array $context_tokens) {
sort($optimized_tokens);
$keys = [];
foreach (array_combine($optimized_tokens, static::parseTokens($optimized_tokens)) as $context_token => $context) {
list($context_id, $parameter) = $context;
[$context_id, $parameter] = $context;
$keys[] = '[' . $context_token . ']=' . $this->getService($context_id)->getContext($parameter);
}
......@@ -164,7 +164,7 @@ public function optimizeTokens(array $context_tokens) {
$parameter = NULL;
$context_id = $context_token;
if (strpos($context_token, ':') !== FALSE) {
list($context_id, $parameter) = explode(':', $context_token);
[$context_id, $parameter] = explode(':', $context_token);
}
// Context tokens without:
......@@ -236,7 +236,7 @@ public static function parseTokens(array $context_tokens) {
$context_id = $context;
$parameter = NULL;
if (strpos($context, ':') !== FALSE) {
list($context_id, $parameter) = explode(':', $context, 2);
[$context_id, $parameter] = explode(':', $context, 2);
}
$contexts_with_parameters[] = [$context_id, $parameter];
}
......
......@@ -279,7 +279,7 @@ protected function getTableCollation(Connection $connection, $table, &$definitio
// Map the collation to a character set. For example, 'utf8mb4_general_ci'
// (MySQL 5) or 'utf8mb4_0900_ai_ci' (MySQL 8) will be mapped to 'utf8mb4'.
list($charset,) = explode('_', $data['Collation'], 2);
[$charset] = explode('_', $data['Collation'], 2);
// Set `mysql_character_set`. This will be ignored by other backends.
$definition['mysql_character_set'] = $charset;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment