diff -u b/core/modules/views/src/Plugin/views/filter/Compare.php b/core/modules/views/src/Plugin/views/filter/Compare.php --- b/core/modules/views/src/Plugin/views/filter/Compare.php +++ b/core/modules/views/src/Plugin/views/filter/Compare.php @@ -101,7 +101,12 @@ * {@inheritdoc} */ public function adminSummary() { - return new FormattableMarkup('@left_field @operator @right_field', ['@left_field' => $this->options['left_field'], '@operator' => $this->options['operator'], '@right_field' => $this->options['right_field']]); + return new FormattableMarkup('@left_field @operator @right_field', [ + '@left_field' => $this->options['left_field'], + '@operator' => $this->options['operator'], + '@right_field' => $this->options['right_field'], + ] + ); } /** @@ -122,13 +127,13 @@ } // Get the left table and field. - /** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $left_handler */ + /** @var FilterPluginBase $left_handler */ $left_handler = $field_handlers[$left]; $left_handler->setRelationship(); $left_table_alias = $this->query->ensureTable($left_handler->table, $left_handler->relationship); // Get the right table and field. - /** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $right_handler */ + /** @var FilterPluginBase $right_handler */ $right_handler = $field_handlers[$right]; $right_handler->setRelationship(); $right_table_alias = $this->query->ensureTable($right_handler->table, $right_handler->relationship); diff -u b/core/modules/views/tests/src/Kernel/Handler/FilterCompareTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterCompareTest.php --- b/core/modules/views/tests/src/Kernel/Handler/FilterCompareTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FilterCompareTest.php @@ -16,7 +16,7 @@ /** * The column map used in the test. * - * @var array + * @var array|string[] */ protected $columnMap = [ 'views_test_data_name' => 'name', @@ -25,12 +25,15 @@ /** * Views used by this test. * - * @var array + * @var array|string[] */ public static $testViews = ['test_filter_compare']; /** - * {@inheritdoc} + * Returns a very simple test dataset. + * + * @returns array + * dataset value array. */ protected function dataSet() { // Setup age/created so comparing fields can be tested. @@ -48,7 +51,7 @@ /** * Tests the compare handler. */ - public function testCompare() { + public function testCompare() : void { $view = Views::getView('test_filter_compare'); // Test the equality operator. @@ -103,7 +106,7 @@ ]; foreach ($tests as $parts) { - list($operator, $expected) = $parts; + [$operator, $expected] = $parts; $view->initDisplay(); $item = $view->getHandler('default', 'filter', 'fields_compare'); diff -u b/core/modules/views/views.views.inc b/core/modules/views/views.views.inc --- b/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -1,10 +1,12 @@ [], + '#global' => [], ]; $data['views']['random'] = [ - 'title' => t('Random'), - 'help' => t('Randomize the display order.'), - 'sort' => [ - 'id' => 'random', + 'title' => t('Random'), + 'help' => t('Randomize the display order.'), + 'sort' => [ + 'id' => 'random', ], ]; @@ -116,7 +118,7 @@ ]; $data['views']['combine'] = [ - 'title' => t('Combine fields filter'), + 'title' => t('Combine fields filter'), 'help' => t('Combine multiple fields together and search by them.'), 'filter' => [ 'id' => 'combine', @@ -183,7 +185,7 @@ // Registers views data for the entity itself. foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->hasHandlerClass('views_data')) { - /** @var \Drupal\views\EntityViewsDataInterface $views_data */ + /** @var EntityViewsDataInterface $views_data */ $views_data = \Drupal::entityTypeManager()->getHandler($entity_type_id, 'views_data'); $data = NestedArray::mergeDeep($data, $views_data->getViewsData()); } @@ -195,7 +197,7 @@ $entity_type_manager = \Drupal::entityTypeManager(); if ($entity_type_manager->hasDefinition('field_storage_config')) { - /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ + /** @var FieldStorageConfigInterface $field_storage */ foreach ($entity_type_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) { if (_views_field_get_entity_type_storage($field_storage)) { $result = (array) $module_handler->invoke($field_storage->getTypeProvider(), 'field_views_data', [$field_storage]); @@ -227,7 +229,7 @@ if (!$entity_type_manager->hasDefinition('field_storage_config')) { return; } - /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ + /** @var FieldStorageConfigInterface $field_storage */ foreach ($entity_type_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) { if (_views_field_get_entity_type_storage($field_storage)) { $function = $field_storage->getTypeProvider() . '_field_views_data_views_data_alter'; @@ -241,10 +243,10 @@ /** * Determines whether the entity type the field appears in is SQL based. * - * @param \Drupal\field\FieldStorageConfigInterface $field_storage + * @param FieldStorageConfigInterface $field_storage * The field storage definition. * - * @return \Drupal\Core\Entity\Sql\SqlContentEntityStorage + * @return SqlContentEntityStorage * Returns the entity type storage if supported. */ function _views_field_get_entity_type_storage(FieldStorageConfigInterface $field_storage) { @@ -297,7 +299,7 @@ /** * Default views data implementation for a field. * - * @param \Drupal\field\FieldStorageConfigInterface $field_storage + * @param FieldStorageConfigInterface $field_storage * The field definition. * * @return array @@ -358,6 +360,7 @@ // @todo Generalize this code to make it work with any table layout. See // https://www.drupal.org/node/2079019. $table_mapping = $storage->getTableMapping(); + assert($table_mapping instanceof DefaultTableMapping); $field_tables = [ EntityStorageInterface::FIELD_LOAD_CURRENT => [ 'table' => $table_mapping->getDedicatedDataTableName($field_storage), @@ -549,9 +552,17 @@ 'base' => $base_table, 'group' => $group_name, 'title' => $label_name, - 'help' => t('This is an alias of @group: @field.', ['@group' => $group_name, '@field' => $label]), + 'help' => t('This is an alias of @group: @field.', [ + '@group' => $group_name, + '@field' => $label, + ] + ), ]; - $also_known[] = t('@group: @field', ['@group' => $group_name, '@field' => $label_name]); + $also_known[] = t('@group: @field', [ + '@group' => $group_name, + '@field' => $label_name, + ] + ); } } elseif ($supports_revisions && $label != $label_name) { @@ -559,9 +570,17 @@ 'base' => $table, 'group' => t('@group (historical data)', ['@group' => $group_name]), 'title' => $label_name, - 'help' => t('This is an alias of @group: @field.', ['@group' => $group_name, '@field' => $label]), + 'help' => t('This is an alias of @group: @field.', [ + '@group' => $group_name, + '@field' => $label, + ] + ), ]; - $also_known[] = t('@group (historical data): @field', ['@group' => $group_name, '@field' => $label_name]); + $also_known[] = t('@group (historical data): @field', [ + '@group' => $group_name, + '@field' => $label_name, + ] + ); } } if ($aliases) { @@ -598,7 +617,7 @@ foreach ($field_columns as $column => $attributes) { $allow_sort = TRUE; - // Identify likely filters and arguments for each column based on field type. + // Identify likely filters & arguments for each column based on field type. switch ($attributes['type']) { case 'int': case 'mediumint': @@ -630,8 +649,17 @@ $title_short = $label; } else { - $title = t('@label (@name:@column)', ['@label' => $label, '@name' => $field_name, '@column' => $column]); - $title_short = t('@label:@column', ['@label' => $label, '@column' => $column]); + $title = t('@label (@name:@column)', [ + '@label' => $label, + '@name' => $field_name, + '@column' => $column, + ] + ); + $title_short = t('@label:@column', [ + '@label' => $label, + '@column' => $column, + ] + ); } // Expose data for the property. @@ -657,24 +685,41 @@ 'help' => t('Appears in: @bundles.', ['@bundles' => implode(', ', $bundles_names)]), ]; - // Go through and create a list of aliases for all possible combinations of - // entity type + name. + // Go through and create a list of aliases for all possible + // combinations of entity type + name. $aliases = []; $also_known = []; foreach ($all_labels as $label_name => $true) { if ($label != $label_name) { if (count($field_columns) == 1 || $column == 'value') { - $alias_title = t('@label (@name)', ['@label' => $label_name, '@name' => $field_name]); + $alias_title = t('@label (@name)', [ + '@label' => $label_name, + '@name' => $field_name, + ] + ); } else { - $alias_title = t('@label (@name:@column)', ['@label' => $label_name, '@name' => $field_name, '@column' => $column]); + $alias_title = t('@label (@name:@column)', [ + '@label' => $label_name, + '@name' => $field_name, + '@column' => $column, + ] + ); } $aliases[] = [ 'group' => $group_name, 'title' => $alias_title, - 'help' => t('This is an alias of @group: @field.', ['@group' => $group_name, '@field' => $title]), + 'help' => t('This is an alias of @group: @field.', [ + '@group' => $group_name, + '@field' => $title, + ] + ), ]; - $also_known[] = t('@group: @field', ['@group' => $group_name, '@field' => $title]); + $also_known[] = t('@group: @field', [ + '@group' => $group_name, + '@field' => $title, + ] + ); } } if ($aliases) { @@ -727,7 +772,11 @@ // Expose additional delta column for multiple value fields. if ($field_storage->isMultiple()) { - $title_delta = t('@label (@name:delta)', ['@label' => $label, '@name' => $field_name]); + $title_delta = t('@label (@name:delta)', [ + '@label' => $label, + '@name' => $field_name, + ] + ); $title_short_delta = t('@label:delta', ['@label' => $label]); $data[$table_alias]['delta'] = [ @@ -789,7 +838,7 @@ $entity_type_manager = \Drupal::entityTypeManager(); $entity_type_id = $field_storage->getTargetEntityTypeId(); - /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ + /** @var DefaultTableMapping $table_mapping */ $table_mapping = $entity_type_manager->getStorage($entity_type_id)->getTableMapping(); foreach ($data as $table_name => $table_data) { @@ -820,8 +869,8 @@ 'relationship field' => $field_name . '_target_id', ]; - // Provide a reverse relationship for the entity type that is referenced by - // the field. + // Provide a reverse relationship for the entity type that is referenced + // by the field. $args['@entity'] = $entity_type->getLabel(); $args['@label'] = $target_entity_type->getSingularLabel(); $pseudo_field_name = 'reverse__' . $entity_type_id . '__' . $field_name;