Commit 4577185c authored by catch's avatar catch

Issue #2572791 by Mile23, andriyun, attiks, RoSk0: Fix...

Issue #2572791 by Mile23, andriyun, attiks, RoSk0: Fix 'Drupal.WhiteSpace.OpenBracketSpacing' coding standard
parent 7bf7cebe
......@@ -5,4 +5,4 @@
/**
* An exception class to be thrown for context plugin exceptions.
*/
class ContextException extends \Exception implements ExceptionInterface { }
class ContextException extends \Exception implements ExceptionInterface {}
......@@ -5,4 +5,4 @@
/**
* Exception interface for all exceptions thrown by the Plugin component.
*/
interface ExceptionInterface { }
interface ExceptionInterface {}
......@@ -8,4 +8,4 @@
* Exception thrown when a decorator's _call() method is triggered, but the
* decorated object does not contain the requested method.
*/
class InvalidDecoratedMethod extends BadMethodCallException implements ExceptionInterface { }
class InvalidDecoratedMethod extends BadMethodCallException implements ExceptionInterface {}
......@@ -5,4 +5,4 @@
/**
* Exception to be thrown if a plugin tries to use an invalid deriver.
*/
class InvalidDeriverException extends PluginException { }
class InvalidDeriverException extends PluginException {}
......@@ -8,4 +8,4 @@
* Extended interface for exceptions thrown specifically by the Mapper subsystem
* within the Plugin component.
*/
interface MapperExceptionInterface extends ExceptionInterface { }
interface MapperExceptionInterface extends ExceptionInterface {}
......@@ -6,4 +6,4 @@
* Generic Plugin exception class to be thrown when no more specific class
* is applicable.
*/
class PluginException extends \Exception implements ExceptionInterface { }
class PluginException extends \Exception implements ExceptionInterface {}
......@@ -12,4 +12,4 @@
*
* @ingroup block_api
*/
interface MessagesBlockPluginInterface extends BlockPluginInterface { }
interface MessagesBlockPluginInterface extends BlockPluginInterface {}
......@@ -452,7 +452,9 @@ protected function callOnDependencyRemoval(ConfigEntityInterface $entity, array
// Key the entity arrays by config dependency name to make searching easy.
foreach (['config', 'content'] as $dependency_type) {
$affected_dependencies[$dependency_type] = array_combine(
array_map(function ($entity) { return $entity->getConfigDependencyName(); }, $affected_dependencies[$dependency_type]),
array_map(function ($entity) {
return $entity->getConfigDependencyName();
}, $affected_dependencies[$dependency_type]),
$affected_dependencies[$dependency_type]
);
}
......
......@@ -187,7 +187,7 @@ public function __construct(\PDO $connection, array $connection_options) {
* @return \PDO
* A \PDO object.
*/
public static function open(array &$connection_options = []) { }
public static function open(array &$connection_options = []) {}
/**
* Destroys this Connection object.
......
......@@ -7,4 +7,4 @@
/**
* MySQL implementation of \Drupal\Core\Database\Query\Delete.
*/
class Delete extends QueryDelete { }
class Delete extends QueryDelete {}
......@@ -7,4 +7,4 @@
/**
* MySQL implementation of \Drupal\Core\Database\Query\Merge.
*/
class Merge extends QueryMerge { }
class Merge extends QueryMerge {}
......@@ -7,4 +7,4 @@
/**
* MySQL implementation of \Drupal\Core\Database\Query\Select.
*/
class Select extends QuerySelect { }
class Select extends QuerySelect {}
......@@ -7,4 +7,4 @@
/**
* MySQL implementation of \Drupal\Core\Database\Transaction.
*/
class Transaction extends DatabaseTransaction { }
class Transaction extends DatabaseTransaction {}
......@@ -7,4 +7,4 @@
/**
* MySQL implementation of \Drupal\Core\Database\Query\Truncate.
*/
class Truncate extends QueryTruncate { }
class Truncate extends QueryTruncate {}
......@@ -7,4 +7,4 @@
/**
* MySQL implementation of \Drupal\Core\Database\Query\Update.
*/
class Update extends QueryUpdate { }
class Update extends QueryUpdate {}
......@@ -128,7 +128,9 @@ 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) { return $this->connection->escapeField($f); }, $insert_fields);
$insert_fields = array_map(function($f) {
return $this->connection->escapeField($f);
}, $insert_fields);
// If we're selecting from a SelectQuery, finish building the query and
// pass it back, as any remaining options are irrelevant.
......
......@@ -254,7 +254,7 @@ public function initializeDatabase() {
\'SELECT random();\'
LANGUAGE \'sql\'',
[],
[ 'allow_delimiter_in_query' => TRUE ]
['allow_delimiter_in_query' => TRUE ]
);
}
......@@ -263,7 +263,7 @@ public function initializeDatabase() {
\'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\'
LANGUAGE \'sql\'',
[],
[ 'allow_delimiter_in_query' => TRUE ]
['allow_delimiter_in_query' => TRUE ]
);
}
$connection->query('SELECT pg_advisory_unlock(1)');
......
......@@ -7,4 +7,4 @@
/**
* PostgreSQL implementation of \Drupal\Core\Database\Query\Merge.
*/
class Merge extends QueryMerge { }
class Merge extends QueryMerge {}
......@@ -100,7 +100,9 @@ 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) { return $this->connection->escapeField($f); }, $insert_fields);
$insert_fields = array_map(function($f) {
return $this->connection->escapeField($f);
}, $insert_fields);
$query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';
......
......@@ -7,4 +7,4 @@
/**
* PostgreSQL implementation of \Drupal\Core\Database\Transaction.
*/
class Transaction extends DatabaseTransaction { }
class Transaction extends DatabaseTransaction {}
......@@ -7,4 +7,4 @@
/**
* SQLite implementation of \Drupal\Core\Database\Query\Delete.
*/
class Delete extends QueryDelete { }
class Delete extends QueryDelete {}
......@@ -7,4 +7,4 @@
/**
* SQLite implementation of \Drupal\Core\Database\Query\Merge.
*/
class Merge extends QueryMerge { }
class Merge extends QueryMerge {}
......@@ -7,4 +7,4 @@
/**
* SQLite implementation of \Drupal\Core\Database\Transaction.
*/
class Transaction extends DatabaseTransaction { }
class Transaction extends DatabaseTransaction {}
......@@ -7,4 +7,4 @@
/**
* SQLite implementation of \Drupal\Core\Database\Query\Update.
*/
class Update extends QueryUpdate { }
class Update extends QueryUpdate {}
......@@ -8,4 +8,4 @@
* This exception is thrown e.g. when trying to insert a row that would violate
* a unique key constraint.
*/
class IntegrityConstraintViolationException extends \RuntimeException implements DatabaseException { }
class IntegrityConstraintViolationException extends \RuntimeException implements DatabaseException {}
......@@ -8,4 +8,4 @@
* This exception is thrown e.g. when trying to have an IN condition with an
* empty array.
*/
class InvalidQueryException extends \InvalidArgumentException implements DatabaseException { }
class InvalidQueryException extends \InvalidArgumentException implements DatabaseException {}
......@@ -5,4 +5,4 @@
/**
* Base exception for Schema-related errors.
*/
class SchemaException extends \RuntimeException implements DatabaseException { }
class SchemaException extends \RuntimeException implements DatabaseException {}
......@@ -9,4 +9,4 @@
* modify a database table, field, or index that does not currently exist in
* the database schema.
*/
class SchemaObjectDoesNotExistException extends SchemaException implements DatabaseException { }
class SchemaObjectDoesNotExistException extends SchemaException implements DatabaseException {}
......@@ -9,4 +9,4 @@
* create a new database table, field, or index that already exists in the
* database schema.
*/
class SchemaObjectExistsException extends SchemaException implements DatabaseException { }
class SchemaObjectExistsException extends SchemaException implements DatabaseException {}
......@@ -5,4 +5,4 @@
/**
* Exception thrown when a commit() function fails.
*/
class TransactionCommitFailedException extends TransactionException implements DatabaseException { }
class TransactionCommitFailedException extends TransactionException implements DatabaseException {}
......@@ -5,4 +5,4 @@
/**
* Exception thrown by an error in a database transaction.
*/
class TransactionException extends \RuntimeException implements DatabaseException { }
class TransactionException extends \RuntimeException implements DatabaseException {}
......@@ -8,4 +8,4 @@
* This exception will be thrown when the PDO connection commit() is called.
* Code should never call this method directly.
*/
class TransactionExplicitCommitNotAllowedException extends TransactionException implements DatabaseException { }
class TransactionExplicitCommitNotAllowedException extends TransactionException implements DatabaseException {}
......@@ -5,4 +5,4 @@
/**
* Exception thrown when a savepoint or transaction name occurs twice.
*/
class TransactionNameNonUniqueException extends TransactionException implements DatabaseException { }
class TransactionNameNonUniqueException extends TransactionException implements DatabaseException {}
......@@ -5,4 +5,4 @@
/**
* Exception for when popTransaction() is called with no active transaction.
*/
class TransactionNoActiveException extends TransactionException implements DatabaseException { }
class TransactionNoActiveException extends TransactionException implements DatabaseException {}
......@@ -5,4 +5,4 @@
/**
* Exception thrown when a rollBack() resulted in other active transactions being rolled-back.
*/
class TransactionOutOfOrderException extends TransactionException implements DatabaseException { }
class TransactionOutOfOrderException extends TransactionException implements DatabaseException {}
......@@ -192,7 +192,7 @@ protected function _changed($orig, $closing) {
// Notice that WordLevelDiff returns HTML-escaped output. Hence, we will be
// calling addedLine/deletedLine without HTML-escaping.
while ($line = array_shift($del)) {
$aline = array_shift( $add );
$aline = array_shift($add );
$this->rows[] = array_merge($this->deletedLine($line), isset($aline) ? $this->addedLine($aline) : $this->emptyLine());
}
......
......@@ -916,7 +916,9 @@ public function getTranslationStatus($langcode) {
* {@inheritdoc}
*/
public function getTranslationLanguages($include_default = TRUE) {
$translations = array_filter($this->translations, function($translation) { return $translation['status']; });
$translations = array_filter($this->translations, function($translation) {
return $translation['status'];
});
unset($translations[LanguageInterface::LANGCODE_DEFAULT]);
if ($include_default) {
......
......@@ -153,8 +153,12 @@ 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) { return $definition->isTranslatable(); });
$field_names = array_map(function(FieldDefinitionInterface $definition) { return $definition->getName(); }, $definitions);
$definitions = array_filter($translation->getFieldDefinitions(), function(FieldDefinitionInterface $definition) {
return $definition->isTranslatable();
});
$field_names = array_map(function(FieldDefinitionInterface $definition) {
return $definition->getName();
}, $definitions);
$values[$this->langcodeKey] = $langcode;
$values[$this->getEntityType()->getKey('default_langcode')] = FALSE;
$this->initFieldValues($translation, $values, $field_names);
......@@ -165,32 +169,32 @@ public function createTranslation(ContentEntityInterface $entity, $langcode, arr
/**
* {@inheritdoc}
*/
public function onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $storage_definition) { }
public function onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $storage_definition) {}
/**
* {@inheritdoc}
*/
public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) { }
public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {}
/**
* {@inheritdoc}
*/
public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition) { }
public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition) {}
/**
* {@inheritdoc}
*/
public function onFieldDefinitionCreate(FieldDefinitionInterface $field_definition) { }
public function onFieldDefinitionCreate(FieldDefinitionInterface $field_definition) {}
/**
* {@inheritdoc}
*/
public function onFieldDefinitionUpdate(FieldDefinitionInterface $field_definition, FieldDefinitionInterface $original) { }
public function onFieldDefinitionUpdate(FieldDefinitionInterface $field_definition, FieldDefinitionInterface $original) {}
/**
* {@inheritdoc}
*/
public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition) { }
public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition) {}
/**
* {@inheritdoc}
......@@ -234,7 +238,7 @@ public function purgeFieldData(FieldDefinitionInterface $field_definition, $batc
/**
* {@inheritdoc}
*/
public function finalizePurge(FieldStorageDefinitionInterface $storage_definition) { }
public function finalizePurge(FieldStorageDefinitionInterface $storage_definition) {}
/**
* {@inheritdoc}
......
......@@ -5,4 +5,4 @@
/**
* Defines an exception thrown when a malformed entity is passed.
*/
class EntityMalformedException extends \Exception { }
class EntityMalformedException extends \Exception {}
......@@ -81,17 +81,17 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { }
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { }
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
/**
* {@inheritdoc}
*/
public function entityQueryAlter(SelectInterface $query) { }
public function entityQueryAlter(SelectInterface $query) {}
/**
* Moves the backward compatibility level configurations in the right place.
......
......@@ -5,4 +5,4 @@
/**
* Defines an exception thrown when storage operations fail.
*/
class EntityStorageException extends \Exception { }
class EntityStorageException extends \Exception {}
......@@ -337,7 +337,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
* @param string $view_mode
* The view mode that should be used to prepare the entity.
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { }
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {}
/**
* {@inheritdoc}
......
......@@ -5,4 +5,4 @@
/**
* Defines an exception thrown when an entity ID is too long.
*/
class EntityTypeIdLengthException extends \Exception { }
class EntityTypeIdLengthException extends \Exception {}
......@@ -5,4 +5,4 @@
/**
* Defines an exception thrown when an entity type definition is invalid.
*/
class UnsupportedEntityTypeDefinitionException extends \Exception { }
class UnsupportedEntityTypeDefinitionException extends \Exception {}
......@@ -46,7 +46,7 @@ class EntityAdapter extends TypedData implements \IteratorAggregate, ComplexData
public static function createFromEntity(EntityInterface $entity) {
$definition = EntityDataDefinition::create()
->setEntityTypeId($entity->getEntityTypeId())
->setBundles([ $entity->bundle() ]);
->setBundles([$entity->bundle() ]);
$instance = new static($definition);
$instance->setValue($entity);
return $instance;
......
......@@ -6,4 +6,4 @@
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Use \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection
*/
class SelectionBase extends DefaultSelection { }
class SelectionBase extends DefaultSelection {}
......@@ -9,4 +9,4 @@
* conditions, and will raise a QueryException when an unsupported
* condition was specified.
*/
class QueryException extends \Exception { }
class QueryException extends \Exception {}
......@@ -296,9 +296,15 @@ public function requiresDedicatedTableStorage(FieldStorageDefinitionInterface $s
*/
public function getDedicatedTableNames() {
$table_mapping = $this;
$definitions = array_filter($this->fieldStorageDefinitions, function($definition) use ($table_mapping) { return $table_mapping->requiresDedicatedTableStorage($definition); });
$data_tables = array_map(function($definition) use ($table_mapping) { return $table_mapping->getDedicatedDataTableName($definition); }, $definitions);
$revision_tables = array_map(function($definition) use ($table_mapping) { return $table_mapping->getDedicatedRevisionTableName($definition); }, $definitions);
$definitions = array_filter($this->fieldStorageDefinitions, function($definition) use ($table_mapping) {
return $table_mapping->requiresDedicatedTableStorage($definition);
});
$data_tables = array_map(function($definition) use ($table_mapping) {
return $table_mapping->getDedicatedDataTableName($definition);
}, $definitions);
$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));
return $dedicated_tables;
}
......
......@@ -1540,12 +1540,12 @@ public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definiti
/**
* {@inheritdoc}
*/
public function onBundleCreate($bundle, $entity_type_id) { }
public function onBundleCreate($bundle, $entity_type_id) {}
/**
* {@inheritdoc}
*/
public function onBundleDelete($bundle, $entity_type_id) { }
public function onBundleDelete($bundle, $entity_type_id) {}
/**
* {@inheritdoc}
......
......@@ -1529,7 +1529,9 @@ 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) { return is_string($item) ? $item : reset($item); }, $specifier);
$specifier_columns = array_map(function($item) {
return is_string($item) ? $item : reset($item);
}, $specifier);
if (!isset($column_names) || array_intersect($specifier_columns, $column_names)) {
$create = TRUE;
foreach ($specifier_columns as $specifier_column_name) {
......@@ -1578,7 +1580,9 @@ 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) { return is_string($item) ? $item : reset($item); }, $specifier);
$specifier_columns = array_map(function($item) {
return is_string($item) ? $item : reset($item);
}, $specifier);
if (!isset($column_names) || array_intersect($specifier_columns, $column_names)) {
$schema_handler->{$drop_method}($table_name, $name);
}
......
......@@ -346,7 +346,9 @@ protected function copyData(array &$sandbox) {
* An array of updated field storage definitions.
*/
protected function updateFieldStorageDefinitionsToRevisionable(ContentEntityTypeInterface $entity_type, array $storage_definitions, array $fields_to_update = [], $update_cached_definitions = TRUE) {
$updated_storage_definitions = array_map(function ($storage_definition) { return clone $storage_definition; }, $storage_definitions);
$updated_storage_definitions = array_map(function ($storage_definition) {
return clone $storage_definition;
}, $storage_definitions);
// Update the 'langcode' field manually, as it is configured in the base
// content entity field definitions.
......
......@@ -5,4 +5,4 @@
/**
* Exception thrown when the extension's name length exceeds the allowed maximum.
*/
class ExtensionNameLengthException extends \Exception { }
class ExtensionNameLengthException extends \Exception {}
......@@ -5,4 +5,4 @@
/**
* Defines an exception thrown when uninstalling a module that did not validate.
*/
class ModuleUninstallValidatorException extends \InvalidArgumentException { }
class ModuleUninstallValidatorException extends \InvalidArgumentException {}
......@@ -191,27 +191,27 @@ public function view($display_options = []) {
/**
* {@inheritdoc}
*/
public function preSave() { }
public function preSave() {}
/**
* {@inheritdoc}
*/
public function postSave($update) { }
public function postSave($update) {}
/**
* {@inheritdoc}
*/
public function delete() { }
public function delete() {}
/**
* {@inheritdoc}
*/
public static function generateSampleValue(FieldDefinitionInterface $field_definition) { }
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {}
/**
* {@inheritdoc}
*/
public function deleteRevision() { }
public function deleteRevision() {}
/**
* {@inheritdoc}
......
......@@ -125,7 +125,7 @@ public function settingsSummary() {
/**
* {@inheritdoc}
*/
public function prepareView(array $entities_items) { }
public function prepareView(array $entities_items) {}
/**
* Returns the array of field settings.
......
......@@ -193,6 +193,6 @@ protected function sanitizeLabel(&$label) {
* @return string|null
* Either a label of the empty option, or NULL.
*/
protected function getEmptyLabel() { }
protected function getEmptyLabel() {}
}
......@@ -73,7 +73,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { }
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
/**
* {@inheritdoc}
......
......@@ -59,17 +59,17 @@ public function getAll() {
/**
* {@inheritdoc}
*/
public function set($key, $value) { }
public function set($key, $value) {}
/**
* {@inheritdoc}
*/
public function setIfNotExists($key, $value) { }
public function setIfNotExists($key, $value) {}
/**
* {@inheritdoc}
*/
public function setMultiple(array $data) { }
public function setMultiple(array $data) {}
/**
* {@inheritdoc}
......@@ -80,17 +80,17 @@ public function rename($key, $new_key) {
/**
* {@inheritdoc}
*/
public function delete($key) { }
public function delete($key) {}
/**
* {@inheritdoc}
*/
public function deleteMultiple(array $keys) { }
public function deleteMultiple(array $keys) {}
/**
* {@inheritdoc}
*/
public function deleteAll() { }
public function deleteAll() {}
/**
* {@inheritdoc}
......@@ -102,16 +102,16 @@ public function getCollectionName() {
/**
* {@inheritdoc}
*/
public function setMultipleWithExpire(array $data, $expire) { }
public function setMultipleWithExpire(array $data, $expire) {}
/**
* {@inheritdoc}
*/
public function setWithExpire($key, $value, $expire) { }