From 19bd1484cb83af56d221543671aad1242dfbf61b Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Thu, 19 Dec 2024 10:48:08 +1000
Subject: [PATCH] Issue #3477668 by quietone, lavanyatalwar, daffie: Fix
 Drupal.Commenting.VariableComment.Missing in non-tests

---
 core/lib/Drupal/Component/Utility/Timer.php   |  5 ++++
 .../Drupal/Core/Datetime/DateFormatter.php    |  5 ++++
 .../Constraint/EntityChangedConstraint.php    |  3 +++
 .../EntityUntranslatableFieldsConstraint.php  |  7 ++++++
 .../Drupal/Core/Recipe/ConfigConfigurator.php |  6 +++++
 .../Core/Recipe/RecipeInputFormTrait.php      |  2 +-
 .../Constraint/PrimitiveTypeConstraint.php    |  3 +++
 .../Constraint/UniqueFieldConstraint.php      |  3 +++
 .../Constraint/ModerationStateConstraint.php  | 11 +++++++++
 .../Validation/Constraint/FileUriUnique.php   |  5 ++++
 .../Constraint/LinkAccessConstraint.php       |  5 ++++
 .../LinkExternalProtocolsConstraint.php       |  5 ++++
 .../LinkNotExistingInternalConstraint.php     |  5 ++++
 .../Constraint/LinkTypeConstraint.php         |  5 ++++
 .../Constraint/MenuSettingsConstraint.php     | 15 ++++++++++++
 .../Constraint/PathAliasConstraint.php        |  3 +++
 .../Validation/Constraint/UserMailUnique.php  |  3 +++
 .../Constraint/UserNameConstraint.php         | 23 +++++++++++++++++++
 .../Validation/Constraint/UserNameUnique.php  |  3 +++
 .../user/src/Plugin/views/filter/Name.php     |  3 +++
 .../views/argument/ArgumentPluginBase.php     | 11 +++++++++
 .../src/Plugin/views/argument/Formula.php     |  3 +++
 .../Plugin/views/field/FieldPluginBase.php    |  4 ++++
 .../src/Plugin/views/filter/InOperator.php    |  3 +++
 .../src/Plugin/views/filter/ManyToOne.php     |  3 +++
 .../src/Plugin/views/filter/NumericFilter.php |  3 +++
 core/phpcs.xml.dist                           |  5 +++-
 27 files changed, 150 insertions(+), 2 deletions(-)

diff --git a/core/lib/Drupal/Component/Utility/Timer.php b/core/lib/Drupal/Component/Utility/Timer.php
index 19c83922e4cb..20f3b7af683b 100644
--- a/core/lib/Drupal/Component/Utility/Timer.php
+++ b/core/lib/Drupal/Component/Utility/Timer.php
@@ -9,6 +9,11 @@
  */
 class Timer {
 
+  /**
+   * An associative array of timers.
+   *
+   * @var array
+   */
   protected static $timers = [];
 
   /**
diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php
index cafe4cab026d..4b4a54c24e98 100644
--- a/core/lib/Drupal/Core/Datetime/DateFormatter.php
+++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php
@@ -53,6 +53,11 @@ class DateFormatter implements DateFormatterInterface {
    */
   protected $requestStack;
 
+  /**
+   * The available date formats.
+   *
+   * @var array
+   */
   protected $dateFormats = [];
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php
index 9099d88b8a97..720190c17839 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php
@@ -16,6 +16,9 @@
 )]
 class EntityChangedConstraint extends SymfonyConstraint {
 
+  /**
+   * The default violation message.
+   */
   public $message = 'The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.';
 
 }
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityUntranslatableFieldsConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityUntranslatableFieldsConstraint.php
index 726a549a3c4b..29ba9ee70f9c 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityUntranslatableFieldsConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityUntranslatableFieldsConstraint.php
@@ -16,7 +16,14 @@
 )]
 class EntityUntranslatableFieldsConstraint extends SymfonyConstraint {
 
+  /**
+   * The message when updating a field but not the current revision.
+   */
   public $defaultRevisionMessage = 'Non-translatable fields can only be changed when updating the current revision.';
+
+  /**
+   * The message when updating a field but not the original language.
+   */
   public $defaultTranslationMessage = 'Non-translatable fields can only be changed when updating the original language.';
 
 }
diff --git a/core/lib/Drupal/Core/Recipe/ConfigConfigurator.php b/core/lib/Drupal/Core/Recipe/ConfigConfigurator.php
index ad837d5dc35c..710cba0f87a9 100644
--- a/core/lib/Drupal/Core/Recipe/ConfigConfigurator.php
+++ b/core/lib/Drupal/Core/Recipe/ConfigConfigurator.php
@@ -14,8 +14,14 @@
  */
 final class ConfigConfigurator {
 
+  /**
+   * The configuration directory for the recipe.
+   */
   public readonly ?string $recipeConfigDirectory;
 
+  /**
+   * Indicates how the shipped and active config are compared.
+   */
   private readonly bool|array $strict;
 
   /**
diff --git a/core/lib/Drupal/Core/Recipe/RecipeInputFormTrait.php b/core/lib/Drupal/Core/Recipe/RecipeInputFormTrait.php
index 1fe9f6bf4878..5f8d8dd32d5e 100644
--- a/core/lib/Drupal/Core/Recipe/RecipeInputFormTrait.php
+++ b/core/lib/Drupal/Core/Recipe/RecipeInputFormTrait.php
@@ -64,7 +64,7 @@ protected function buildRecipeInputForm(Recipe $recipe): array {
        *
        * @var array
        */
-      // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
+      // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable, Drupal.Commenting.VariableComment.Missing
       public array $form = [];
 
       /**
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php
index dde912716f87..e4e270af73ad 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php
@@ -15,6 +15,9 @@
 )]
 class PrimitiveTypeConstraint extends SymfonyConstraint {
 
+  /**
+   * The default violation message.
+   */
   public $message = 'This value should be of the correct primitive type.';
 
 }
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php
index 23c7019bdcc1..850bb49f62d9 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php
@@ -15,6 +15,9 @@
 )]
 class UniqueFieldConstraint extends SymfonyConstraint {
 
+  /**
+   * The default violation message.
+   */
   public $message = 'A @entity_type with @field_name %value already exists.';
 
   /**
diff --git a/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraint.php b/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraint.php
index 360f20da2f84..c4dc0a5d45fb 100644
--- a/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraint.php
+++ b/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraint.php
@@ -15,8 +15,19 @@
 )]
 class ModerationStateConstraint extends SymfonyConstraint {
 
+  /**
+   * The default violation message.
+   */
   public $message = 'Invalid state transition from %from to %to';
+
+  /**
+   * The violation message when there is an invalid stated.
+   */
   public $invalidStateMessage = 'State %state does not exist on %workflow workflow';
+
+  /**
+   * The violation message when there is an invalid transition.
+   */
   public $invalidTransitionAccess = 'You do not have access to transition from %original_state to %new_state';
 
 }
diff --git a/core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php b/core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php
index fd2300a7ca18..f8004c1a1152 100644
--- a/core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php
+++ b/core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php
@@ -16,6 +16,11 @@
 )]
 class FileUriUnique extends UniqueFieldConstraint {
 
+  /**
+   * The error message.
+   *
+   * @var string
+   */
   public $message = 'The file %value already exists. Enter a unique file URI.';
 
   /**
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php
index 739ebce3bac7..18fe46c4d55f 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php
@@ -15,6 +15,11 @@
 )]
 class LinkAccessConstraint extends SymfonyConstraint {
 
+  /**
+   * The error message.
+   *
+   * @var string
+   */
   public $message = "The path '@uri' is inaccessible.";
 
 }
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php
index 398e8dc5b7ce..bd383c0c4eb2 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php
@@ -15,6 +15,11 @@
 )]
 class LinkExternalProtocolsConstraint extends SymfonyConstraint {
 
+  /**
+   * The error message.
+   *
+   * @var string
+   */
   public $message = "The path '@uri' is invalid.";
 
 }
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php
index f266b37a1d7f..6d25cf00a25f 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php
@@ -15,6 +15,11 @@
 )]
 class LinkNotExistingInternalConstraint extends SymfonyConstraint {
 
+  /**
+   * The error message.
+   *
+   * @var string
+   */
   public $message = "The path '@uri' is invalid.";
 
 }
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
index 38d5c6d4c3c2..83333afdaad2 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
@@ -15,6 +15,11 @@
 )]
 class LinkTypeConstraint extends SymfonyConstraint {
 
+  /**
+   * The error message.
+   *
+   * @var string
+   */
   public $message = "The path '@uri' is invalid.";
 
 }
diff --git a/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraint.php b/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraint.php
index b1edc89626e9..117bdb69a0a1 100644
--- a/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraint.php
+++ b/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraint.php
@@ -15,9 +15,24 @@
 )]
 class MenuSettingsConstraint extends SymfonyConstraint {
 
+  /**
+   * The default violation message.
+   */
   public $message = 'You can only change the menu settings for the <em>published</em> version of this content.';
+
+  /**
+   * The violation message when the weight cannot be changed.
+   */
   public $messageWeight = 'You can only change the menu link weight for the <em>published</em> version of this content.';
+
+  /**
+   * The violation message when changing the parent for a unpublished content.
+   */
   public $messageParent = 'You can only change the parent menu link for the <em>published</em> version of this content.';
+
+  /**
+   * The violation message when removing a menu link for unpublished content.
+   */
   public $messageRemove = 'You can only remove the menu link in the <em>published</em> version of this content.';
 
 }
diff --git a/core/modules/path/src/Plugin/Validation/Constraint/PathAliasConstraint.php b/core/modules/path/src/Plugin/Validation/Constraint/PathAliasConstraint.php
index c40860aafe01..da92e7e35b11 100644
--- a/core/modules/path/src/Plugin/Validation/Constraint/PathAliasConstraint.php
+++ b/core/modules/path/src/Plugin/Validation/Constraint/PathAliasConstraint.php
@@ -15,6 +15,9 @@
 )]
 class PathAliasConstraint extends SymfonyConstraint {
 
+  /**
+   * The default violation message.
+   */
   public $message = 'You can only change the URL alias for the <em>published</em> version of this content.';
 
 }
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php b/core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php
index eb808902f8f6..92eb3809e58e 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php
@@ -15,6 +15,9 @@
 )]
 class UserMailUnique extends UniqueFieldConstraint {
 
+  /**
+   * The default violation message.
+   */
   public $message = 'The email address %value is already taken.';
 
 }
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php
index babf6b6fd077..f017147f5b69 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php
@@ -15,11 +15,34 @@
 )]
 class UserNameConstraint extends SymfonyConstraint {
 
+  /**
+   * The violation message when there is no username.
+   */
   public $emptyMessage = 'You must enter a username.';
+
+  /**
+   * The violation message when the username begins with whitespace.
+   */
   public $spaceBeginMessage = 'The username cannot begin with a space.';
+
+  /**
+   * The violation message when the username ends with whitespace.
+   */
   public $spaceEndMessage = 'The username cannot end with a space.';
+
+  /**
+   * The violation message when the username has consecutive whitespace.
+   */
   public $multipleSpacesMessage = 'The username cannot contain multiple spaces in a row.';
+
+  /**
+   * The violation message when the username uses an invalid character.
+   */
   public $illegalMessage = 'The username contains an illegal character.';
+
+  /**
+   * The violation message when the username length exceeds the maximum allowed.
+   */
   public $tooLongMessage = 'The username %name is too long: it must be %max characters or less.';
 
 }
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php b/core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php
index 3b52c8f6e45a..7484ecf4aefb 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php
@@ -15,6 +15,9 @@
 )]
 class UserNameUnique extends UniqueFieldConstraint {
 
+  /**
+   * The default violation message.
+   */
   public $message = 'The username %value is already taken.';
 
 }
diff --git a/core/modules/user/src/Plugin/views/filter/Name.php b/core/modules/user/src/Plugin/views/filter/Name.php
index a5ca2d40b767..6d18d5f1560d 100644
--- a/core/modules/user/src/Plugin/views/filter/Name.php
+++ b/core/modules/user/src/Plugin/views/filter/Name.php
@@ -16,6 +16,9 @@
 #[ViewsFilter("user_name")]
 class Name extends InOperator {
 
+  /**
+   * This filter is always considered multiple-valued.
+   */
   protected $alwaysMultiple = TRUE;
 
   /**
diff --git a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
index ab4f399f72b0..3279a33d6e53 100644
--- a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
+++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
@@ -55,8 +55,19 @@
  */
 abstract class ArgumentPluginBase extends HandlerBase implements CacheableDependencyInterface {
 
+  /**
+   * The validator to use.
+   */
   public $validator = NULL;
+
+  /**
+   * The name of the argument.
+   */
   public $argument = NULL;
+
+  /**
+   * The value for the argument.
+   */
   public $value = NULL;
 
   /**
diff --git a/core/modules/views/src/Plugin/views/argument/Formula.php b/core/modules/views/src/Plugin/views/argument/Formula.php
index 1bfc914d5ae9..3ffa4ac2b1ff 100644
--- a/core/modules/views/src/Plugin/views/argument/Formula.php
+++ b/core/modules/views/src/Plugin/views/argument/Formula.php
@@ -21,6 +21,9 @@
 )]
 class Formula extends ArgumentPluginBase {
 
+  /**
+   * An appropriate SQL string for the DB type and field type.
+   */
   public $formula = NULL;
 
   /**
diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
index 4b0e4d57fd44..c04abeccb1da 100644
--- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
+++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
@@ -78,6 +78,10 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
    */
   // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing
   public $field_alias = 'unknown';
+
+  /**
+   * An array of aliases.
+   */
   public $aliases = [];
 
   /**
diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php
index 36089e05aec8..bde4e41c11d7 100644
--- a/core/modules/views/src/Plugin/views/filter/InOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -22,6 +22,9 @@
 #[ViewsFilter("in_operator")]
 class InOperator extends FilterPluginBase implements FilterOperatorsInterface {
 
+  /**
+   * The default form type.
+   */
   protected $valueFormType = 'checkboxes';
 
   /**
diff --git a/core/modules/views/src/Plugin/views/filter/ManyToOne.php b/core/modules/views/src/Plugin/views/filter/ManyToOne.php
index f4049573b6ac..c086dcb24c5a 100644
--- a/core/modules/views/src/Plugin/views/filter/ManyToOne.php
+++ b/core/modules/views/src/Plugin/views/filter/ManyToOne.php
@@ -106,6 +106,9 @@ public function operators() {
     return $operators;
   }
 
+  /**
+   * The default form type.
+   */
   protected $valueFormType = 'select';
 
   protected function valueForm(&$form, FormStateInterface $form_state) {
diff --git a/core/modules/views/src/Plugin/views/filter/NumericFilter.php b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
index 1acda0990412..7de7ddfb3a8d 100644
--- a/core/modules/views/src/Plugin/views/filter/NumericFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -13,6 +13,9 @@
 #[ViewsFilter("numeric")]
 class NumericFilter extends FilterPluginBase implements FilterOperatorsInterface {
 
+  /**
+   * Exposed filter options.
+   */
   protected $alwaysMultiple = TRUE;
 
   protected function defineOptions() {
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index d7a66fe42aa4..c50f67f2d5fd 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -89,9 +89,12 @@
   <rule ref="Drupal.Commenting.TodoComment" />
   <rule ref="Drupal.Commenting.VariableComment">
     <!-- Sniff for: DuplicateVar, EmptyVar, IncorrectVarType, InlineVariableName, WrongStyle -->
-    <exclude name="Drupal.Commenting.VariableComment.Missing"/>
     <exclude name="Drupal.Commenting.VariableComment.MissingVar"/>
   </rule>
+  <rule ref="Drupal.Commenting.VariableComment.Missing">
+    <exclude-pattern>./core/tests/*</exclude-pattern>
+    <exclude-pattern>./core/*/tests/*</exclude-pattern>
+  </rule>
   <rule ref="Drupal.ControlStructures.ControlSignature"/>
   <rule ref="Drupal.ControlStructures.ElseIf"/>
   <rule ref="Drupal.ControlStructures.InlineControlStructure"/>
-- 
GitLab