diff --git a/core/includes/common.inc b/core/includes/common.inc index 03af03bbb5dc923dc8f8f77f31923eaedf847143..feceb5bbe6be6bd71f760a6d761032717fdec749 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -14,6 +14,7 @@ use Drupal\Component\Utility\SortArray; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Cache\Cache; +use Drupal\Core\Render\Element\Link; use Drupal\Core\Render\Markup; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\PhpStorage\PhpStorageFactory; @@ -748,7 +749,7 @@ function drupal_clear_js_cache() { * Use \Drupal\Core\Render\Element\Link::preRenderLink(). */ function drupal_pre_render_link($element) { - return Element\Link::preRenderLink($element); + return Link::preRenderLink($element); } /** diff --git a/core/includes/form.inc b/core/includes/form.inc index c110c5b316a9060862e45eebd0862900f6a55bcf..06a806be9e621dba0d15a33b1b9312966295836a 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -7,6 +7,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Render\Element; +use Drupal\Core\Render\Element\RenderElement; use Drupal\Core\Template\Attribute; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -29,7 +30,7 @@ function template_preprocess_select(&$variables) { $element = $variables['element']; Element::setAttributes($element, array('id', 'name', 'size')); - Element\RenderElement::setAttributes($element, array('form-select')); + RenderElement::setAttributes($element, array('form-select')); $variables['attributes'] = $element['#attributes']; $variables['options'] = form_select_options($element); @@ -191,7 +192,7 @@ function form_get_options($element, $key) { function template_preprocess_fieldset(&$variables) { $element = $variables['element']; Element::setAttributes($element, array('id')); - Element\RenderElement::setAttributes($element); + RenderElement::setAttributes($element); $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : array(); $variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL; $variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL; @@ -376,7 +377,7 @@ function template_preprocess_form(&$variables) { function template_preprocess_textarea(&$variables) { $element = $variables['element']; Element::setAttributes($element, array('id', 'name', 'rows', 'cols', 'placeholder')); - Element\RenderElement::setAttributes($element, array('form-textarea')); + RenderElement::setAttributes($element, array('form-textarea')); $variables['wrapper_attributes'] = new Attribute(); $variables['attributes'] = new Attribute($element['#attributes']); $variables['value'] = $element['#value']; diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index bc693cde7761c0d9ae50fc0cc4ac9f2f2e4fece9..2df00f114e7725a6f9277960a68e536eac5fb4a2 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -2,6 +2,7 @@ namespace Drupal\Core; +use Drupal\Component\Assertion\Handle; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; @@ -18,6 +19,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Site\Settings; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\ClassLoader\ApcClassLoader; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -923,7 +925,7 @@ public static function bootEnvironment() { assert_options(ASSERT_ACTIVE, TRUE); // Now synchronize PHP 5 and 7's handling of assertions as much as // possible. - \Drupal\Component\Assertion\Handle::register(); + Handle::register(); // Log fatal errors to the test site directory. ini_set('log_errors', 1); @@ -978,7 +980,7 @@ protected function initializeSettings(Request $request) { && Settings::get('class_loader_auto_detect', TRUE) && extension_loaded('apc')) { $prefix = Settings::getApcuPrefix('class_loader', $this->root); - $apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader($prefix, $this->classLoader); + $apc_loader = new ApcClassLoader($prefix, $this->classLoader); $this->classLoader->unregister(); $apc_loader->register(); $this->classLoader = $apc_loader; diff --git a/core/lib/Drupal/Core/PageCache/DefaultRequestPolicy.php b/core/lib/Drupal/Core/PageCache/DefaultRequestPolicy.php index 731f22ff251209fde5dfe96590cf69399b09cce8..4616d989b1f11a573f12a59e1d33c3cbb8778e16 100644 --- a/core/lib/Drupal/Core/PageCache/DefaultRequestPolicy.php +++ b/core/lib/Drupal/Core/PageCache/DefaultRequestPolicy.php @@ -2,6 +2,8 @@ namespace Drupal\Core\PageCache; +use Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod; +use Drupal\Core\PageCache\RequestPolicy\NoSessionOpen; use Drupal\Core\Session\SessionConfigurationInterface; /** @@ -20,8 +22,8 @@ class DefaultRequestPolicy extends ChainRequestPolicy { * The session configuration. */ public function __construct(SessionConfigurationInterface $session_configuration) { - $this->addPolicy(new RequestPolicy\CommandLineOrUnsafeMethod()); - $this->addPolicy(new RequestPolicy\NoSessionOpen($session_configuration)); + $this->addPolicy(new CommandLineOrUnsafeMethod()); + $this->addPolicy(new NoSessionOpen($session_configuration)); } } diff --git a/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php b/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php index 46a5df7ad05c28d5238b0d22885d7298d1a49e5d..1986ceaf5867f1c1e9c31fe5dcae21a16d8d42fa 100644 --- a/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php +++ b/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php @@ -4,6 +4,7 @@ use Drupal\aggregator\Entity\Feed; use Drupal\aggregator\Entity\Item; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\system\Tests\Entity\EntityCacheTagsTestBase; use Drupal\user\Entity\Role; use Drupal\user\RoleInterface; @@ -63,7 +64,7 @@ protected function createEntity() { */ public function testEntityCreation() { // Create a cache entry that is tagged with a feed cache tag. - \Drupal::cache('render')->set('foo', 'bar', \Drupal\Core\Cache\CacheBackendInterface::CACHE_PERMANENT, $this->entity->getCacheTags()); + \Drupal::cache('render')->set('foo', 'bar', CacheBackendInterface::CACHE_PERMANENT, $this->entity->getCacheTags()); // Verify a cache hit. $this->verifyRenderCache('foo', array('aggregator_feed:1')); diff --git a/core/modules/big_pipe/src/Tests/BigPipePlaceholderTestCases.php b/core/modules/big_pipe/src/Tests/BigPipePlaceholderTestCases.php index 45958444b3f42681799a0f52fd0399ea88fef842..1cf10d4dc14257c221918b347c913d50891e05b0 100644 --- a/core/modules/big_pipe/src/Tests/BigPipePlaceholderTestCases.php +++ b/core/modules/big_pipe/src/Tests/BigPipePlaceholderTestCases.php @@ -9,6 +9,7 @@ use Drupal\big_pipe\Render\BigPipeMarkup; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -93,7 +94,7 @@ public static function cases(ContainerInterface $container = NULL, AccountInterf 'theme' => 'classy', 'libraries' => 'big_pipe/big_pipe,classy/base,classy/messages,core/drupal.active-link,core/html5shiv,core/normalize,system/base', ], - 'pluralDelimiter' => \Drupal\Core\StringTranslation\PluralTranslatableMarkup::DELIMITER, + 'pluralDelimiter' => PluralTranslatableMarkup::DELIMITER, 'user' => [ 'uid' => '1', 'permissionsHash' => $container->get('user_permissions_hash_generator')->generate($user), diff --git a/core/modules/big_pipe/src/Tests/BigPipeTest.php b/core/modules/big_pipe/src/Tests/BigPipeTest.php index 9ae960b636510c6c346b1884a1919fc8196e4fea..f947c46bdcf9cc99bea371e34d53ce3c0ca36dad 100644 --- a/core/modules/big_pipe/src/Tests/BigPipeTest.php +++ b/core/modules/big_pipe/src/Tests/BigPipeTest.php @@ -361,7 +361,7 @@ protected function getTestCases() { $csrf_token_seed = unserialize(explode('_sf2_meta|', $session_data)[1])['s']; $this->container->get('session_manager.metadata_bag')->setCsrfTokenSeed($csrf_token_seed); - return \Drupal\big_pipe\Tests\BigPipePlaceholderTestCases::cases($this->container, $this->rootUser); + return BigPipePlaceholderTestCases::cases($this->container, $this->rootUser); } /** diff --git a/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php b/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php index 2ac5a99372ae59474ede7288a35d51479495eda9..450a464bd467eaea40db3657e74535e68a9ed5db 100644 --- a/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php +++ b/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php @@ -3,6 +3,7 @@ namespace Drupal\big_pipe_test; use Drupal\big_pipe\Render\BigPipeMarkup; +use Drupal\big_pipe\Tests\BigPipePlaceholderTestCases; use Drupal\big_pipe_test\EventSubscriber\BigPipeTestSubscriber; class BigPipeTestController { @@ -15,7 +16,7 @@ class BigPipeTestController { public function test() { $build = []; - $cases = \Drupal\big_pipe\Tests\BigPipePlaceholderTestCases::cases(\Drupal::getContainer()); + $cases = BigPipePlaceholderTestCases::cases(\Drupal::getContainer()); // 1. HTML placeholder: status messages. Drupal renders those automatically, // so all that we need to do in this controller is set a message. diff --git a/core/modules/big_pipe/tests/src/Unit/Render/Placeholder/BigPipeStrategyTest.php b/core/modules/big_pipe/tests/src/Unit/Render/Placeholder/BigPipeStrategyTest.php index 9806fbf6454d0582d71f01e92dc0a2879553b850..f0f40ba29d771e91082bbca127bf9e89e3c40b3c 100644 --- a/core/modules/big_pipe/tests/src/Unit/Render/Placeholder/BigPipeStrategyTest.php +++ b/core/modules/big_pipe/tests/src/Unit/Render/Placeholder/BigPipeStrategyTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\big_pipe\Unit\Render\Placeholder; use Drupal\big_pipe\Render\Placeholder\BigPipeStrategy; +use Drupal\big_pipe\Tests\BigPipePlaceholderTestCases; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\SessionConfigurationInterface; use Drupal\Tests\UnitTestCase; @@ -61,7 +62,7 @@ public function testProcessPlaceholders(array $placeholders, $method, $route_mat * @see \Drupal\big_pipe\Tests\BigPipePlaceholderTestCases */ public function placeholdersProvider() { - $cases = \Drupal\big_pipe\Tests\BigPipePlaceholderTestCases::cases(); + $cases = BigPipePlaceholderTestCases::cases(); // Generate $placeholders variable as expected by // \Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface::processPlaceholders(). diff --git a/core/modules/comment/src/Tests/CommentCacheTagsTest.php b/core/modules/comment/src/Tests/CommentCacheTagsTest.php index e0e84c85810e2f6d303d1a3c374adee6308dad9f..3c7ab009638b192430ac68d94b03f3d22c1733fd 100644 --- a/core/modules/comment/src/Tests/CommentCacheTagsTest.php +++ b/core/modules/comment/src/Tests/CommentCacheTagsTest.php @@ -82,7 +82,7 @@ protected function createEntity() { 'entity_id' => $this->entityTestCamelid->id(), 'entity_type' => 'entity_test', 'field_name' => 'comment', - 'status' => \Drupal\comment\CommentInterface::PUBLISHED, + 'status' => CommentInterface::PUBLISHED, )); $comment->save(); diff --git a/core/modules/config/tests/config_install_dependency_test/config_install_dependency_test.module b/core/modules/config/tests/config_install_dependency_test/config_install_dependency_test.module index 08a169762a7f10cba637098b344d552e260dabf6..fbf11e5dabf6ad732da0dc2d2569c9cb6d63d0a6 100644 --- a/core/modules/config/tests/config_install_dependency_test/config_install_dependency_test.module +++ b/core/modules/config/tests/config_install_dependency_test/config_install_dependency_test.module @@ -5,10 +5,12 @@ * Provides hook implementations for testing purposes. */ +use Drupal\Core\Entity\EntityInterface; + /** * Implements hook_ENTITY_TYPE_create. */ -function config_install_dependency_test_config_test_create(\Drupal\Core\Entity\EntityInterface $entity) { +function config_install_dependency_test_config_test_create(EntityInterface $entity) { // Add an enforced dependency on this module so that we can test if this is // possible during module installation. $entity->setEnforcedDependencies(['module' => ['config_install_dependency_test']]); diff --git a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module index 0ecfee574a2107ee803694a27150d458b2f469e6..e20dc436fccd9d0a2255dad365f6fb2cd5b71baf 100644 --- a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module +++ b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module @@ -6,13 +6,14 @@ */ use Drupal\contact\ContactFormInterface; +use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Form\FormStateInterface; /** * Implements hook_entity_base_field_info(). */ -function contact_storage_test_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { +function contact_storage_test_entity_base_field_info(EntityTypeInterface $entity_type) { if ($entity_type->id() == 'contact_message') { $fields = array(); diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 3f507747138b723ec6861d517ed90cf528d29c12..5fb3ae37f554d9a74c51ca9c31cceedc25373f2a 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -7,6 +7,7 @@ use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface; +use Drupal\field\ConfigImporterFieldPurger; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\FieldConfigInterface; @@ -168,7 +169,7 @@ function field_cron() { /** * Implements hook_entity_field_storage_info(). */ -function field_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { +function field_entity_field_storage_info(EntityTypeInterface $entity_type) { if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { // Query by filtering on the ID as this is more efficient than filtering // on the entity_type property directly. @@ -301,7 +302,7 @@ function _field_create_entity_from_ids($ids) { * Implements hook_config_import_steps_alter(). */ function field_config_import_steps_alter(&$sync_steps, ConfigImporter $config_importer) { - $field_storages = \Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge( + $field_storages = ConfigImporterFieldPurger::getFieldStoragesToPurge( $config_importer->getStorageComparer()->getSourceStorage()->read('core.extension'), $config_importer->getStorageComparer()->getChangelist('delete') ); @@ -327,7 +328,7 @@ function field_form_config_admin_import_form_alter(&$form, FormStateInterface $f $user_input = $form_state->getUserInput(); $storage_comparer = $form_state->get('storage_comparer'); if ($storage_comparer && empty($user_input)) { - $field_storages = \Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge( + $field_storages = ConfigImporterFieldPurger::getFieldStoragesToPurge( $storage_comparer->getSourceStorage()->read('core.extension'), $storage_comparer->getChangelist('delete') ); diff --git a/core/modules/field/tests/fixtures/update/drupal-8.views_entity_reference_plugins-2429191.php b/core/modules/field/tests/fixtures/update/drupal-8.views_entity_reference_plugins-2429191.php index ca7c51a1db7443bc1c744490ed46c0268b5e4a5d..4ad0a7779646d85d3184319f973e18395c2da95c 100644 --- a/core/modules/field/tests/fixtures/update/drupal-8.views_entity_reference_plugins-2429191.php +++ b/core/modules/field/tests/fixtures/update/drupal-8.views_entity_reference_plugins-2429191.php @@ -8,6 +8,7 @@ use Drupal\Core\Database\Database; use Drupal\Component\Serialization\Yaml; +use Drupal\field\Entity\FieldStorageConfig; $connection = Database::getConnection(); @@ -59,8 +60,8 @@ ->execute() ->fetchField(); $installed = unserialize($installed); -$installed['field_ref_views_select_2429191'] = new \Drupal\field\Entity\FieldStorageConfig($field_ref_views_select_2429191); -$installed['field_ref_autocreate_2412569'] = new \Drupal\field\Entity\FieldStorageConfig($field_ref_autocreate_2412569); +$installed['field_ref_views_select_2429191'] = new FieldStorageConfig($field_ref_views_select_2429191); +$installed['field_ref_autocreate_2412569'] = new FieldStorageConfig($field_ref_autocreate_2412569); $connection->update('key_value') ->condition('collection', 'entity.definitions.installed') ->condition('name', 'node.field_storage_definitions') diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 9c994d6f758d45aac0e266ef52a33017281de50a..7eda28852726b3dee56e5a51d727c47cf88bdef3 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -13,8 +13,9 @@ * test helper functions */ -use Drupal\field\FieldStorageConfigInterface; +use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\field\FieldStorageConfigInterface; require_once __DIR__ . '/field_test.entity.inc'; require_once __DIR__ . '/field_test.field.inc'; @@ -149,7 +150,7 @@ function field_test_entity_extra_field_info_alter(&$info) { /** * Implements hook_entity_bundle_field_info_alter(). */ -function field_test_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) { +function field_test_entity_bundle_field_info_alter(&$fields, EntityTypeInterface $entity_type, $bundle) { if (($field_name = \Drupal::state()->get('field_test_set_constraint', FALSE)) && $entity_type->id() == 'entity_test' && $bundle == 'entity_test' && !empty($fields[$field_name])) { $fields[$field_name]->setPropertyConstraints('value', [ 'Range' => [ diff --git a/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module b/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module index ac0ce1cbfc9583294d1ea877a9cf92c0169698c4..9dc2b1936304fea6d02701c5d5956cad4eb23d55 100644 --- a/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module +++ b/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module @@ -5,12 +5,15 @@ * Test module. */ +use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Field\FormatterInterface; +use Drupal\Core\Field\WidgetInterface; use Drupal\Core\Form\FormStateInterface; /** * Implements hook_field_widget_third_party_settings_form(). */ -function field_third_party_test_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) { +function field_third_party_test_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) { $element['field_test_widget_third_party_settings_form'] = array( '#type' => 'textfield', '#title' => t('3rd party widget settings form'), @@ -30,7 +33,7 @@ function field_third_party_test_field_widget_settings_summary_alter(&$summary, $ /** * Implements hook_field_formatter_third_party_settings_form(). */ -function field_third_party_test_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) { +function field_third_party_test_field_formatter_third_party_settings_form(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) { $element['field_test_field_formatter_third_party_settings_form'] = array( '#type' => 'textfield', '#title' => t('3rd party formatter settings form'), diff --git a/core/modules/filter/tests/src/Kernel/FilterAPITest.php b/core/modules/filter/tests/src/Kernel/FilterAPITest.php index 49dde8ae17b55296b18b2dc57896c83bb07bf652..0f9feff4f570348144f1c7b5c2a793eb41258018 100644 --- a/core/modules/filter/tests/src/Kernel/FilterAPITest.php +++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php @@ -207,7 +207,7 @@ function testFilterFormatAPI() { // Test on nonsensical_restricted_html, where the allowed attribute values // contain asterisks, which do not have any meaning, but which we also // cannot prevent because configuration can be modified outside of forms. - $nonsensical_restricted_html = \Drupal\filter\Entity\FilterFormat::create(array( + $nonsensical_restricted_html = FilterFormat::create(array( 'format' => 'nonsensical_restricted_html', 'name' => 'Nonsensical Restricted HTML', 'filters' => array( @@ -468,7 +468,7 @@ public function assertFilterFormatViolation(ConstraintViolationListInterface $vi */ public function testDependencyRemoval() { $this->installSchema('user', array('users_data')); - $filter_format = \Drupal\filter\Entity\FilterFormat::load('filtered_html'); + $filter_format = FilterFormat::load('filtered_html'); // Disable the filter_test_restrict_tags_and_attributes filter plugin but // have custom configuration so that the filter plugin is still configured @@ -498,7 +498,7 @@ public function testDependencyRemoval() { // Verify the filter format still exists but the dependency and filter is // gone. \Drupal::entityManager()->getStorage('filter_format')->resetCache(); - $filter_format = \Drupal\filter\Entity\FilterFormat::load('filtered_html'); + $filter_format = FilterFormat::load('filtered_html'); $this->assertEqual([], $filter_format->getDependencies()); // Use the get method since the FilterFormat::filters() method only returns // existing plugins. diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 3722c45414cd2124ecaca1043acbc61c261ef4bc..42d5349f353f3905aff5c7bb439d57704e865fa3 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -8,6 +8,7 @@ use Drupal\comment\CommentInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Url; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -134,7 +135,7 @@ function forum_uri($forum) { /** * Implements hook_entity_bundle_field_info_alter(). */ -function forum_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) { +function forum_entity_bundle_field_info_alter(&$fields, EntityTypeInterface $entity_type, $bundle) { if ($entity_type->id() == 'node' && !empty($fields['taxonomy_forums'])) { $fields['taxonomy_forums']->addConstraint('ForumLeaf', []); } diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 72e8cfe47713d8c5118cfe029a592eba40ca58f6..1181b50f270a3010d7398da16c6c28921a3eaf0d 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -340,7 +340,7 @@ function locale_translate_batch_refresh(&$context) { // Clear cache and force refresh of JavaScript translations. _locale_refresh_translations($context['sandbox']['refresh']['languages'], $next); // Check whether we need to refresh configuration objects. - if ($names = \Drupal\locale\Locale::config()->getStringNames($next)) { + if ($names = Locale::config()->getStringNames($next)) { $context['sandbox']['refresh']['names_finished'] = $context['finished']; $context['sandbox']['refresh']['names'] = $names; } @@ -533,7 +533,7 @@ function locale_translate_delete_translation_files(array $projects = array(), ar */ function locale_config_batch_update_components(array $options, array $langcodes = array(), array $components = array()) { $langcodes = $langcodes ? $langcodes : array_keys(\Drupal::languageManager()->getLanguages()); - if ($langcodes && $names = \Drupal\locale\Locale::config()->getComponentNames($components)) { + if ($langcodes && $names = Locale::config()->getComponentNames($components)) { return locale_config_batch_build($names, $langcodes, $options); } } diff --git a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php index ee756584eaef60e4261f6f9e12e4516c06bc09e3..013a9ea21742a323c2ebbfc9e5ae2a7881c0e742 100644 --- a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +++ b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php @@ -67,7 +67,7 @@ protected function setUp() { // @see locale_system_update() locale_system_set_config_langcodes(); $langcodes = array_keys(\Drupal::languageManager()->getLanguages()); - $names = \Drupal\locale\Locale::config()->getComponentNames(); + $names = Locale::config()->getComponentNames(); Locale::config()->updateConfigTranslations($names, $langcodes); $this->configFactory = $this->container->get('config.factory'); diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module index e195ea8993cd2888e4a26dd49858786002e76baa..56b53a92bd3c7149c879e59a0645ac80599e16bd 100644 --- a/core/modules/node/tests/modules/node_access_test/node_access_test.module +++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module @@ -19,6 +19,7 @@ * @see \Drupal\node\Tests\NodeAccessBaseTableTest */ +use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessResult; use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldConfig; @@ -144,7 +145,7 @@ function node_access_test_add_field(NodeTypeInterface $type) { /** * Implements hook_node_access(). */ -function node_access_test_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account) { +function node_access_test_node_access(NodeInterface $node, $op, AccountInterface $account) { $secret_catalan = \Drupal::state() ->get('node_access_test_secret_catalan') ?: 0; if ($secret_catalan && $node->language()->getId() == 'ca') { diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module index aa7d4dd694635fd5e648c5539c6eba475c21e8aa..ab1777ea1d8804118c23f20c6a63a3f210613ea7 100644 --- a/core/modules/node/tests/modules/node_test/node_test.module +++ b/core/modules/node/tests/modules/node_test/node_test.module @@ -8,6 +8,7 @@ * interaction with the Node module. */ +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Session\AccountInterface; use Drupal\node\NodeInterface; @@ -151,7 +152,7 @@ function node_test_node_update(NodeInterface $node) { /** * Implements hook_entity_view_mode_alter(). */ -function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) { +function node_test_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) { // Only alter the view mode if we are on the test callback. $change_view_mode = \Drupal::state()->get( 'node_test_change_view_mode') ?: ''; if ($change_view_mode) { diff --git a/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php b/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php index 2160621d52f4ba217ddbafe7e8e2e8b30483fc86..aee02728ec884da87c831c1904b1789e4352ed6c 100644 --- a/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php +++ b/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\node\Kernel; +use Drupal\user\UserInterface; use Drupal\Core\Field\Entity\BaseFieldOverride; use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; use Drupal\node\Entity\Node; @@ -56,7 +57,7 @@ public function testFieldOverrides() { /** @var \Drupal\node\NodeInterface $node */ $node = Node::create(['type' => 'ponies']); $owner = $node->getOwner(); - $this->assertTrue($owner instanceof \Drupal\user\UserInterface); + $this->assertTrue($owner instanceof UserInterface); $this->assertEqual($owner->id(), $this->user->id()); } diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index 7df1da81a9f63cd8ff637108fa664cfb607eee8a..89ac37f4903e6ed6f395313abb6645f3b746616b 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -5,6 +5,8 @@ * Responsive image display formatter for image fields. */ +use Drupal\Core\Template\Attribute; +use Drupal\Core\Logger\RfcLogLevel; use Drupal\Component\Utility\Unicode; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\image\Entity\ImageStyle; @@ -162,7 +164,7 @@ function template_preprocess_responsive_image(&$variables) { // execution. if (!$responsive_image_style) { $variables['img_element'] = []; - \Drupal::logger('responsive_image')->log(\Drupal\Core\Logger\RfcLogLevel::ERROR, 'Failed to load responsive image style: “@style“ while displaying responsive image.', ['@style' => $variables['responsive_image_style_id']]); + \Drupal::logger('responsive_image')->log(RfcLogLevel::ERROR, 'Failed to load responsive image style: “@style“ while displaying responsive image.', ['@style' => $variables['responsive_image_style_id']]); return; } // Retrieve all breakpoints and multipliers and reverse order of breakpoints. @@ -411,7 +413,7 @@ function responsive_image_build_source_attributes(ImageInterface $image, array $ } // Sort the srcset from small to large image width or multiplier. ksort($srcset); - $source_attributes = new \Drupal\Core\Template\Attribute(array( + $source_attributes = new Attribute(array( 'srcset' => implode(', ', array_unique($srcset)), )); $media_query = trim($breakpoint->getMediaQuery()); @@ -494,7 +496,7 @@ function _responsive_image_image_style_url($style_name, $path) { return 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; } $entity = ImageStyle::load($style_name); - if ($entity instanceof Drupal\image\Entity\ImageStyle) { + if ($entity instanceof ImageStyle) { return file_url_transform_relative($entity->buildUrl($path)); } return file_url_transform_relative(file_create_url($path)); diff --git a/core/modules/shortcut/src/Tests/ShortcutCacheTagsTest.php b/core/modules/shortcut/src/Tests/ShortcutCacheTagsTest.php index 8fdd86cb7173007c658a5c94663fe33bc26d4d83..a437ffb0102641b1de0cac24fcbb799743d0a1ec 100644 --- a/core/modules/shortcut/src/Tests/ShortcutCacheTagsTest.php +++ b/core/modules/shortcut/src/Tests/ShortcutCacheTagsTest.php @@ -2,6 +2,7 @@ namespace Drupal\shortcut\Tests; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\shortcut\Entity\Shortcut; use Drupal\system\Tests\Entity\EntityCacheTagsTestBase; use Drupal\user\Entity\Role; @@ -55,7 +56,7 @@ protected function createEntity() { public function testEntityCreation() { // Create a cache entry that is tagged with a shortcut set cache tag. $cache_tags = ['config:shortcut.set.default']; - \Drupal::cache('render')->set('foo', 'bar', \Drupal\Core\Cache\CacheBackendInterface::CACHE_PERMANENT, $cache_tags); + \Drupal::cache('render')->set('foo', 'bar', CacheBackendInterface::CACHE_PERMANENT, $cache_tags); // Verify a cache hit. $this->verifyRenderCache('foo', $cache_tags); diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index b6c086812cc436f27395a8aee28d5a7a9e904607..9bc2c5bed771da5bf1618eb427decccc5b4a30a4 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -2,6 +2,7 @@ namespace Drupal\simpletest; +use Drupal\Component\Assertion\Handle; use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\SafeMarkup; @@ -1019,7 +1020,7 @@ public function run(array $methods = array()) { // Force assertion failures to be thrown as AssertionError for PHP 5 & 7 // compatibility. - \Drupal\Component\Assertion\Handle::register(); + Handle::register(); set_error_handler(array($this, 'errorHandler')); // Iterate through all the methods in this class, unless a specific list of diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 71ca68ef2d751fd36a44676e90f50c89a8a16ce0..627df293156677fd026d455fa663e1d06e3ffac4 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -27,6 +27,7 @@ use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Yaml\Yaml as SymfonyYaml; use Zend\Diactoros\Uri; /** @@ -635,7 +636,7 @@ protected function prepareSettings() { copy($settings_services_file, $directory . '/services.yml'); if ($this->strictConfigSchema) { // Add a listener to validate configuration schema on save. - $yaml = new \Symfony\Component\Yaml\Yaml(); + $yaml = new SymfonyYaml(); $content = file_get_contents($directory . '/services.yml'); $services = $yaml->parse($content); $services['services']['simpletest.config_schema_checker'] = [ diff --git a/core/modules/simpletest/tests/src/Unit/TestInfoParsingTest.php b/core/modules/simpletest/tests/src/Unit/TestInfoParsingTest.php index b96ea797c3e1c8073ff91bf9136d110e78937663..9a69d78af0bfb6b7866e4d4f2186d2ef0a77a744 100644 --- a/core/modules/simpletest/tests/src/Unit/TestInfoParsingTest.php +++ b/core/modules/simpletest/tests/src/Unit/TestInfoParsingTest.php @@ -25,7 +25,7 @@ class TestInfoParsingTest extends UnitTestCase { * @dataProvider infoParserProvider */ public function testTestInfoParser($expected, $classname, $doc_comment = NULL) { - $info = \Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment); + $info = TestDiscovery::getTestInfo($classname, $doc_comment); $this->assertEquals($expected, $info); } @@ -245,7 +245,7 @@ public function testTestInfoParserMissingGroup() { * Bulk delete storages and fields, and clean up afterwards. */ EOT; - \Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment); + TestDiscovery::getTestInfo($classname, $doc_comment); } /** @@ -258,7 +258,7 @@ public function testTestInfoParserMissingSummary() { * @group field */ EOT; - $info = \Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment); + $info = TestDiscovery::getTestInfo($classname, $doc_comment); $this->assertEmpty($info['description']); } diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php index fdde6d0c822ba7326fbe5f517637f7e2c104f8b5..80b46506726586920879ca4ecbc02aa89c5b9609 100644 --- a/core/modules/system/src/Tests/Ajax/DialogTest.php +++ b/core/modules/system/src/Tests/Ajax/DialogTest.php @@ -2,6 +2,7 @@ namespace Drupal\system\Tests\Ajax; +use Drupal\ajax_test\Controller\AjaxTestController; use Drupal\Core\EventSubscriber\MainContentViewSubscriber; use Drupal\Core\Form\FormBuilderInterface; use Drupal\Core\Url; @@ -29,7 +30,7 @@ public function testDialog() { $this->drupalGet('ajax-test/dialog'); // Set up variables for this test. - $dialog_renderable = \Drupal\ajax_test\Controller\AjaxTestController::dialogContents(); + $dialog_renderable = AjaxTestController::dialogContents(); $dialog_contents = \Drupal::service('renderer')->renderRoot($dialog_renderable); $modal_expected_response = array( 'command' => 'openDialog', diff --git a/core/modules/system/src/Tests/System/FloodTest.php b/core/modules/system/src/Tests/System/FloodTest.php index 59f4852efd2c35439fc9c21ee9cae60bb54b6f27..a3a336831484124816ff677d17bc953bc266e67a 100644 --- a/core/modules/system/src/Tests/System/FloodTest.php +++ b/core/modules/system/src/Tests/System/FloodTest.php @@ -2,6 +2,8 @@ namespace Drupal\system\Tests\System; +use Drupal\Core\Flood\DatabaseBackend; +use Drupal\Core\Flood\MemoryBackend; use Drupal\simpletest\WebTestBase; use Symfony\Component\HttpFoundation\Request; @@ -59,7 +61,7 @@ public function testMemoryBackend() { $name = 'flood_test_cleanup'; $request_stack = \Drupal::service('request_stack'); - $flood = new \Drupal\Core\Flood\MemoryBackend($request_stack); + $flood = new MemoryBackend($request_stack); // Register expired event. $flood->register($name, $window_expired); // Verify event is not allowed. @@ -87,7 +89,7 @@ public function testDatabaseBackend() { $connection = \Drupal::service('database'); $request_stack = \Drupal::service('request_stack'); - $flood = new \Drupal\Core\Flood\DatabaseBackend($connection, $request_stack); + $flood = new DatabaseBackend($connection, $request_stack); // Register expired event. $flood->register($name, $window_expired); // Verify event is not allowed. diff --git a/core/modules/system/src/Tests/TypedData/TypedDataTest.php b/core/modules/system/src/Tests/TypedData/TypedDataTest.php index 2f225338f0581fc3523a7d84884024aa894b9297..9903240b0564d213068e55b4f5cde89e2a19c71e 100644 --- a/core/modules/system/src/Tests/TypedData/TypedDataTest.php +++ b/core/modules/system/src/Tests/TypedData/TypedDataTest.php @@ -2,14 +2,22 @@ namespace Drupal\system\Tests\TypedData; +use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\ListDataDefinition; use Drupal\Core\TypedData\MapDataDefinition; +use Drupal\Core\TypedData\Type\BinaryInterface; +use Drupal\Core\TypedData\Type\BooleanInterface; +use Drupal\Core\TypedData\Type\DateTimeInterface; +use Drupal\Core\TypedData\Type\DurationInterface; +use Drupal\Core\TypedData\Type\FloatInterface; +use Drupal\Core\TypedData\Type\IntegerInterface; +use Drupal\Core\TypedData\Type\StringInterface; +use Drupal\Core\TypedData\Type\UriInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\file\Entity\File; use Drupal\simpletest\KernelTestBase; -use Drupal\Core\Datetime\DrupalDateTime; /** * Tests the functionality of all core data types. @@ -49,7 +57,7 @@ protected function createTypedData($definition, $value = NULL, $name = NULL) { $definition = DataDefinition::create($definition['type']); } $data = $this->typedDataManager->create($definition, $value, $name); - $this->assertTrue($data instanceof \Drupal\Core\TypedData\TypedDataInterface, 'Typed data object is an instance of the typed data interface.'); + $this->assertTrue($data instanceof TypedDataInterface, 'Typed data object is an instance of the typed data interface.'); return $data; } @@ -59,7 +67,7 @@ protected function createTypedData($definition, $value = NULL, $name = NULL) { public function testGetAndSet() { // Boolean type. $typed_data = $this->createTypedData(array('type' => 'boolean'), TRUE); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\BooleanInterface, 'Typed data object is an instance of BooleanInterface.'); + $this->assertTrue($typed_data instanceof BooleanInterface, 'Typed data object is an instance of BooleanInterface.'); $this->assertTrue($typed_data->getValue() === TRUE, 'Boolean value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $typed_data->setValue(FALSE); @@ -75,7 +83,7 @@ public function testGetAndSet() { // String type. $value = $this->randomString(); $typed_data = $this->createTypedData(array('type' => 'string'), $value); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\StringInterface, 'Typed data object is an instance of StringInterface.'); + $this->assertTrue($typed_data instanceof StringInterface, 'Typed data object is an instance of StringInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'String value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $new_value = $this->randomString(); @@ -93,7 +101,7 @@ public function testGetAndSet() { // Integer type. $value = rand(); $typed_data = $this->createTypedData(array('type' => 'integer'), $value); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\IntegerInterface, 'Typed data object is an instance of IntegerInterface.'); + $this->assertTrue($typed_data instanceof IntegerInterface, 'Typed data object is an instance of IntegerInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'Integer value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $new_value = rand(); @@ -110,7 +118,7 @@ public function testGetAndSet() { // Float type. $value = 123.45; $typed_data = $this->createTypedData(array('type' => 'float'), $value); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\FloatInterface, 'Typed data object is an instance of FloatInterface.'); + $this->assertTrue($typed_data instanceof FloatInterface, 'Typed data object is an instance of FloatInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'Float value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $new_value = 678.90; @@ -127,7 +135,7 @@ public function testGetAndSet() { // Date Time type. $value = '2014-01-01T20:00:00+00:00'; $typed_data = $this->createTypedData(array('type' => 'datetime_iso8601'), $value); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.'); + $this->assertTrue($typed_data instanceof DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.'); $this->assertTrue($typed_data->getValue() == $value, 'Date value was fetched.'); $this->assertEqual($typed_data->getValue(), $typed_data->getDateTime()->format('c'), 'Value representation of a date is ISO 8601'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -153,7 +161,7 @@ public function testGetAndSet() { // Timestamp type. $value = REQUEST_TIME; $typed_data = $this->createTypedData(array('type' => 'timestamp'), $value); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.'); + $this->assertTrue($typed_data instanceof DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.'); $this->assertTrue($typed_data->getValue() == $value, 'Timestamp value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $new_value = REQUEST_TIME + 1; @@ -176,7 +184,7 @@ public function testGetAndSet() { // DurationIso8601 type. $value = 'PT20S'; $typed_data = $this->createTypedData(array('type' => 'duration_iso8601'), $value); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DurationInterface, 'Typed data object is an instance of DurationInterface.'); + $this->assertTrue($typed_data instanceof DurationInterface, 'Typed data object is an instance of DurationInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'DurationIso8601 value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $typed_data->setValue('P40D'); @@ -200,7 +208,7 @@ public function testGetAndSet() { // Time span type. $value = 20; $typed_data = $this->createTypedData(array('type' => 'timespan'), $value); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DurationInterface, 'Typed data object is an instance of DurationInterface.'); + $this->assertTrue($typed_data instanceof DurationInterface, 'Typed data object is an instance of DurationInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'Time span value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $typed_data->setValue(60 * 60 * 4); @@ -223,7 +231,7 @@ public function testGetAndSet() { // URI type. $uri = 'http://example.com/foo/'; $typed_data = $this->createTypedData(array('type' => 'uri'), $uri); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\UriInterface, 'Typed data object is an instance of UriInterface.'); + $this->assertTrue($typed_data instanceof UriInterface, 'Typed data object is an instance of UriInterface.'); $this->assertTrue($typed_data->getValue() === $uri, 'URI value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $typed_data->setValue($uri . 'bar.txt'); @@ -251,7 +259,7 @@ public function testGetAndSet() { // Email type. $value = $this->randomString(); $typed_data = $this->createTypedData(array('type' => 'email'), $value); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\StringInterface, 'Typed data object is an instance of StringInterface.'); + $this->assertTrue($typed_data instanceof StringInterface, 'Typed data object is an instance of StringInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'Email value was fetched.'); $new_value = 'test@example.com'; $typed_data->setValue($new_value); @@ -266,7 +274,7 @@ public function testGetAndSet() { // Binary type. $typed_data = $this->createTypedData(array('type' => 'binary'), $files[0]->getFileUri()); - $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\BinaryInterface, 'Typed data object is an instance of BinaryInterface.'); + $this->assertTrue($typed_data instanceof BinaryInterface, 'Typed data object is an instance of BinaryInterface.'); $this->assertTrue(is_resource($typed_data->getValue()), 'Binary value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); // Try setting by URI. @@ -441,7 +449,7 @@ public function testTypedDataMaps() { // Test iterating. $count = 0; foreach ($typed_data as $item) { - $this->assertTrue($item instanceof \Drupal\Core\TypedData\TypedDataInterface); + $this->assertTrue($item instanceof TypedDataInterface); $count++; } $this->assertEqual($count, 3); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 3033a110e58339c5ae4593026be4713eeac218a3..787225220c3c664a0b1695208c6bb9d3d7dba544 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1254,7 +1254,7 @@ function system_get_module_admin_tasks($module, array $info) { $access_manager = \Drupal::service('access_manager'); if ($access_manager->checkNamedRoute('user.admin_permissions', array(), \Drupal::currentUser())) { /** @var \Drupal\Core\Url $url */ - $url = new \Drupal\Core\Url('user.admin_permissions'); + $url = new Url('user.admin_permissions'); $url->setOption('fragment', 'module-' . $module); $admin_tasks["user.admin_permissions.$module"] = array( 'title' => t('Configure @module permissions', array('@module' => $info['name'])), diff --git a/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php b/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php index 23b67e55a4c57d2cbcac0a17980dbca5686d871d..34474bf625b46ed6b7525a078d6f6a3c178b9674 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php @@ -6,19 +6,20 @@ * upgrade path of https://www.drupal.org/node/2354889. */ +use Drupal\Component\Serialization\Yaml; use Drupal\Core\Database\Database; $connection = Database::getConnection(); // A custom block with visibility settings. -$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2354889.yml')); +$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2354889.yml')); // A custom block without any visibility settings. -$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2354889.yml')); +$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2354889.yml')); // A custom block with visibility settings that contain a non-existing context // mapping. -$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdtestfor2354889.yml')); +$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdtestfor2354889.yml')); foreach ($block_configs as $block_config) { $connection->insert('config') diff --git a/core/modules/system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php b/core/modules/system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php index 986362f26ffdada51825939bdc6770f6d4f0e033..33861a0f991768e3a854fb7978eabc486b3417fc 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php @@ -6,12 +6,13 @@ * upgrade path of https://www.drupal.org/node/507488. */ +use Drupal\Component\Serialization\Yaml; use Drupal\Core\Database\Database; $connection = Database::getConnection(); // Structure of a custom block with visibility settings. -$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor507488.yml')); +$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor507488.yml')); foreach ($block_configs as $block_config) { $connection->insert('config') diff --git a/core/modules/system/tests/fixtures/update/drupal-8.page-title-into-block-2476947.php b/core/modules/system/tests/fixtures/update/drupal-8.page-title-into-block-2476947.php index ae3e77720b808cbfa97705f1fcb92511a70fb90e..b259ccc9b6eb7a6899f750d1f2c927f7abd4e49b 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.page-title-into-block-2476947.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.page-title-into-block-2476947.php @@ -6,12 +6,13 @@ * upgrade path of https://www.drupal.org/node/2476947. */ +use Drupal\Component\Serialization\Yaml; use Drupal\Core\Database\Database; $connection = Database::getConnection(); // Structure of a custom block with visibility settings. -$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2476947.yml')); +$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2476947.yml')); foreach ($block_configs as $block_config) { $connection->insert('config') diff --git a/core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php b/core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php index 474a085260893dffee48080048543d7899f9513c..f19c07c7de6ff27427650a5e9c8b73e9a822864c 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php @@ -6,12 +6,13 @@ * upgrade path of https://www.drupal.org/node/507488. */ +use Drupal\Component\Serialization\Yaml; use Drupal\Core\Database\Database; $connection = Database::getConnection(); // Structure of a custom block with visibility settings. -$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2569529.yml')); +$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2569529.yml')); foreach ($block_configs as $block_config) { $connection->insert('config') diff --git a/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php b/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php index 576762d088874ec17c75aa9e8ef6ed6515bbcad6..c632060afe793263af67698317d810f2b0ef2fb9 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php @@ -6,12 +6,13 @@ * upgrade path of https://www.drupal.org/node/2005546. */ +use Drupal\Component\Serialization\Yaml; use Drupal\Core\Database\Database; $connection = Database::getConnection(); // Structure of a custom block with visibility settings. -$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2005546.yml')); +$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2005546.yml')); foreach ($block_configs as $block_config) { $connection->insert('config') diff --git a/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php b/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php index 2d8da457fb82a6d0a36785283a58858c28e99936..fe72370b393f53007e751235df36fb52a8f77909 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php @@ -6,6 +6,7 @@ * upgrade path of https://www.drupal.org/node/2455125. */ +use Drupal\Component\Serialization\Yaml; use Drupal\Core\Database\Database; $connection = Database::getConnection(); @@ -13,7 +14,7 @@ // Structure of a view with timestamp fields. $views_configs = []; -$views_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/drupal-8.views-entity-views-data-2455125.yml')); +$views_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/drupal-8.views-entity-views-data-2455125.yml')); foreach ($views_configs as $views_config) { $connection->insert('config') diff --git a/core/modules/system/tests/fixtures/update/drupal-8.without_automated_cron.php b/core/modules/system/tests/fixtures/update/drupal-8.without_automated_cron.php index 87b635502da7495b7f9d465a0def92d6183cd190..b245f74e8136d0bb6c3d89a2a10423f06d0df408 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.without_automated_cron.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.without_automated_cron.php @@ -5,7 +5,9 @@ * Test fixture. */ -$connection = Drupal\Core\Database\Database::getConnection(); +use Drupal\Core\Database\Database; + +$connection = Database::getConnection(); $config = $connection; $connection->merge('config') diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module index 3e470884db0975ccb9c8edc4303449a3a5954b2e..ecde048bc51be0607bbc788856f3a30d605aa4be 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module +++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module @@ -5,8 +5,22 @@ * Simpletest mock module for Ajax forms testing. */ -use Drupal\Core\Ajax; +use Drupal\Core\Ajax\AddCssCommand; +use Drupal\Core\Ajax\AfterCommand; use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\Ajax\AlertCommand; +use Drupal\Core\Ajax\AppendCommand; +use Drupal\Core\Ajax\BeforeCommand; +use Drupal\Core\Ajax\ChangedCommand; +use Drupal\Core\Ajax\CssCommand; +use Drupal\Core\Ajax\DataCommand; +use Drupal\Core\Ajax\HtmlCommand; +use Drupal\Core\Ajax\InsertCommand; +use Drupal\Core\Ajax\InvokeCommand; +use Drupal\Core\Ajax\PrependCommand; +use Drupal\Core\Ajax\RemoveCommand; +use Drupal\Core\Ajax\RestripeCommand; +use Drupal\Core\Ajax\SettingsCommand; use Drupal\Core\Form\FormStateInterface; /** @@ -16,7 +30,7 @@ function ajax_forms_test_advanced_commands_after_callback($form, FormStateInterf $selector = '#after_div'; $response = new AjaxResponse(); - $response->addCommand(new Ajax\AfterCommand($selector, "This will be placed after")); + $response->addCommand(new AfterCommand($selector, "This will be placed after")); return $response; } @@ -25,7 +39,7 @@ function ajax_forms_test_advanced_commands_after_callback($form, FormStateInterf */ function ajax_forms_test_advanced_commands_alert_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\AlertCommand('Alert')); + $response->addCommand(new AlertCommand('Alert')); return $response; } @@ -35,7 +49,7 @@ function ajax_forms_test_advanced_commands_alert_callback($form, FormStateInterf function ajax_forms_test_advanced_commands_append_callback($form, FormStateInterface $form_state) { $selector = '#append_div'; $response = new AjaxResponse(); - $response->addCommand(new Ajax\AppendCommand($selector, "Appended text")); + $response->addCommand(new AppendCommand($selector, "Appended text")); return $response; } @@ -45,7 +59,7 @@ function ajax_forms_test_advanced_commands_append_callback($form, FormStateInter function ajax_forms_test_advanced_commands_before_callback($form, FormStateInterface $form_state) { $selector = '#before_div'; $response = new AjaxResponse(); - $response->addCommand(new Ajax\BeforeCommand($selector, "Before text")); + $response->addCommand(new BeforeCommand($selector, "Before text")); return $response; } @@ -54,7 +68,7 @@ function ajax_forms_test_advanced_commands_before_callback($form, FormStateInter */ function ajax_forms_test_advanced_commands_changed_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\ChangedCommand('#changed_div')); + $response->addCommand(new ChangedCommand('#changed_div')); return $response; } @@ -63,7 +77,7 @@ function ajax_forms_test_advanced_commands_changed_callback($form, FormStateInte */ function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\ChangedCommand('#changed_div', '#changed_div_mark_this')); + $response->addCommand(new ChangedCommand('#changed_div', '#changed_div_mark_this')); return $response; } @@ -75,7 +89,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterfac $color = 'blue'; $response = new AjaxResponse(); - $response->addCommand(new Ajax\CssCommand($selector, array('background-color' => $color))); + $response->addCommand(new CssCommand($selector, array('background-color' => $color))); return $response; } @@ -85,7 +99,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterfac function ajax_forms_test_advanced_commands_data_callback($form, FormStateInterface $form_state) { $selector = '#data_div'; $response = new AjaxResponse(); - $response->addCommand(new Ajax\DataCommand($selector, 'testkey', 'testvalue')); + $response->addCommand(new DataCommand($selector, 'testkey', 'testvalue')); return $response; } @@ -94,7 +108,7 @@ function ajax_forms_test_advanced_commands_data_callback($form, FormStateInterfa */ function ajax_forms_test_advanced_commands_invoke_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\InvokeCommand('#invoke_div', 'addClass', array('error'))); + $response->addCommand(new InvokeCommand('#invoke_div', 'addClass', array('error'))); return $response; } @@ -103,7 +117,7 @@ function ajax_forms_test_advanced_commands_invoke_callback($form, FormStateInter */ function ajax_forms_test_advanced_commands_html_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\HtmlCommand('#html_div', 'replacement text')); + $response->addCommand(new HtmlCommand('#html_div', 'replacement text')); return $response; } @@ -112,7 +126,7 @@ function ajax_forms_test_advanced_commands_html_callback($form, FormStateInterfa */ function ajax_forms_test_advanced_commands_insert_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\InsertCommand('#insert_div', 'insert replacement text')); + $response->addCommand(new InsertCommand('#insert_div', 'insert replacement text')); return $response; } @@ -121,7 +135,7 @@ function ajax_forms_test_advanced_commands_insert_callback($form, FormStateInter */ function ajax_forms_test_advanced_commands_prepend_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\PrependCommand('#prepend_div', "prepended text")); + $response->addCommand(new PrependCommand('#prepend_div', "prepended text")); return $response; } @@ -130,7 +144,7 @@ function ajax_forms_test_advanced_commands_prepend_callback($form, FormStateInte */ function ajax_forms_test_advanced_commands_remove_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\RemoveCommand('#remove_text')); + $response->addCommand(new RemoveCommand('#remove_text')); return $response; } @@ -139,7 +153,7 @@ function ajax_forms_test_advanced_commands_remove_callback($form, FormStateInter */ function ajax_forms_test_advanced_commands_restripe_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\RestripeCommand('#restripe_table')); + $response->addCommand(new RestripeCommand('#restripe_table')); return $response; } @@ -149,7 +163,7 @@ function ajax_forms_test_advanced_commands_restripe_callback($form, FormStateInt function ajax_forms_test_advanced_commands_settings_callback($form, FormStateInterface $form_state) { $setting['ajax_forms_test']['foo'] = 42; $response = new AjaxResponse(); - $response->addCommand(new Ajax\SettingsCommand($setting)); + $response->addCommand(new SettingsCommand($setting)); return $response; } @@ -158,7 +172,7 @@ function ajax_forms_test_advanced_commands_settings_callback($form, FormStateInt */ function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); - $response->addCommand(new Ajax\AddCssCommand('my/file.css')); + $response->addCommand(new AddCssCommand('my/file.css')); return $response; } diff --git a/core/modules/system/tests/modules/entity_test_operation/entity_test_operation.module b/core/modules/system/tests/modules/entity_test_operation/entity_test_operation.module index bdea7ba2a029dd9acfa559324aeb00e1c3be8031..2b050ea93617bf7856a7b9b731d02d7d6e4e44b1 100644 --- a/core/modules/system/tests/modules/entity_test_operation/entity_test_operation.module +++ b/core/modules/system/tests/modules/entity_test_operation/entity_test_operation.module @@ -5,12 +5,13 @@ * Contains hook implementations for Entity Operation Test Module. */ +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Url; /** * Implements hook_entity_operation(). */ -function entity_test_operation_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) { +function entity_test_operation_entity_operation(EntityInterface $entity) { return [ 'test' => [ 'title' => t('Front page'), diff --git a/core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php b/core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php index 040674fe1c890667f321f4c1a37772f24d067824..5bdb22a35f69158b73405c830d4e35952bb774a3 100644 --- a/core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php +++ b/core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php @@ -2,6 +2,8 @@ namespace Drupal\module_test\Controller; +use Drupal\module_autoload_test\SomeClass; + /** * Controller routines for module_test routes. */ @@ -38,7 +40,7 @@ public function hookDynamicLoadingInvokeAll() { public function testClassLoading() { $markup = NULL; if (class_exists('Drupal\module_autoload_test\SomeClass')) { - $obj = new \Drupal\module_autoload_test\SomeClass(); + $obj = new SomeClass(); $markup = $obj->testMethod(); } return ['#markup' => $markup]; diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index d691beb776cf404757bca51230335b98f2326d55..9beac7a86371e07b2e31e9a2dfcd96bb34e4640b 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\system\Kernel\Extension; +use Drupal\Core\Extension\MissingDependencyException; use Drupal\Core\DependencyInjection\ContainerBuilder; use \Drupal\Core\Extension\ModuleUninstallValidatorException; use Drupal\entity_test\Entity\EntityTest; @@ -121,7 +122,7 @@ function testDependencyResolution() { $result = $this->moduleInstaller()->install(array('color')); $this->fail(t('ModuleInstaller::install() throws an exception if dependencies are missing.')); } - catch (\Drupal\Core\Extension\MissingDependencyException $e) { + catch (MissingDependencyException $e) { $this->pass(t('ModuleInstaller::install() throws an exception if dependencies are missing.')); } diff --git a/core/modules/taxonomy/tests/modules/taxonomy_crud/taxonomy_crud.module b/core/modules/taxonomy/tests/modules/taxonomy_crud/taxonomy_crud.module index 442ca090dba5f387bf2a4296a77e6431d79fc3cc..dbe8781cea25c5df6a1971ef53f8ff36585e99e5 100644 --- a/core/modules/taxonomy/tests/modules/taxonomy_crud/taxonomy_crud.module +++ b/core/modules/taxonomy/tests/modules/taxonomy_crud/taxonomy_crud.module @@ -5,9 +5,11 @@ * Provides hook implementations for testing purposes. */ +use Drupal\taxonomy\VocabularyInterface; + /** * Implements hook_ENTITY_TYPE_presave() for taxonomy_vocabulary entities. */ -function taxonomy_crud_taxonomy_vocabulary_presave(\Drupal\taxonomy\VocabularyInterface $vocabulary) { +function taxonomy_crud_taxonomy_vocabulary_presave(VocabularyInterface $vocabulary) { $vocabulary->setThirdPartySetting('taxonomy_crud', 'foo', 'bar'); } diff --git a/core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php b/core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php index 844143acc1a008346f6581ee727280955c7be06a..33c3713c1e1c3b31524a627666e51d3c1a110959 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php @@ -2,6 +2,7 @@ namespace Drupal\views\Tests\Plugin; +use Drupal\views_test_data\Plugin\views\display_extender\DisplayExtenderTest as DisplayExtenderTestData; use Drupal\views\Views; /** @@ -38,7 +39,7 @@ public function testDisplayExtenders() { $this->assertEqual(count($view->display_handler->getExtenders()), 1, 'Make sure that only one extender is initialized.'); $display_extender = $view->display_handler->getExtenders()['display_extender_test']; - $this->assertTrue($display_extender instanceof \Drupal\views_test_data\Plugin\views\display_extender\DisplayExtenderTest, 'Make sure the right class got initialized.'); + $this->assertTrue($display_extender instanceof DisplayExtenderTestData, 'Make sure the right class got initialized.'); $view->preExecute(); $this->assertTrue($display_extender->testState['preExecute'], 'Make sure the display extender was able to react on preExecute.'); diff --git a/core/modules/views/tests/fixtures/update/argument-placeholder.php b/core/modules/views/tests/fixtures/update/argument-placeholder.php index 525299cdcd2cb4bc24ee5ea31d7dd78eb74d16fd..03181bbe5989f3c01ea70babb48bc3044013aae1 100644 --- a/core/modules/views/tests/fixtures/update/argument-placeholder.php +++ b/core/modules/views/tests/fixtures/update/argument-placeholder.php @@ -5,12 +5,15 @@ * Text fixture. */ -$connection = Drupal\Core\Database\Database::getConnection(); +use Drupal\Component\Serialization\Yaml; +use Drupal\Core\Database\Database; + +$connection = Database::getConnection(); $connection->insert('config') ->fields(array( 'collection' => '', 'name' => 'views.view.test_token_view', - 'data' => serialize(\Drupal\Component\Serialization\Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_token_view.yml'))), + 'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_token_view.yml'))), )) ->execute(); diff --git a/core/modules/views/tests/fixtures/update/duplicate-field-handler.php b/core/modules/views/tests/fixtures/update/duplicate-field-handler.php index 69aa8e8e3d153f40bcf184959287710d0f0d5c1c..32e74fb7cb290c4dcd7c9cb87559f093a0e7949e 100644 --- a/core/modules/views/tests/fixtures/update/duplicate-field-handler.php +++ b/core/modules/views/tests/fixtures/update/duplicate-field-handler.php @@ -5,12 +5,15 @@ * Test fixture. */ -$connection = Drupal\Core\Database\Database::getConnection(); +use Drupal\Component\Serialization\Yaml; +use Drupal\Core\Database\Database; + +$connection = Database::getConnection(); $connection->insert('config') ->fields(array( 'collection' => '', 'name' => 'views.view.test_duplicate_field_handlers', - 'data' => serialize(\Drupal\Component\Serialization\Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_duplicate_field_handlers.yml'))), + 'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_duplicate_field_handlers.yml'))), )) ->execute(); diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.module b/core/modules/views/tests/modules/views_test_data/views_test_data.module index f041651dc797269d26cf3d901ebcd27e9fedea45..bd917c7eee7e1c6bae8f1c28f2883eea3b71ea11 100644 --- a/core/modules/views/tests/modules/views_test_data/views_test_data.module +++ b/core/modules/views/tests/modules/views_test_data/views_test_data.module @@ -5,6 +5,8 @@ * Helper module for Views tests. */ +use Drupal\Core\Form\FormStateInterface; + /** * Access callback for the generic handler test. * @@ -126,6 +128,6 @@ function views_test_data_test_pre_render_function($element) { /** * Implements hook_form_BASE_FORM_ID_alter(). */ -function views_test_data_form_views_form_test_form_multiple_default_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { +function views_test_data_form_views_form_test_form_multiple_default_alter(&$form, FormStateInterface $form_state, $form_id) { drupal_set_message(t('Test base form ID with Views forms and arguments.')); } diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php index 58344bf7133aacad1963546bb6bed77e84b75880..93bd049808062fd141032f10b42d49f8c338ee80 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php @@ -3,17 +3,20 @@ namespace Drupal\views_ui\Form\Ajax; use Drupal\Component\Utility\Html; +use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\Ajax\CloseModalDialogCommand; use Drupal\Core\Ajax\OpenModalDialogCommand; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Render\RenderContext; +use Drupal\views\Ajax\HighlightCommand; +use Drupal\views\Ajax\ReplaceTitleCommand; +use Drupal\views\Ajax\ShowButtonsCommand; +use Drupal\views\Ajax\TriggerPreviewCommand; use Drupal\views\ViewEntityInterface; -use Drupal\views\Ajax; -use Drupal\views_ui\Ajax as AjaxUI; -use Drupal\Core\Ajax\AjaxResponse; -use Drupal\Core\Ajax\CloseModalDialogCommand; +use Drupal\views_ui\Ajax\SetFormCommand; use Symfony\Component\HttpFoundation\RedirectResponse; /** @@ -151,10 +154,10 @@ public function getForm(ViewEntityInterface $view, $display_id, $js) { else { $response = new AjaxResponse(); $response->addCommand(new CloseModalDialogCommand()); - $response->addCommand(new Ajax\ShowButtonsCommand(!empty($view->changed))); - $response->addCommand(new Ajax\TriggerPreviewCommand()); + $response->addCommand(new ShowButtonsCommand(!empty($view->changed))); + $response->addCommand(new TriggerPreviewCommand()); if ($page_title = $form_state->get('page_title')) { - $response->addCommand(new Ajax\ReplaceTitleCommand($page_title)); + $response->addCommand(new ReplaceTitleCommand($page_title)); } } // If this form was for view-wide changes, there's no need to regenerate @@ -248,10 +251,10 @@ protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state) // Usually this happens at the same path, but custom paths may be // specified in $form_state. $form_url = $form_state->has('url') ? $form_state->get('url')->toString() : $this->url(''); - $response->addCommand(new AjaxUI\SetFormCommand($form_url)); + $response->addCommand(new SetFormCommand($form_url)); if ($section = $form_state->get('#section')) { - $response->addCommand(new Ajax\HighlightCommand('.' . Html::cleanCssIdentifier($section))); + $response->addCommand(new HighlightCommand('.' . Html::cleanCssIdentifier($section))); } return $response; diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc index f9b165a112ade844397dc653ecb36d2c0734da99..3b5867894d39721e4e8386d868aee6e7ad9bc01c 100644 --- a/core/modules/views_ui/views_ui.theme.inc +++ b/core/modules/views_ui/views_ui.theme.inc @@ -8,6 +8,8 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Form\FormState; use Drupal\Core\Render\Element; +use Drupal\Core\Render\Element\Checkboxes; +use Drupal\Core\Render\Element\Radios; use Drupal\Core\Url; /** @@ -88,8 +90,8 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) { // Prepare default selectors. $form_state = new FormState(); - $form['default_group'] = Element\Radios::processRadios($form['default_group'], $form_state, $form); - $form['default_group_multiple'] = Element\Checkboxes::processCheckboxes($form['default_group_multiple'], $form_state, $form); + $form['default_group'] = Radios::processRadios($form['default_group'], $form_state, $form); + $form['default_group_multiple'] = Checkboxes::processCheckboxes($form['default_group_multiple'], $form_state, $form); $form['default_group']['All']['#title'] = ''; $rows[] = array( diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 9a5581c1bded3315da28565202e805469c61177d..975c31f056adeced1cbe3214a09dbb37210e061f 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -13,6 +13,7 @@ + diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php index ec3f87a577e9d56a68569eb66f219c16475d2db8..85320141ae6ec9a452922502886ec99cc110ca75 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php @@ -3,12 +3,16 @@ namespace Drupal\KernelTests\Core\Entity; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\TypedData\EntityDataDefinition; +use Drupal\Core\Entity\TypedData\EntityDataDefinitionInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\TypedData\ComplexDataDefinitionInterface; +use Drupal\Core\TypedData\ComplexDataInterface; use Drupal\Core\TypedData\DataDefinitionInterface; +use Drupal\Core\TypedData\ListInterface; use Drupal\Core\TypedData\Type\StringInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\node\Entity\Node; @@ -420,7 +424,7 @@ protected function doTestIntrospection($entity_type) { $this->assertEqual($value_definition->getDataType(), 'string'); // Test deriving metadata from references. - $entity_definition = \Drupal\Core\Entity\TypedData\EntityDataDefinition::create($entity_type); + $entity_definition = EntityDataDefinition::create($entity_type); $langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode'); $reference_definition = $entity_definition->getPropertyDefinition($langcode_key) ->getPropertyDefinition('language') @@ -431,7 +435,7 @@ protected function doTestIntrospection($entity_type) { ->getPropertyDefinition('entity') ->getTargetDefinition(); - $this->assertTrue($reference_definition instanceof \Drupal\Core\Entity\TypedData\EntityDataDefinitionInterface, 'Definition of the referenced user retrieved.'); + $this->assertTrue($reference_definition instanceof EntityDataDefinitionInterface, 'Definition of the referenced user retrieved.'); $this->assertEqual($reference_definition->getEntityTypeId(), 'user', 'Referenced entity is of type "user".'); // Test propagating down. @@ -583,12 +587,12 @@ public function getContainedStrings(TypedDataInterface $wrapper, $depth, array & // Recurse until a certain depth is reached if possible. if ($depth < 7) { - if ($wrapper instanceof \Drupal\Core\TypedData\ListInterface) { + if ($wrapper instanceof ListInterface) { foreach ($wrapper as $item) { $this->getContainedStrings($item, $depth + 1, $strings); } } - elseif ($wrapper instanceof \Drupal\Core\TypedData\ComplexDataInterface) { + elseif ($wrapper instanceof ComplexDataInterface) { foreach ($wrapper as $property) { $this->getContainedStrings($property, $depth + 1, $strings); } diff --git a/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php b/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php index be04507e6943d0db4f07badc21d410521f39f265..164da9d954c3ae6ab6e8e3520c2286eeb0a20066 100644 --- a/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\Core\DrupalKernel; +use Composer\Autoload\ClassLoader; use Drupal\Core\DrupalKernel; use Drupal\Core\Site\Settings; use Drupal\Tests\UnitTestCase; @@ -24,7 +25,7 @@ public function testDiscoverServiceCustom() { ), )); - $kernel = new DrupalKernel('prod', new \Composer\Autoload\ClassLoader()); + $kernel = new DrupalKernel('prod', new ClassLoader()); $kernel->discoverServiceProviders(); $expect = array( @@ -44,7 +45,7 @@ public function testDiscoverServiceCustom() { */ public function testDiscoverServiceNoContainerYamls() { new Settings([]); - $kernel = new DrupalKernel('prod', new \Composer\Autoload\ClassLoader()); + $kernel = new DrupalKernel('prod', new ClassLoader()); $kernel->discoverServiceProviders(); $expect = [ diff --git a/core/tests/Drupal/Tests/Core/PageCache/NoSessionOpenTest.php b/core/tests/Drupal/Tests/Core/PageCache/NoSessionOpenTest.php index 1af6afb9f4431d16c6da93bd9abaeb1ea76b977b..aa1f5d7d931401eec4fb07155152688417a9b711 100644 --- a/core/tests/Drupal/Tests/Core/PageCache/NoSessionOpenTest.php +++ b/core/tests/Drupal/Tests/Core/PageCache/NoSessionOpenTest.php @@ -2,8 +2,8 @@ namespace Drupal\Tests\Core\PageCache; +use Drupal\Core\PageCache\RequestPolicy\NoSessionOpen; use Drupal\Core\PageCache\RequestPolicyInterface; -use Drupal\Core\PageCache\RequestPolicy; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\Request; @@ -29,7 +29,7 @@ class NoSessionOpenTest extends UnitTestCase { protected function setUp() { $this->sessionConfiguration = $this->getMock('Drupal\Core\Session\SessionConfigurationInterface'); - $this->policy = new RequestPolicy\NoSessionOpen($this->sessionConfiguration); + $this->policy = new NoSessionOpen($this->sessionConfiguration); } /** diff --git a/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php b/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php index ded278e9642190a5e1372d03e7789fca76968117..ebafab0c96a10b88cbd470ce64a74cf53e531a2a 100644 --- a/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php +++ b/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\Core\ParamConverter; +use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Core\ParamConverter\EntityConverter; use Drupal\Tests\UnitTestCase; use Symfony\Component\Routing\Route; @@ -116,7 +117,7 @@ public function testConvertWithInvalidEntityType() { $this->entityManager->expects($this->once()) ->method('getStorage') ->with('invalid_id') - ->willThrowException(new \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException('invalid_id')); + ->willThrowException(new InvalidPluginDefinitionException('invalid_id')); $this->entityConverter->convert('id', ['type' => 'entity:invalid_id'], 'foo', ['foo' => 'id']); } diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php index ad02e5f3ecbfc2bb4adf187947c7ba2575bda5f2..49e350aca75908b6fdfc9b004f065758af950e76 100644 --- a/core/tests/bootstrap.php +++ b/core/tests/bootstrap.php @@ -7,6 +7,8 @@ * @see phpunit.xml.dist */ +use Drupal\Component\Assertion\Handle; + /** * Finds all valid extension directories recursively within a given directory. * @@ -141,4 +143,4 @@ function drupal_phpunit_populate_class_loader() { // runtime assertions. By default this setting is on. Here we make a call to // make PHP 5 and 7 handle assertion failures the same way, but this call does // not turn runtime assertions on if they weren't on already. -\Drupal\Component\Assertion\Handle::register(); +Handle::register(); diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 3d3ca1297aaaab912cc3f6a31fa4cc1b9b0361d9..b1b3308260a86f42d862d5ceca2fbbfc8c6d12f6 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -5,6 +5,7 @@ * Functions to support theming in the Bartik theme. */ +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Template\Attribute; /** @@ -113,7 +114,7 @@ function bartik_theme_suggestions_form_alter(array &$suggestions, array $variabl /** * Implements hook_form_alter() to add classes to the search form. */ -function bartik_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { +function bartik_form_alter(&$form, FormStateInterface $form_state, $form_id) { if (in_array($form_id, ['search_block_form', 'search_form'])) { $key = ($form_id == 'search_block_form') ? 'actions' : 'basic'; if (!isset($form[$key]['submit']['#attributes'])) {