From 53e5e3382cb867203f0dabe17e780ca11bac1861 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 18 Oct 2021 16:40:04 +0100
Subject: [PATCH] Issue #2909370 by Spokje, mfernea, neclimdul, zaporylie,
 quietone, xjm, osman, BartoszUrbaniak: Fix
 'Drupal.Commenting.VariableComment.IncorrectVarType' coding standard

---
 core/lib/Drupal/Core/Annotation/Action.php    |  4 ++-
 .../Drupal/Core/Annotation/QueueWorker.php    | 12 +++++---
 .../Core/Config/ExtensionInstallStorage.php   |  2 +-
 .../Annotation/EntityReferenceSelection.php   |  4 ++-
 .../Core/Field/Annotation/FieldFormatter.php  |  4 ++-
 .../Core/Field/Annotation/FieldWidget.php     |  4 ++-
 .../Drupal/Core/Layout/Annotation/Layout.php  | 28 ++++++++++++++-----
 .../tests/src/Kernel/CKEditorTest.php         |  2 +-
 core/modules/filter/src/Annotation/Filter.php | 16 ++++++++---
 .../image/src/Annotation/ImageEffect.php      |  4 ++-
 .../src/Annotation/MigrateProcessPlugin.php   |  4 ++-
 .../rest/src/Annotation/RestResource.php      |  4 ++-
 .../ChainEntityResolverTest.php               |  2 +-
 .../src/Kernel/Views/TaxonomyFieldVidTest.php |  2 +-
 .../Annotation/ViewsPluginAnnotationBase.php  |  4 ++-
 core/phpcs.xml.dist                           |  3 +-
 .../DependencySerializationTest.php           |  2 +-
 .../Core/TempStore/PrivateTempStoreTest.php   |  4 +--
 .../Core/TempStore/SharedTempStoreTest.php    |  4 +--
 19 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/core/lib/Drupal/Core/Annotation/Action.php b/core/lib/Drupal/Core/Annotation/Action.php
index 94781c754acb..9f215fc87a4d 100644
--- a/core/lib/Drupal/Core/Annotation/Action.php
+++ b/core/lib/Drupal/Core/Annotation/Action.php
@@ -39,9 +39,11 @@ class Action extends Plugin {
   /**
    * The route name for a confirmation form for this action.
    *
+   * This property is optional and it does not need to be declared.
+   *
    * @todo Provide a more generic way to allow an action to be confirmed first.
    *
-   * @var string (optional)
+   * @var string
    */
   public $confirm_form_route_name = '';
 
diff --git a/core/lib/Drupal/Core/Annotation/QueueWorker.php b/core/lib/Drupal/Core/Annotation/QueueWorker.php
index 04ec168dc991..1f85cb07871d 100644
--- a/core/lib/Drupal/Core/Annotation/QueueWorker.php
+++ b/core/lib/Drupal/Core/Annotation/QueueWorker.php
@@ -52,11 +52,15 @@ class QueueWorker extends Plugin {
   public $title;
 
   /**
-   * An associative array containing the optional key:
-   *   - time: (optional) How much time Drupal cron should spend on calling
-   *     this worker in seconds. Defaults to 15.
+   * An associative array containing an optional key.
    *
-   * @var array (optional)
+   * This property is optional and it does not need to be declared.
+   *
+   * Available keys:
+   * - time (optional): How much time Drupal cron should spend on calling this
+   *   worker in seconds. Defaults to 15.
+   *
+   * @var array
    */
   public $cron;
 
diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
index 39e13d8476bf..1006013f5f2d 100644
--- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
+++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
@@ -31,7 +31,7 @@ class ExtensionInstallStorage extends InstallStorage {
    *
    * In the early installer this value can be NULL.
    *
-   * @var string|NULL
+   * @var string|null
    */
   protected $installProfile;
 
diff --git a/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php b/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php
index a647441bd69c..110beb1ba17f 100644
--- a/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php
+++ b/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php
@@ -63,7 +63,9 @@ class EntityReferenceSelection extends Plugin {
    * An array of entity types that can be referenced by this plugin. Defaults to
    * all entity types.
    *
-   * @var array (optional)
+   * This property is optional and it does not need to be declared.
+   *
+   * @var array
    */
   public $entity_types = [];
 
diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php b/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
index 1a2439109c0f..9ecac7a348fb 100644
--- a/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
+++ b/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
@@ -68,7 +68,9 @@ class FieldFormatter extends Plugin {
    * formatter in the Field UI when selecting a formatter for a given field
    * instance.
    *
-   * @var int optional
+   * This property is optional and it does not need to be declared.
+   *
+   * @var int
    */
   public $weight = NULL;
 
diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php b/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php
index 38d3f869e54f..f17612284a2f 100644
--- a/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php
+++ b/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php
@@ -73,7 +73,9 @@ class FieldWidget extends Plugin {
    * An integer to determine the weight of this widget relative to other widgets
    * in the Field UI when selecting a widget for a given field.
    *
-   * @var int optional
+   * This property is optional and it does not need to be declared.
+   *
+   * @var int
    */
   public $weight = NULL;
 
diff --git a/core/lib/Drupal/Core/Layout/Annotation/Layout.php b/core/lib/Drupal/Core/Layout/Annotation/Layout.php
index eae930cf4eb1..ce7aba42fe51 100644
--- a/core/lib/Drupal/Core/Layout/Annotation/Layout.php
+++ b/core/lib/Drupal/Core/Layout/Annotation/Layout.php
@@ -40,7 +40,9 @@ class Layout extends Plugin {
   public $label;
 
   /**
-   * An optional description for advanced layouts.
+   * A description for advanced layouts.
+   *
+   * This property is optional and it does not need to be declared.
    *
    * Sometimes layouts are so complex that the name is insufficient to describe
    * a layout such that a visually impaired administrator could layout a page
@@ -67,11 +69,13 @@ class Layout extends Plugin {
   /**
    * The template file to render this layout (relative to the 'path' given).
    *
+   * This property is optional and it does not need to be declared.
+   *
    * If specified, then the layout_discovery module will register the template
    * with hook_theme() and the module or theme registering this layout does not
    * need to do it.
    *
-   * @var string optional
+   * @var string
    *
    * @see hook_theme()
    */
@@ -80,11 +84,13 @@ class Layout extends Plugin {
   /**
    * The theme hook used to render this layout.
    *
+   * This property is optional and it does not need to be declared.
+   *
    * If specified, it's assumed that the module or theme registering this layout
    * will also register the theme hook with hook_theme() itself. This is
    * mutually exclusive with 'template' - you can't specify both.
    *
-   * @var string optional
+   * @var string
    *
    * @see hook_theme()
    */
@@ -93,28 +99,36 @@ class Layout extends Plugin {
   /**
    * Path (relative to the module or theme) to resources like icon or template.
    *
-   * @var string optional
+   * This property is optional and it does not need to be declared.
+   *
+   * @var string
    */
   public $path;
 
   /**
    * The asset library.
    *
-   * @var string optional
+   * This property is optional and it does not need to be declared.
+   *
+   * @var string
    */
   public $library;
 
   /**
    * The path to the preview image (relative to the 'path' given).
    *
-   * @var string optional
+   * This property is optional and it does not need to be declared.
+   *
+   * @var string
    */
   public $icon;
 
   /**
    * The icon map.
    *
-   * @var string[][] optional
+   * This property is optional and it does not need to be declared.
+   *
+   * @var string[][]
    *
    * @see \Drupal\Core\Layout\Icon\IconBuilderInterface::build()
    */
diff --git a/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php b/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php
index 68fd7a607319..f70fd87d0740 100644
--- a/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php
+++ b/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php
@@ -45,7 +45,7 @@ class CKEditorTest extends KernelTestBase {
   /**
    * The Editor Plugin Manager.
    *
-   * @var \Drupal\editor\Plugin\EditorManager;
+   * @var \Drupal\editor\Plugin\EditorManager
    */
   protected $manager;
 
diff --git a/core/modules/filter/src/Annotation/Filter.php b/core/modules/filter/src/Annotation/Filter.php
index c65f9058e697..53d607bc2a92 100644
--- a/core/modules/filter/src/Annotation/Filter.php
+++ b/core/modules/filter/src/Annotation/Filter.php
@@ -48,30 +48,38 @@ class Filter extends Plugin {
   /**
    * Additional administrative information about the filter's behavior.
    *
+   * This property is optional and it does not need to be declared.
+   *
    * @ingroup plugin_translatable
    *
-   * @var \Drupal\Core\Annotation\Translation (optional)
+   * @var \Drupal\Core\Annotation\Translation
    */
   public $description = '';
 
   /**
    * A default weight for the filter in new text formats.
    *
-   * @var int (optional)
+   * This property is optional and it does not need to be declared.
+   *
+   * @var int
    */
   public $weight = 0;
 
   /**
    * Whether this filter is enabled or disabled by default.
    *
-   * @var bool (optional)
+   * This property is optional and it does not need to be declared.
+   *
+   * @var bool
    */
   public $status = FALSE;
 
   /**
    * The default settings for the filter.
    *
-   * @var array (optional)
+   * This property is optional and it does not need to be declared.
+   *
+   * @var array
    */
   public $settings = [];
 
diff --git a/core/modules/image/src/Annotation/ImageEffect.php b/core/modules/image/src/Annotation/ImageEffect.php
index bbe10e6541ca..f45977013c6d 100644
--- a/core/modules/image/src/Annotation/ImageEffect.php
+++ b/core/modules/image/src/Annotation/ImageEffect.php
@@ -44,11 +44,13 @@ class ImageEffect extends Plugin {
   /**
    * A brief description of the image effect.
    *
+   * This property is optional and it does not need to be declared.
+   *
    * This will be shown when adding or configuring this image effect.
    *
    * @ingroup plugin_translatable
    *
-   * @var \Drupal\Core\Annotation\Translation (optional)
+   * @var \Drupal\Core\Annotation\Translation
    */
   public $description = '';
 
diff --git a/core/modules/migrate/src/Annotation/MigrateProcessPlugin.php b/core/modules/migrate/src/Annotation/MigrateProcessPlugin.php
index def2fd9d92ba..0732bafc3d13 100644
--- a/core/modules/migrate/src/Annotation/MigrateProcessPlugin.php
+++ b/core/modules/migrate/src/Annotation/MigrateProcessPlugin.php
@@ -35,13 +35,15 @@ class MigrateProcessPlugin extends Plugin {
   /**
    * Whether the plugin handles multiples itself.
    *
+   * This property is optional and it does not need to be declared.
+   *
    * Typically these plugins will expect an array as input and iterate over it
    * themselves, changing the whole array. For example the 'sub_process' and the
    * 'flatten' plugins. If the plugin only need to change a single value it
    * can skip setting this attribute and let
    * \Drupal\migrate\MigrateExecutable::processRow() handle the iteration.
    *
-   * @var bool (optional)
+   * @var bool
    */
   public $handle_multiples = FALSE;
 
diff --git a/core/modules/rest/src/Annotation/RestResource.php b/core/modules/rest/src/Annotation/RestResource.php
index f525ff1c8490..832b43b0ced1 100644
--- a/core/modules/rest/src/Annotation/RestResource.php
+++ b/core/modules/rest/src/Annotation/RestResource.php
@@ -41,9 +41,11 @@ class RestResource extends Plugin {
   /**
    * The serialization class to deserialize serialized data into.
    *
+   * This property is optional and it does not need to be declared.
+   *
    * @see \Symfony\Component\Serializer\SerializerInterface's "type" parameter.
    *
-   * @var string (optional)
+   * @var string
    */
   public $serialization_class;
 
diff --git a/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php b/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
index 2a9dd5b68df4..76800296df6b 100644
--- a/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
+++ b/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
@@ -21,7 +21,7 @@ class ChainEntityResolverTest extends UnitTestCase {
   /**
    * Test data passed to the resolve method.
    *
-   * @var \stdClass
+   * @var object
    */
   protected $testData;
 
diff --git a/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php b/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php
index 456dd494054d..1b0c88b28a8e 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyFieldVidTest.php
@@ -48,7 +48,7 @@ class TaxonomyFieldVidTest extends ViewsKernelTestBase {
   /**
    * An admin user.
    *
-   * @var \Drupal\user\Entity\User;
+   * @var \Drupal\user\Entity\User
    */
   protected $adminUser;
 
diff --git a/core/modules/views/src/Annotation/ViewsPluginAnnotationBase.php b/core/modules/views/src/Annotation/ViewsPluginAnnotationBase.php
index ad64c94ed469..59d9fb0762ff 100644
--- a/core/modules/views/src/Annotation/ViewsPluginAnnotationBase.php
+++ b/core/modules/views/src/Annotation/ViewsPluginAnnotationBase.php
@@ -12,7 +12,9 @@ abstract class ViewsPluginAnnotationBase extends Plugin {
   /**
    * Whether or not to register a theme function automatically.
    *
-   * @var bool (optional)
+   * This property is optional and it does not need to be declared.
+   *
+   * @var bool
    */
   public $register_theme = TRUE;
 
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index 6fafc0de1a4d..5db0cfbabd86 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -79,8 +79,7 @@
   <rule ref="Drupal.Commenting.GenderNeutralComment"/>
   <rule ref="Drupal.Commenting.InlineVariableComment"/>
   <rule ref="Drupal.Commenting.VariableComment">
-    <!-- Sniff for: DuplicateVar, EmptyVar, InlineVariableName, WrongStyle -->
-    <exclude name="Drupal.Commenting.VariableComment.IncorrectVarType"/>
+    <!-- Sniff for: DuplicateVar, EmptyVar, IncorrectVarType, InlineVariableName, WrongStyle -->
     <exclude name="Drupal.Commenting.VariableComment.Missing"/>
     <exclude name="Drupal.Commenting.VariableComment.MissingVar"/>
     <exclude name="Drupal.Commenting.VariableComment.VarOrder"/>
diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/DependencySerializationTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/DependencySerializationTest.php
index 0f45f18a6d9d..6c2446e8f556 100644
--- a/core/tests/Drupal/Tests/Core/DependencyInjection/DependencySerializationTest.php
+++ b/core/tests/Drupal/Tests/Core/DependencyInjection/DependencySerializationTest.php
@@ -79,7 +79,7 @@ class DependencySerializationTestDummy implements ContainerAwareInterface {
   /**
    * A test service.
    *
-   * @var \stdClass
+   * @var object
    */
   public $service;
 
diff --git a/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php b/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
index 267a6fdfb31d..3586877c35ab 100644
--- a/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
+++ b/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
@@ -53,14 +53,14 @@ class PrivateTempStoreTest extends UnitTestCase {
   /**
    * A tempstore object belonging to the owner.
    *
-   * @var \stdClass
+   * @var object
    */
   protected $ownObject;
 
   /**
    * A tempstore object not belonging to the owner.
    *
-   * @var \stdClass
+   * @var object
    */
   protected $otherObject;
 
diff --git a/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php b/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
index ec6d6c0594ae..97be1742bc11 100644
--- a/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
+++ b/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
@@ -59,14 +59,14 @@ class SharedTempStoreTest extends UnitTestCase {
   /**
    * A tempstore object belonging to the owner.
    *
-   * @var \stdClass
+   * @var object
    */
   protected $ownObject;
 
   /**
    * A tempstore object not belonging to the owner.
    *
-   * @var \stdClass
+   * @var object
    */
   protected $otherObject;
 
-- 
GitLab