From f2eaf0178cf1115ba5a83a8e268f0f2621a8d0b5 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Tue, 16 Apr 2019 21:22:07 +0900
Subject: [PATCH] Issue #3041985 by alexpott, pifagor: Add
 Generic.CodeAnalysis.EmptyPHPStatement to phpcs rules to prevent empty PHP
 statements

---
 core/includes/form.inc                                        | 2 +-
 core/lib/Drupal/Core/Field/DeletedFieldsRepository.php        | 2 +-
 .../tests/src/Unit/Menu/AggregatorLocalTasksTest.php          | 1 -
 .../comment/tests/src/Functional/CommentFieldsTest.php        | 2 +-
 .../contact/tests/src/Functional/ContactSitewideTest.php      | 2 +-
 .../tests/src/Functional/ModerationStateNodeTest.php          | 2 +-
 .../src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php     | 2 +-
 .../Functional/Rest/ConfigurableLanguageResourceTestBase.php  | 2 +-
 .../tests/src/FunctionalJavascript/BlockFilterTest.php        | 2 +-
 .../src/Functional/EntityResource/EntityResourceTestBase.php  | 4 ++--
 .../tests/src/Functional/Rest/TermResourceTestBase.php        | 2 +-
 .../update/tests/src/Unit/Menu/UpdateLocalTasksTest.php       | 2 --
 core/phpcs.xml.dist                                           | 1 +
 .../modules/demo_umami_content/src/InstallHelper.php          | 2 +-
 .../Drupal/KernelTests/Core/Config/ConfigDependencyTest.php   | 4 ++--
 core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php | 2 +-
 core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php   | 2 +-
 .../Core/Entity/Routing/DefaultHtmlRouteProviderTest.php      | 2 +-
 .../Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php     | 2 +-
 .../Tests/Listeners/DrupalComponentTestListenerTrait.php      | 4 ++--
 20 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/core/includes/form.inc b/core/includes/form.inc
index ec6b2e8f30e0..0567076396b6 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -837,7 +837,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
 
     // Assign an arbitrary id: don't rely on a serial column in the 'batch'
     // table, since non-progressive batches skip database storage completely.
-    $batch['id'] = \Drupal::database()->nextId();;
+    $batch['id'] = \Drupal::database()->nextId();
 
     // Move operations to a job queue. Non-progressive batches will use a
     // memory-based queue.
diff --git a/core/lib/Drupal/Core/Field/DeletedFieldsRepository.php b/core/lib/Drupal/Core/Field/DeletedFieldsRepository.php
index 69f427473e9e..217112b7b5dd 100644
--- a/core/lib/Drupal/Core/Field/DeletedFieldsRepository.php
+++ b/core/lib/Drupal/Core/Field/DeletedFieldsRepository.php
@@ -76,7 +76,7 @@ public function addFieldStorageDefinition(FieldStorageDefinitionInterface $field
    * {@inheritdoc}
    */
   public function removeFieldDefinition(FieldDefinitionInterface $field_definition) {
-    $deleted_field_definitions = $this->state->get('field.field.deleted', []);;
+    $deleted_field_definitions = $this->state->get('field.field.deleted', []);
     unset($deleted_field_definitions[$field_definition->getUniqueIdentifier()]);
     $this->state->set('field.field.deleted', $deleted_field_definitions);
 
diff --git a/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php b/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
index 7a78ad9fb4ec..d1f91dfe2781 100644
--- a/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
+++ b/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
@@ -49,7 +49,6 @@ public function testAggregatorSourceLocalTasks($route) {
     $this->assertLocalTasks($route, [
       0 => ['entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'],
     ]);
-    ;
   }
 
   /**
diff --git a/core/modules/comment/tests/src/Functional/CommentFieldsTest.php b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php
index 2e64fed31c66..1cb6382f127b 100644
--- a/core/modules/comment/tests/src/Functional/CommentFieldsTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php
@@ -55,7 +55,7 @@ public function testCommentDefaultFields() {
 
     // Test adding a field that defaults to CommentItemInterface::CLOSED.
     $this->addDefaultCommentField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED, 'who_likes_ponies');
-    $field = FieldConfig::load('node.test_node_type.who_likes_ponies');;
+    $field = FieldConfig::load('node.test_node_type.who_likes_ponies');
     $this->assertEqual($field->getDefaultValueLiteral()[0]['status'], CommentItemInterface::CLOSED);
   }
 
diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
index 5a9e0ecf79fb..ec453715edf9 100644
--- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
@@ -556,7 +556,7 @@ public function submitContact($name, $mail, $subject, $id, $message) {
    * Deletes all forms.
    */
   public function deleteContactForms() {
-    $contact_forms = ContactForm::loadMultiple();;
+    $contact_forms = ContactForm::loadMultiple();
     foreach ($contact_forms as $id => $contact_form) {
       if ($id == 'personal') {
         // Personal form could not be deleted.
diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php
index 92b7219be023..8fd580896bf0 100644
--- a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php
+++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php
@@ -56,7 +56,7 @@ public function testCreatingContent() {
 
     // Disable content moderation.
     $edit['bundles[moderated_content]'] = FALSE;
-    $this->drupalPostForm('admin/config/workflow/workflows/manage/editorial/type/node', $edit, t('Save'));;
+    $this->drupalPostForm('admin/config/workflow/workflows/manage/editorial/type/node', $edit, t('Save'));
     // Ensure the parent environment is up-to-date.
     // @see content_moderation_workflow_insert()
     \Drupal::service('entity_type.bundle.info')->clearCachedBundles();
diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php
index 1dea1f89d5ae..7109627a43e9 100644
--- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php
+++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php
@@ -34,7 +34,7 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element = parent::settingsForm($form, $form_state);
 
-    unset($element['image_link']);;
+    unset($element['image_link']);
 
     return $element;
   }
diff --git a/core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php b/core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php
index a0dd46054109..2638d38c8acf 100644
--- a/core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php
+++ b/core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php
@@ -82,7 +82,7 @@ protected function getNormalizedPostEntity() {
    */
   public function testGetDefaultConfig() {
     $this->initAuthentication();
-    $url = Url::fromUri('base:/entity/configurable_language/en')->setOption('query', ['_format' => static::$format]);;
+    $url = Url::fromUri('base:/entity/configurable_language/en')->setOption('query', ['_format' => static::$format]);
     $request_options = $this->getAuthenticationRequestOptions('GET');
     $this->provisionEntityResource();
     $this->setUpAuthorization('GET');
diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php
index 1f92e5dd1c55..f7945d7129f7 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php
@@ -117,7 +117,7 @@ public function testBlockFilter() {
     });
 
     // Test Drupal.announce() message when all blocks are listed.
-    $filter->setValue('');;
+    $filter->setValue('');
     $this->assertAnnounceContains('All available blocks are listed.');
     // Confirm the Content Fields category remains collapsed after filtering.
     $this->assertFalse($promoteToFrontPageLink->isVisible());
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
index 1bc41be84e3d..15a450154640 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
@@ -1141,13 +1141,13 @@ public function testPatch() {
     $this->assertResourceErrorResponse(403, "Access denied on updating field 'field_rest_test'.", $response);
 
     // DX: 403 when entity trying to update an entity's ID field.
-    $request_options[RequestOptions::BODY] = $this->serializer->encode($this->makeNormalizationInvalid($this->getNormalizedPatchEntity(), 'id'), static::$format);;
+    $request_options[RequestOptions::BODY] = $this->serializer->encode($this->makeNormalizationInvalid($this->getNormalizedPatchEntity(), 'id'), static::$format);
     $response = $this->request('PATCH', $url, $request_options);
     $this->assertResourceErrorResponse(403, "Access denied on updating field '{$this->entity->getEntityType()->getKey('id')}'. The entity ID cannot be changed.", $response);
 
     if ($this->entity->getEntityType()->hasKey('uuid')) {
       // DX: 403 when entity trying to update an entity's UUID field.
-      $request_options[RequestOptions::BODY] = $this->serializer->encode($this->makeNormalizationInvalid($this->getNormalizedPatchEntity(), 'uuid'), static::$format);;
+      $request_options[RequestOptions::BODY] = $this->serializer->encode($this->makeNormalizationInvalid($this->getNormalizedPatchEntity(), 'uuid'), static::$format);
       $response = $this->request('PATCH', $url, $request_options);
       $this->assertResourceErrorResponse(403, "Access denied on updating field '{$this->entity->getEntityType()->getKey('uuid')}'. The entity UUID cannot be changed.", $response);
     }
diff --git a/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php b/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
index 91326511fe59..2609ecd3f352 100644
--- a/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
+++ b/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
@@ -372,7 +372,7 @@ public function providerTestGetTermWithParent() {
   protected function getExpectedUnauthorizedEntityAccessCacheability($is_authenticated) {
     // @see \Drupal\taxonomy\TermAccessControlHandler::checkAccess()
     return parent::getExpectedUnauthorizedEntityAccessCacheability($is_authenticated)
-      ->addCacheTags(['taxonomy_term:1']);;
+      ->addCacheTags(['taxonomy_term:1']);
   }
 
 }
diff --git a/core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php b/core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php
index 113f006aad2d..51b83c8d5b33 100644
--- a/core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php
+++ b/core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php
@@ -47,7 +47,6 @@ public function testUpdateModuleLocalTasks($route) {
     $this->assertLocalTasks($route, [
       0 => ['update.module_update'],
     ]);
-    ;
   }
 
   /**
@@ -68,7 +67,6 @@ public function testUpdateThemeLocalTasks($route) {
     $this->assertLocalTasks($route, [
       0 => ['update.theme_update'],
     ]);
-    ;
   }
 
   /**
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index 4738cba5b436..40f740420c14 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -148,6 +148,7 @@
 
   <!-- Generic sniffs -->
   <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
+  <rule ref="Generic.CodeAnalysis.EmptyPHPStatement" />
   <rule ref="Generic.Files.ByteOrderMark"/>
   <rule ref="Generic.Files.LineEndings"/>
   <rule ref="Generic.Formatting.SpaceAfterCast"/>
diff --git a/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
index 3a4044559ff4..b192c84f517b 100644
--- a/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
+++ b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
@@ -737,7 +737,7 @@ public function deleteImportedContent() {
    */
   protected function getUser($name) {
     $user_storage = $this->entityTypeManager->getStorage('user');
-    $users = $user_storage->loadByProperties(['name' => $name]);;
+    $users = $user_storage->loadByProperties(['name' => $name]);
     if (empty($users)) {
       // Creating user without any password.
       $user = $user_storage->create([
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php
index 6a0f938bd455..e9259c52e81d 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php
@@ -117,7 +117,7 @@ public function testDependencyManagement() {
       'type' => 'entity_test',
     ]);
     $entity_test->save();
-    $entity2->setEnforcedDependencies(['config' => [$entity1->getConfigDependencyName()], 'content' => [$entity_test->getConfigDependencyName()]])->save();;
+    $entity2->setEnforcedDependencies(['config' => [$entity1->getConfigDependencyName()], 'content' => [$entity_test->getConfigDependencyName()]])->save();
     $dependents = $config_manager->findConfigEntityDependents('content', [$entity_test->getConfigDependencyName()]);
     $this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on the content entity.');
     $this->assertTrue(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 has a dependency on the content entity.');
@@ -175,7 +175,7 @@ public function testDependencyManagement() {
 
     // Add a fake missing dependency to ensure multiple missing dependencies
     // work.
-    $entity1->setEnforcedDependencies(['content' => [$entity_test->getConfigDependencyName(), 'entity_test:bundle:uuid']])->save();;
+    $entity1->setEnforcedDependencies(['content' => [$entity_test->getConfigDependencyName(), 'entity_test:bundle:uuid']])->save();
     $expected['uuid'] = [
       'entity_type' => 'entity_test',
       'bundle' => 'bundle',
diff --git a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
index 070782fcba67..2af9ccd69264 100644
--- a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
@@ -39,7 +39,7 @@ public function setUp() {
     parent::setUp();
 
     // Add file_private_path setting.
-    $request = Request::create('/');;
+    $request = Request::create('/');
     $site_path = DrupalKernel::findSitePath($request);
     $this->setSetting('file_private_path', $site_path . '/private');
   }
diff --git a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
index 9d4e4ad408fe..6545542afca0 100644
--- a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
@@ -170,7 +170,7 @@ public function testFieldSettings($factory_name) {
    */
   public function testDefaultFieldSettings($factory_name) {
     $definition = $this->initializeFieldUsingFactory($factory_name);
-    $expected_settings = $this->fieldTypeDefinition['field_settings'] + $this->fieldTypeDefinition['storage_settings'];;
+    $expected_settings = $this->fieldTypeDefinition['field_settings'] + $this->fieldTypeDefinition['storage_settings'];
     $this->assertEquals($expected_settings, $definition->getSettings());
     foreach ($expected_settings as $setting => $value) {
       $this->assertEquals($value, $definition->getSetting($setting));
diff --git a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
index 8f89eaabc217..05de4c651671 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
@@ -218,7 +218,7 @@ public function providerTestGetCanonicalRoute() {
     $entity_type1->hasLinkTemplate('canonical')->willReturn(FALSE);
     $data['no_canonical_link_template'] = [NULL, $entity_type1->reveal()];
 
-    $entity_type2 = $this->getEntityType();;
+    $entity_type2 = $this->getEntityType();
     $entity_type2->hasLinkTemplate('canonical')->willReturn(TRUE);
     $entity_type2->hasViewBuilderClass()->willReturn(FALSE);
     $data['no_view_builder'] = [NULL, $entity_type2->reveal()];
diff --git a/core/tests/Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php b/core/tests/Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php
index c677fd39d40c..21c1427f6c00 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormStateDecoratorBaseTest.php
@@ -1477,7 +1477,7 @@ public function testSetFormObject() {
     $form = $this->getMock(FormInterface::class);
 
     $this->decoratedFormState->setFormObject($form)
-      ->shouldBeCalled();;
+      ->shouldBeCalled();
 
     $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setFormObject($form));
   }
diff --git a/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListenerTrait.php
index 70fa23604141..105d1333c345 100644
--- a/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListenerTrait.php
+++ b/core/tests/Drupal/Tests/Listeners/DrupalComponentTestListenerTrait.php
@@ -2,8 +2,8 @@
 
 namespace Drupal\Tests\Listeners;
 
-use Drupal\KernelTests\KernelTestBase;;
-use Drupal\Tests\BrowserTestBase;;
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\Tests\BrowserTestBase;
 use Drupal\Tests\UnitTestCase;
 use PHPUnit\Framework\AssertionFailedError;
 
-- 
GitLab