Issue #2937853 by idebr, mfernea, SherFengChong, alexpott, borisson_: Fix 'Drupal.Formatting.MultipleStatementAlignment' coding standard

8.7.x
Alex Pott 2018-08-13 11:13:36 +01:00
parent 500403b458
commit 6c40e077ef
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
41 changed files with 49 additions and 48 deletions

View File

@ -1371,9 +1371,9 @@ function template_preprocess_page(&$variables) {
}
}
$variables['base_path'] = base_path();
$variables['front_page'] = \Drupal::url('<front>');
$variables['language'] = $language_interface;
$variables['base_path'] = base_path();
$variables['front_page'] = \Drupal::url('<front>');
$variables['language'] = $language_interface;
// An exception might be thrown.
try {

View File

@ -41,7 +41,7 @@ class DateTimePlus {
use ToStringTrait;
const FORMAT = 'Y-m-d H:i:s';
const FORMAT = 'Y-m-d H:i:s';
/**
* A RFC7231 Compliant date.

View File

@ -189,7 +189,7 @@ class CssOptimizer implements AssetOptimizerInterface {
if ($optimize) {
// Perform some safe CSS optimizations.
// Regexp to match comment blocks.
$comment = '/\*[^*]*\*+(?:[^/*][^*]*\*+)*/';
$comment = '/\*[^*]*\*+(?:[^/*][^*]*\*+)*/';
// Regexp to match double quoted strings.
$double_quot = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
// Regexp to match single quoted strings.

View File

@ -74,7 +74,7 @@ class DatabaseBackendFactory implements CacheFactoryInterface {
$max_rows_settings = $this->settings->get('database_cache_max_rows');
// First, look for a cache bin specific setting.
if (isset($max_rows_settings['bins'][$bin])) {
$max_rows = $max_rows_settings['bins'][$bin];
$max_rows = $max_rows_settings['bins'][$bin];
}
// Second, use configured default backend.
elseif (isset($max_rows_settings['default'])) {

View File

@ -145,7 +145,7 @@ class DbDumpCommand extends DbCommandBase {
$name = $row['Field'];
// Parse out the field type and meta information.
preg_match('@([a-z]+)(?:\((\d+)(?:,(\d+))?\))?\s*(unsigned)?@', $row['Type'], $matches);
$type = $this->fieldTypeMap($connection, $matches[1]);
$type = $this->fieldTypeMap($connection, $matches[1]);
if ($row['Extra'] === 'auto_increment') {
// If this is an auto increment, then the type is 'serial'.
$type = 'serial';

View File

@ -70,8 +70,8 @@ class Datetime extends DateElementBase {
*/
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
if ($input !== FALSE) {
$date_input = $element['#date_date_element'] != 'none' && !empty($input['date']) ? $input['date'] : '';
$time_input = $element['#date_time_element'] != 'none' && !empty($input['time']) ? $input['time'] : '';
$date_input = $element['#date_date_element'] != 'none' && !empty($input['date']) ? $input['date'] : '';
$time_input = $element['#date_time_element'] != 'none' && !empty($input['time']) ? $input['time'] : '';
$date_format = $element['#date_date_element'] != 'none' ? static::getHtml5DateFormat($element) : '';
$time_format = $element['#date_time_element'] != 'none' ? static::getHtml5TimeFormat($element) : '';
$timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : NULL;

View File

@ -401,7 +401,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
* {@inheritdoc}
*/
public function reset() {
$this->routes = [];
$this->routes = [];
$this->serializedRoutes = [];
$this->cacheTagInvalidator->invalidateTags(['routes']);
}

View File

@ -28,7 +28,7 @@ class ActionListTest extends BrowserTestBase {
// Ensure the empty text appears on the action list page.
/** @var $storage \Drupal\Core\Entity\EntityStorageInterface */
$storage = $this->container->get('entity.manager')->getStorage('action');
$actions = $storage->loadMultiple();
$actions = $storage->loadMultiple();
$storage->delete($actions);
$this->drupalGet('/admin/config/system/actions');
$this->assertRaw('There are no actions yet.');

View File

@ -179,7 +179,7 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
// Comment related URLs.
case 'url':
$url_options['fragment'] = 'comment-' . $comment->id();
$url_options['fragment'] = 'comment-' . $comment->id();
$replacements[$original] = $comment->url('canonical', $url_options);
break;

View File

@ -235,7 +235,7 @@ class CommentViewsData extends EntityViewsData {
// Define the base group of this table. Fields that don't have a group defined
// will go into this field by default.
$data['comment_entity_statistics']['table']['group'] = $this->t('Comment Statistics');
$data['comment_entity_statistics']['table']['group'] = $this->t('Comment Statistics');
// Provide a relationship for each entity type except comment.
foreach ($entities_types as $type => $entity_type) {

View File

@ -413,7 +413,7 @@ class DbLogController extends ControllerBase {
}
}
$build['dblog_top_table'] = [
$build['dblog_top_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,

View File

@ -65,7 +65,7 @@ class FileViewsData extends EntityViewsData {
$data['file_managed']['uid']['relationship']['title'] = $this->t('User who uploaded');
$data['file_managed']['uid']['relationship']['label'] = $this->t('User who uploaded');
$data['file_usage']['table']['group'] = $this->t('File Usage');
$data['file_usage']['table']['group'] = $this->t('File Usage');
// Provide field-type-things to several base tables; on the core files table
// ("file_managed") so that we can create relationships from files to

View File

@ -62,7 +62,7 @@ class DownloadTest extends FileManagedTestBase {
$file->setPermanent();
$file->save();
$url = file_create_url($file->getFileUri());
$url = file_create_url($file->getFileUri());
// Set file_test access header to allow the download.
file_test_set_return('download', ['x-foo' => 'Bar']);

View File

@ -77,7 +77,7 @@ class ForumForm extends TermForm {
$status = $term_storage->save($term);
$route_name = $this->urlStub == 'container' ? 'entity.taxonomy_term.forum_edit_container_form' : 'entity.taxonomy_term.forum_edit_form';
$route_parameters = ['taxonomy_term' => $term->id()];
$route_parameters = ['taxonomy_term' => $term->id()];
$link = $this->l($this->t('Edit'), new Url($route_name, $route_parameters));
$view_link = $term->link($term->getName());
switch ($status) {

View File

@ -27,7 +27,7 @@ define('HISTORY_READ_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
function history_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.history':
$output = '<h3>' . t('About') . '</h3>';
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The History module keeps track of which content a user has read. It marks content as <em>new</em> or <em>updated</em> depending on the last time the user viewed it. History records that are older than one month are removed during cron, which means that content older than one month is always considered <em>read</em>. The History module does not have a user interface but it provides a filter to <a href=":views-help">Views</a> to show new or updated content. For more information, see the <a href=":url">online documentation for the History module</a>.', [':views-help' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', ['name' => 'views']) : '#', ':url' => 'https://www.drupal.org/documentation/modules/history']) . '</p>';
return $output;
}

View File

@ -14,7 +14,7 @@ function history_views_data() {
// We're actually defining a specific instance of the table, so let's
// alias it so that we can later add the real table for other purposes if we
// need it.
$data['history']['table']['group'] = t('Content');
$data['history']['table']['group'] = t('Content');
// Explain how this table joins to others.
$data['history']['table']['join'] = [

View File

@ -161,7 +161,7 @@ function locale_translation_default_translation_server() {
// An additional check is required here. During the upgrade process
// \Drupal::config()->get() returns NULL. We use the defined value as
// fallback.
$pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN;
$pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN;
return [
'pattern' => $pattern,

View File

@ -662,7 +662,7 @@ class MenuUiTest extends BrowserTestBase {
$this->drupalPostForm("admin/structure/menu/manage/{$this->menu->id()}/add", $edit, t('Save'));
$menu_links = entity_load_multiple_by_properties('menu_link_content', ['title' => $title]);
$last_link = reset($menu_links);
$created_links[] = 'tools:' . $last_link->getPluginId();
$created_links[] = 'tools:' . $last_link->getPluginId();
}
// The last link cannot be a parent in the new menu link form.

View File

@ -83,7 +83,7 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
// This gets rid of migrations which try to use a non-existent source
// plugin. The common case for this is if the source plugin has, or
// specifies, a non-existent provider.
$only_with_source_discovery = new NoSourcePluginDecorator($yaml_discovery);
$only_with_source_discovery = new NoSourcePluginDecorator($yaml_discovery);
// This gets rid of migrations with explicit providers set if one of the
// providers do not exist before we try to use a potentially non-existing
// deriver. This is a rare case.

View File

@ -124,7 +124,7 @@ class NodeTypeForm extends BundleEntityFormBase {
DRUPAL_REQUIRED => t('Required'),
],
];
$form['submission']['help'] = [
$form['submission']['help'] = [
'#type' => 'textarea',
'#title' => t('Explanation or submission guidelines'),
'#default_value' => $type->getHelp(),

View File

@ -280,7 +280,7 @@ class NodeViewsData extends EntityViewsData {
// Define the base group of this table. Fields that don't have a group defined
// will go into this field by default.
$data['node_access']['table']['group'] = $this->t('Content access');
$data['node_access']['table']['group'] = $this->t('Content access');
// For other base tables, explain how we join.
$data['node_access']['table']['join'] = [

View File

@ -789,7 +789,7 @@ abstract class EntityResourceTestBase extends ResourceTestBase {
// Try with all of the following request bodies.
$unparseable_request_body = '!{>}<';
$parseable_valid_request_body = $this->serializer->encode($this->getNormalizedPostEntity(), static::$format);
$parseable_valid_request_body = $this->serializer->encode($this->getNormalizedPostEntity(), static::$format);
$parseable_valid_request_body_2 = $this->serializer->encode($this->getSecondNormalizedPostEntity(), static::$format);
$parseable_invalid_request_body = $this->serializer->encode($this->makeNormalizationInvalid($this->getNormalizedPostEntity(), 'label'), static::$format);
$parseable_invalid_request_body_2 = $this->serializer->encode($this->getNormalizedPostEntity() + ['uuid' => [$this->randomMachineName(129)]], static::$format);
@ -1018,9 +1018,9 @@ abstract class EntityResourceTestBase extends ResourceTestBase {
$has_canonical_url = $this->entity->hasLinkTemplate('canonical');
// Try with all of the following request bodies.
$unparseable_request_body = '!{>}<';
$parseable_valid_request_body = $this->serializer->encode($this->getNormalizedPatchEntity(), static::$format);
$parseable_valid_request_body_2 = $this->serializer->encode($this->getNormalizedPatchEntity(), static::$format);
$unparseable_request_body = '!{>}<';
$parseable_valid_request_body = $this->serializer->encode($this->getNormalizedPatchEntity(), static::$format);
$parseable_valid_request_body_2 = $this->serializer->encode($this->getNormalizedPatchEntity(), static::$format);
$parseable_invalid_request_body = $this->serializer->encode($this->makeNormalizationInvalid($this->getNormalizedPatchEntity(), 'label'), static::$format);
$parseable_invalid_request_body_2 = $this->serializer->encode($this->getNormalizedPatchEntity() + ['field_rest_test' => [['value' => $this->randomString()]]], static::$format);
// The 'field_rest_test' field does not allow 'view' access, so does not end

View File

@ -29,7 +29,7 @@ class TextItemSillyNormalizer extends FieldItemNormalizer {
*/
protected function constructValue($data, $context) {
$value = parent::constructValue($data, $context);
$value['value'] = str_replace('::silly_suffix', '', $value['value']);
$value['value'] = str_replace('::silly_suffix', '', $value['value']);
return $value;
}

View File

@ -9,7 +9,7 @@
* Implements hook_views_data().
*/
function statistics_views_data() {
$data['node_counter']['table']['group'] = t('Content statistics');
$data['node_counter']['table']['group'] = t('Content statistics');
$data['node_counter']['table']['join'] = [
'node_field_data' => [

View File

@ -187,7 +187,7 @@ class SystemController extends ControllerBase {
uasort($themes, 'system_sort_modules_by_info_name');
$theme_default = $config->get('default');
$theme_groups = ['installed' => [], 'uninstalled' => []];
$theme_groups = ['installed' => [], 'uninstalled' => []];
$admin_theme = $config->get('admin');
$admin_theme_options = [];

View File

@ -99,7 +99,7 @@ function entity_test_update_entity_presave(EntityInterface $entity) {
*/
function _entity_test_update_create_test_entities($start = 1, $end = 50, $add_translation = FALSE) {
for ($i = $start; $i <= $end; $i++) {
$entity = EntityTestUpdate::create([
$entity = EntityTestUpdate::create([
'id' => $i,
'name' => $i,
'test_single_property' => $i . ' - test single property',

View File

@ -27,7 +27,7 @@ class StatusTest extends BrowserTestBase {
// Unset the sync directory in settings.php to trigger $config_directories
// error.
$settings['config_directories'] = [
$settings['config_directories'] = [
CONFIG_SYNC_DIRECTORY => (object) [
'value' => '',
'required' => TRUE,

View File

@ -133,7 +133,7 @@ class TermViewsData extends EntityViewsData {
],
];
$data['taxonomy_index']['table']['group'] = $this->t('Taxonomy term');
$data['taxonomy_index']['table']['group'] = $this->t('Taxonomy term');
$data['taxonomy_index']['table']['join'] = [
'taxonomy_term_field_data' => [

View File

@ -82,7 +82,7 @@ class Roles extends PrerenderList {
$ordered_roles = array_flip(array_keys($roles));
foreach ($this->items as &$user_roles) {
// Create an array of rids that the user has in the role weight order.
$sorted_keys = array_intersect_key($ordered_roles, $user_roles);
$sorted_keys = array_intersect_key($ordered_roles, $user_roles);
// Merge with the unsorted array of role information which has the
// effect of sorting it.
$user_roles = array_merge($sorted_keys, $user_roles);

View File

@ -491,7 +491,7 @@ function template_preprocess_username(&$variables) {
// unsanitized version, in case other preprocess functions want to implement
// their own shortening logic or add markup. If they do so, they must ensure
// that $variables['name'] is safe for printing.
$name = $account->getDisplayName();
$name = $account->getDisplayName();
$variables['name_raw'] = $account->getUsername();
if (mb_strlen($name) > 20) {
$name = Unicode::truncate($name, 15, FALSE, TRUE);

View File

@ -140,7 +140,7 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
// Overrides for standard stuff.
$options['style']['contains']['type']['default'] = 'rss';
$options['style']['contains']['options']['default'] = ['description' => ''];
$options['style']['contains']['options']['default'] = ['description' => ''];
$options['sitename_title']['default'] = FALSE;
$options['row']['contains']['type']['default'] = 'rss_fields';
$options['defaults']['default']['style'] = FALSE;

View File

@ -1513,7 +1513,7 @@ class Sql extends QueryPluginBase {
if (!empty($this->limit) || !empty($this->offset)) {
// We can't have an offset without a limit, so provide a very large limit instead.
$limit = intval(!empty($this->limit) ? $this->limit : 999999);
$limit = intval(!empty($this->limit) ? $this->limit : 999999);
$offset = intval(!empty($this->offset) ? $this->offset : 0);
$query->range($offset, $limit);
}

View File

@ -176,7 +176,7 @@ class EntityViewsDataTest extends UnitTestCase {
->setSetting('max_length', 255);
// A base field with cardinality > 1
$base_fields['string'] = BaseFieldDefinition::create('string')
$base_fields['string'] = BaseFieldDefinition::create('string')
->setLabel('Strong')
->setTranslatable(TRUE)
->setCardinality(2);

View File

@ -811,7 +811,7 @@ function template_preprocess_views_view_unformatted(&$variables) {
* - view: A View object.
*/
function template_preprocess_views_view_list(&$variables) {
$handler = $variables['view']->style_plugin;
$handler = $variables['view']->style_plugin;
// Fetch classes from handler options.
if ($handler->options['class']) {
@ -844,7 +844,7 @@ function template_preprocess_views_view_list(&$variables) {
* - rows: The raw row data.
*/
function template_preprocess_views_view_rss(&$variables) {
$view = $variables['view'];
$view = $variables['view'];
$items = $variables['rows'];
$style = $view->style_plugin;
@ -945,7 +945,7 @@ function template_preprocess_views_view_row_rss(&$variables) {
* - rows: The raw row data.
*/
function template_preprocess_views_view_opml(&$variables) {
$view = $variables['view'];
$view = $variables['view'];
$items = $variables['rows'];
$config = \Drupal::config('system.site');

View File

@ -99,6 +99,7 @@
<rule ref="Drupal.Files.FileEncoding"/>
<rule ref="Drupal.Files.TxtFileLineLength"/>
<rule ref="Drupal.Formatting.MultiLineAssignment"/>
<rule ref="Drupal.Formatting.MultipleStatementAlignment"/>
<rule ref="Drupal.Formatting.SpaceInlineIf"/>
<rule ref="Drupal.Formatting.SpaceUnaryOperator"/>
<rule ref="Drupal.Functions.DiscouragedFunctions"/>

View File

@ -58,8 +58,8 @@ EOF;
exit;
}
// define default settings
$cmd = 'index.php';
// define default settings
$_SERVER['HTTP_HOST'] = 'default';
$_SERVER['PHP_SELF'] = '/index.php';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';

View File

@ -17,7 +17,7 @@ if (PHP_SAPI !== 'cli') {
}
if (version_compare(PHP_VERSION, '5.4.5') < 0) {
$version = PHP_VERSION;
$version = PHP_VERSION;
echo <<<EOF
ERROR: This script requires at least PHP version 5.4.5. You invoked it with

View File

@ -204,7 +204,7 @@ class AttachedAssetsTest extends KernelTestBase {
$end = strrpos($rendered_js, $endToken);
// Convert to a string, as $renderer_js is a \Drupal\Core\Render\Markup
// object.
$json = mb_substr($rendered_js, $start, $end - $start + 1);
$json = mb_substr($rendered_js, $start, $end - $start + 1);
$parsed_settings = Json::decode($json);
// Test whether the settings for core/drupalSettings are available.

View File

@ -31,7 +31,7 @@ class ToolkitGdTest extends KernelTestBase {
protected $white = [255, 255, 255, 0];
protected $transparent = [0, 0, 0, 127];
// Used as rotate background colors.
protected $fuchsia = [255, 0, 255, 0];
protected $fuchsia = [255, 0, 255, 0];
protected $rotateTransparent = [255, 255, 255, 127];
protected $width = 40;

View File

@ -31,7 +31,7 @@ class AnnotatedClassDiscoveryCachedTest extends TestCase {
*/
public function testGetDefinitions() {
// Path to the classes which we'll discover and parse annotation.
$discovery_path = __DIR__ . '/Fixtures';
$discovery_path = __DIR__ . '/Fixtures';
// File path that should be discovered within that directory.
$file_path = $discovery_path . '/PluginNamespace/DiscoveryTest1.php';

View File

@ -61,7 +61,7 @@ class ArgumentsResolverTest extends TestCase {
// Test with a raw value that overrides the provided upcast value, since
// it is not typehinted.
$scalars = ['foo' => 'baz'];
$scalars = ['foo' => 'baz'];
$objects = ['foo' => new \stdClass()];
$data[] = [
function ($foo) {}, $scalars, $objects, [], ['baz'],