Commit f659d6ca authored by catch's avatar catch
Browse files

Issue #2901726 by mfernea, gmario, finn.lewis, robertoperuzzo, rachel_norfolk:...

Issue #2901726 by mfernea, gmario, finn.lewis, robertoperuzzo, rachel_norfolk: Fix 'Squiz.Functions.MultiLineFunctionDeclaration' coding standard
parent 942b70b4
......@@ -1030,7 +1030,7 @@ function file_scan_directory($dir, $mask, $options = [], $depth = 0) {
// performance boost.
if (!isset($options['nomask'])) {
$ignore_directories = Settings::get('file_scan_ignore_directories', []);
array_walk($ignore_directories, function(&$value) {
array_walk($ignore_directories, function (&$value) {
$value = preg_quote($value, '/');
});
$default_nomask = '/^' . implode('|', $ignore_directories) . '$/';
......
......@@ -25,7 +25,7 @@ public static function register() {
require __DIR__ . '/global_namespace_php5.php';
}
// PHP 5 - create a handler to throw the exception directly.
assert_options(ASSERT_CALLBACK, function($file = '', $line = 0, $code = '', $message = '') {
assert_options(ASSERT_CALLBACK, function ($file = '', $line = 0, $code = '', $message = '') {
if (empty($message)) {
$message = $code;
}
......
......@@ -376,7 +376,7 @@ public static function lcfirst($text) {
*/
public static function ucwords($text) {
$regex = '/(^|[' . static::PREG_CLASS_WORD_BOUNDARY . '])([^' . static::PREG_CLASS_WORD_BOUNDARY . '])/u';
return preg_replace_callback($regex, function(array $matches) {
return preg_replace_callback($regex, function (array $matches) {
return $matches[1] . Unicode::strtoupper($matches[2]);
}, $text);
}
......
......@@ -175,7 +175,7 @@ public function getAll() {
public function deleteAll() {
$this->state->delete('drupal_css_cache_files');
$delete_stale = function($uri) {
$delete_stale = function ($uri) {
// Default stale file threshold is 30 days.
if (REQUEST_TIME - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) {
file_unmanaged_delete($uri);
......
......@@ -178,7 +178,7 @@ public function getAll() {
*/
public function deleteAll() {
$this->state->delete('system.js_cache_files');
$delete_stale = function($uri) {
$delete_stale = function ($uri) {
// Default stale file threshold is 30 days.
if (REQUEST_TIME - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) {
file_unmanaged_delete($uri);
......
......@@ -278,7 +278,7 @@ protected function getCacheKey($name) {
*/
protected function getCacheKeys(array $names) {
$prefix = $this->getCollectionPrefix();
$cache_keys = array_map(function($name) use ($prefix) {
$cache_keys = array_map(function ($name) use ($prefix) {
return $prefix . $name;
}, $names);
......
......@@ -306,7 +306,7 @@ protected function getConfigCacheKey($name, $immutable) {
* An array of cache keys that match the provided config name.
*/
protected function getConfigCacheKeys($name) {
return array_filter(array_keys($this->cache), function($key) use ($name) {
return array_filter(array_keys($this->cache), function ($key) use ($name) {
// Return TRUE if the key is the name or starts with the configuration
// name plus the delimiter.
return $key === $name || strpos($key, $name . ':') === 0;
......
......@@ -185,7 +185,7 @@ public function installOptionalConfig(StorageInterface $storage = NULL, $depende
$existing_config = $this->getActiveStorages()->listAll();
$list = array_unique(array_merge($storage->listAll(), $optional_profile_config));
$list = array_filter($list, function($config_name) use ($existing_config) {
$list = array_filter($list, function ($config_name) use ($existing_config) {
// Only list configuration that:
// - does not already exist
// - is a configuration entity (this also excludes config that has an
......
......@@ -233,7 +233,7 @@ public function getConfigDependencyManager() {
// dependencies on the config entity classes. Assume data with UUID is a
// config entity. Only configuration entities can be depended on so we can
// ignore everything else.
$data = array_map(function($config) {
$data = array_map(function ($config) {
$data = $config->get();
if (isset($data['uuid'])) {
return $data;
......
......@@ -88,7 +88,7 @@ public function execute() {
foreach ($this->sort as $sort) {
$direction = $sort['direction'] == 'ASC' ? -1 : 1;
$field = $sort['field'];
uasort($result, function($a, $b) use ($field, $direction) {
uasort($result, function ($a, $b) use ($field, $direction) {
return ($a[$field] <= $b[$field]) ? $direction : -$direction;
});
}
......
......@@ -128,7 +128,7 @@ public function __toString() {
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
$insert_fields = array_map(function($f) {
$insert_fields = array_map(function ($f) {
return $this->connection->escapeField($f);
}, $insert_fields);
......
......@@ -100,7 +100,7 @@ public function __toString() {
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
$insert_fields = array_map(function($f) {
$insert_fields = array_map(function ($f) {
return $this->connection->escapeField($f);
}, $insert_fields);
......
......@@ -108,7 +108,7 @@ public function format($format, $settings = []) {
$format = parent::format($format, $settings);
// Translates a formatted date string.
$translation_callback = function($matches) use ($langcode) {
$translation_callback = function ($matches) use ($langcode) {
$code = $matches[1];
$string = $matches[2];
if (!isset($this->formatTranslationCache[$langcode][$code][$string])) {
......
......@@ -916,7 +916,7 @@ public function getTranslationStatus($langcode) {
* {@inheritdoc}
*/
public function getTranslationLanguages($include_default = TRUE) {
$translations = array_filter($this->translations, function($translation) {
$translations = array_filter($this->translations, function ($translation) {
return $translation['status'];
});
unset($translations[LanguageInterface::LANGCODE_DEFAULT]);
......
......@@ -153,10 +153,10 @@ protected function initFieldValues(ContentEntityInterface $entity, array $values
*/
public function createTranslation(ContentEntityInterface $entity, $langcode, array $values = []) {
$translation = $entity->getTranslation($langcode);
$definitions = array_filter($translation->getFieldDefinitions(), function(FieldDefinitionInterface $definition) {
$definitions = array_filter($translation->getFieldDefinitions(), function (FieldDefinitionInterface $definition) {
return $definition->isTranslatable();
});
$field_names = array_map(function(FieldDefinitionInterface $definition) {
$field_names = array_map(function (FieldDefinitionInterface $definition) {
return $definition->getName();
}, $definitions);
$values[$this->langcodeKey] = $langcode;
......
......@@ -77,7 +77,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
// Potentially the #value is set directly, so it contains the 'target_id'
// array structure instead of a string.
if ($input !== FALSE && is_array($input)) {
$entity_ids = array_map(function(array $item) {
$entity_ids = array_map(function (array $item) {
return $item['target_id'];
}, $input);
......
......@@ -346,7 +346,7 @@ protected function buildBundleFieldDefinitions($entity_type_id, $bundle, array $
// Load base field overrides from configuration. These take precedence over
// base field overrides returned above.
$base_field_override_ids = array_map(function($field_name) use ($entity_type_id, $bundle) {
$base_field_override_ids = array_map(function ($field_name) use ($entity_type_id, $bundle) {
return $entity_type_id . '.' . $bundle . '.' . $field_name;
}, array_keys($base_field_definitions));
$base_field_overrides = $this->entityTypeManager->getStorage('base_field_override')->loadMultiple($base_field_override_ids);
......
......@@ -50,7 +50,7 @@ public function execute() {
foreach ($this->sort as $sort) {
$direction = $sort['direction'] == 'ASC' ? -1 : 1;
$field = $sort['field'];
uasort($result, function($a, $b) use ($field, $direction) {
uasort($result, function ($a, $b) use ($field, $direction) {
return ($a[$field] <= $b[$field]) ? $direction : -$direction;
});
}
......
......@@ -296,13 +296,13 @@ public function requiresDedicatedTableStorage(FieldStorageDefinitionInterface $s
*/
public function getDedicatedTableNames() {
$table_mapping = $this;
$definitions = array_filter($this->fieldStorageDefinitions, function($definition) use ($table_mapping) {
$definitions = array_filter($this->fieldStorageDefinitions, function ($definition) use ($table_mapping) {
return $table_mapping->requiresDedicatedTableStorage($definition);
});
$data_tables = array_map(function($definition) use ($table_mapping) {
$data_tables = array_map(function ($definition) use ($table_mapping) {
return $table_mapping->getDedicatedDataTableName($definition);
}, $definitions);
$revision_tables = array_map(function($definition) use ($table_mapping) {
$revision_tables = array_map(function ($definition) use ($table_mapping) {
return $table_mapping->getDedicatedRevisionTableName($definition);
}, $definitions);
$dedicated_tables = array_merge(array_values($data_tables), array_values($revision_tables));
......
......@@ -1529,7 +1529,7 @@ protected function createEntitySchemaIndexes(array $entity_schema, FieldStorageD
// involving them. Only indexes for which all columns exist are
// actually created.
$create = FALSE;
$specifier_columns = array_map(function($item) {
$specifier_columns = array_map(function ($item) {
return is_string($item) ? $item : reset($item);
}, $specifier);
if (!isset($column_names) || array_intersect($specifier_columns, $column_names)) {
......@@ -1580,7 +1580,7 @@ protected function deleteEntitySchemaIndexes(array $entity_schema_data, FieldSto
foreach ($index_keys as $key => $drop_method) {
if (!empty($schema[$key])) {
foreach ($schema[$key] as $name => $specifier) {
$specifier_columns = array_map(function($item) {
$specifier_columns = array_map(function ($item) {
return is_string($item) ? $item : reset($item);
}, $specifier);
if (!isset($column_names) || array_intersect($specifier_columns, $column_names)) {
......
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