From fcbdd1b86a5867f2382b5c68d3d1d3429a374a55 Mon Sep 17 00:00:00 2001
From: Tim Rohaly <tr@202830.no-reply.drupal.org>
Date: Mon, 9 Dec 2019 05:25:05 +0000
Subject: [PATCH] Clean up some code: Whitespace, quoting, comments, and text
 strings.

---
 config/schema/rules.context.schema.yml           |  2 +-
 config/schema/rules.expression.schema.yml        |  6 +++---
 src/Context/ContextConfig.php                    |  2 +-
 src/Core/Annotation/RulesAction.php              |  6 ++++--
 src/Core/RulesActionBase.php                     | 13 +++++++++++++
 src/Core/RulesActionManager.php                  |  8 ++++----
 src/Entity/ReactionRuleStorage.php               |  2 +-
 src/Form/Expression/ContextFormTrait.php         |  1 -
 src/Plugin/Condition/DataListCountIs.php         |  4 ++--
 src/Plugin/RulesAction/SystemSendEmail.php       |  2 +-
 src/Plugin/RulesDataProcessor/TokenProcessor.php |  4 +++-
 src/Routing/RulesUiRouteSubscriber.php           |  4 ++++
 src/Ui/RulesUiConfigHandler.php                  |  1 -
 13 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/config/schema/rules.context.schema.yml b/config/schema/rules.context.schema.yml
index 9e2169e1..74ae08e9 100644
--- a/config/schema/rules.context.schema.yml
+++ b/config/schema/rules.context.schema.yml
@@ -23,7 +23,7 @@ rules.context.values:
   label: 'Context values'
   mapping:
   # The entries depend on the plugin here. Plugins have to extend this and
-  # provide a suiting schema.
+  # provide a suitable schema.
 
 rules.context.processors:
   type: ignore
diff --git a/config/schema/rules.expression.schema.yml b/config/schema/rules.expression.schema.yml
index ab6d4068..bf1bf4f0 100644
--- a/config/schema/rules.expression.schema.yml
+++ b/config/schema/rules.expression.schema.yml
@@ -10,7 +10,7 @@ rules_expression:
 
 rules_expression.rules_condition:
   type: rules_expression
-  label: "Rules condition configuration"
+  label: 'Rules condition configuration'
   mapping:
     id:
       type: string
@@ -39,7 +39,7 @@ rules_expression.rules_condition:
 
 rules_expression.rules_action:
   type: rules_expression
-  label: "Rules action configuration"
+  label: 'Rules action configuration'
   mapping:
     id:
       type: string
@@ -100,7 +100,7 @@ rules_expression.rules_action_set:
 
 rules_expression.rules_rule:
   type: rules_expression
-  label: "Rule"
+  label: 'Rule'
   mapping:
     id:
       type: string
diff --git a/src/Context/ContextConfig.php b/src/Context/ContextConfig.php
index 0d1af488..d0731aab 100644
--- a/src/Context/ContextConfig.php
+++ b/src/Context/ContextConfig.php
@@ -164,7 +164,7 @@ class ContextConfig {
    * @return array
    *   The config array, with the following keys set:
    *   - context_map: An array of data selectors, keyed by context name.
-   *   - context An array of context values, keyed by context.
+   *   - context_values: An array of context values, keyed by context name.
    *   - context_processors: An array of data processor config, keyed by context
    *     name and process plugin id.
    *   - provides_mapping: An array of context names to use for provided
diff --git a/src/Core/Annotation/RulesAction.php b/src/Core/Annotation/RulesAction.php
index 120bc946..40d00956 100644
--- a/src/Core/Annotation/RulesAction.php
+++ b/src/Core/Annotation/RulesAction.php
@@ -58,7 +58,8 @@ class RulesAction extends Plugin {
   /**
    * An array of context definitions describing the context used by the plugin.
    *
-   * Array keys are the names of the contexts and values are context definitions.
+   * Array keys are the names of the context variables and values are the
+   * context definitions.
    *
    * @var \Drupal\Core\Annotation\ContextDefinition[]
    */
@@ -67,7 +68,8 @@ class RulesAction extends Plugin {
   /**
    * Defines the provided context of the action plugin.
    *
-   * Array keys are the names of the contexts and values are context definitions.
+   * Array keys are the names of the context variables and values are the
+   * context definitions.
    *
    * @var \Drupal\Core\Annotation\ContextDefinition[]
    */
diff --git a/src/Core/RulesActionBase.php b/src/Core/RulesActionBase.php
index 021149a1..28267b72 100644
--- a/src/Core/RulesActionBase.php
+++ b/src/Core/RulesActionBase.php
@@ -58,6 +58,8 @@ abstract class RulesActionBase extends ContextAwarePluginBase implements RulesAc
 
   /**
    * {@inheritdoc}
+   *
+   * @todo this documentation is not actually inherited from any interface.
    */
   public function getConfiguration() {
     return [
@@ -67,6 +69,8 @@ abstract class RulesActionBase extends ContextAwarePluginBase implements RulesAc
 
   /**
    * {@inheritdoc}
+   *
+   * @todo this documentation is not actually inherited from any interface.
    */
   public function setConfiguration(array $configuration) {
     $this->configuration = $configuration + $this->defaultConfiguration();
@@ -75,6 +79,9 @@ abstract class RulesActionBase extends ContextAwarePluginBase implements RulesAc
 
   /**
    * {@inheritdoc}
+   *
+   * @todo this documentation is not actually inherited from any interface.
+   * Do we need this empty implementation?
    */
   public function defaultConfiguration() {
     return [];
@@ -82,6 +89,9 @@ abstract class RulesActionBase extends ContextAwarePluginBase implements RulesAc
 
   /**
    * {@inheritdoc}
+   *
+   * @todo this documentation is not actually inherited from any interface.
+   * Do we need this empty implementation?
    */
   public function calculateDependencies() {
     return [];
@@ -89,6 +99,9 @@ abstract class RulesActionBase extends ContextAwarePluginBase implements RulesAc
 
   /**
    * {@inheritdoc}
+   *
+   * @todo this documentation is not actually inherited from any interface.
+   * Do we need this empty implementation?
    */
   public function executeMultiple(array $objects) {
     // @todo Remove this once it is removed from the interface.
diff --git a/src/Core/RulesActionManager.php b/src/Core/RulesActionManager.php
index 5f92ad75..f9518497 100644
--- a/src/Core/RulesActionManager.php
+++ b/src/Core/RulesActionManager.php
@@ -12,11 +12,11 @@ use Drupal\rules\Context\AnnotatedClassDiscovery;
 use Drupal\rules\Core\Annotation\RulesAction;
 
 /**
- * Provides an Action plugin manager for the Rules actions API.
+ * Provides a RulesAction plugin manager for the Rules actions API.
  *
- * @see \Drupal\Core\Annotation\Action
- * @see \Drupal\Core\Action\ActionInterface
- * @see \Drupal\Core\Action\ActionBase
+ * @see \Drupal\rules\Core\Annotation\RulesAction
+ * @see \Drupal\rules\Core\RulesActionInterface
+ * @see \Drupal\rules\Core\RulesActionBase
  * @see plugin_api
  */
 class RulesActionManager extends DefaultPluginManager implements RulesActionManagerInterface {
diff --git a/src/Entity/ReactionRuleStorage.php b/src/Entity/ReactionRuleStorage.php
index b2dfd750..ca89fbca 100644
--- a/src/Entity/ReactionRuleStorage.php
+++ b/src/Entity/ReactionRuleStorage.php
@@ -56,7 +56,7 @@ class ReactionRuleStorage extends ConfigEntityStorage {
    * @param \Drupal\Core\State\StateInterface $state_service
    *   The state service.
    * @param \Drupal\Core\DrupalKernelInterface $drupal_kernel
-   *   The drupal kernel.
+   *   The Drupal kernel.
    * @param \Drupal\rules\Core\RulesEventManager $event_manager
    *   The Rules event manager.
    * @param \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface|null $memory_cache
diff --git a/src/Form/Expression/ContextFormTrait.php b/src/Form/Expression/ContextFormTrait.php
index fbf0adf7..61721a62 100644
--- a/src/Form/Expression/ContextFormTrait.php
+++ b/src/Form/Expression/ContextFormTrait.php
@@ -11,7 +11,6 @@ use Drupal\rules\Context\DataProcessorManagerTrait;
  * Provides form logic for handling contexts when configuring an expression.
  */
 trait ContextFormTrait {
-
   use DataProcessorManagerTrait;
 
   /**
diff --git a/src/Plugin/Condition/DataListCountIs.php b/src/Plugin/Condition/DataListCountIs.php
index c611478c..c64a8eef 100644
--- a/src/Plugin/Condition/DataListCountIs.php
+++ b/src/Plugin/Condition/DataListCountIs.php
@@ -9,12 +9,12 @@ use Drupal\rules\Core\RulesConditionBase;
  *
  * @Condition(
  *   id = "rules_list_count_is",
- *   label = @Translation("List Count Comparison"),
+ *   label = @Translation("List count comparison"),
  *   category = @Translation("Data"),
  *   context = {
  *     "list" = @ContextDefinition("list",
  *       label = @Translation("List"),
- *       description = @Translation("A multi value data element to have its count compared, specified by using a data selector, eg 'node.uid.entity.roles'.")
+ *       description = @Translation("A multi-valued data element to have its count compared, specified by using a data selector, eg 'node.uid.entity.roles'.")
  *     ),
  *     "operator" = @ContextDefinition("string",
  *       label = @Translation("Operator"),
diff --git a/src/Plugin/RulesAction/SystemSendEmail.php b/src/Plugin/RulesAction/SystemSendEmail.php
index 821bffc4..1f3acb86 100644
--- a/src/Plugin/RulesAction/SystemSendEmail.php
+++ b/src/Plugin/RulesAction/SystemSendEmail.php
@@ -28,7 +28,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
  *     ),
  *     "message" = @ContextDefinition("string",
  *       label = @Translation("Message"),
- *       description = @Translation("The email's message body.")
+ *       description = @Translation("The email's message body. This must be plain text, but may contain tokens.")
  *     ),
  *     "reply" = @ContextDefinition("email",
  *       label = @Translation("Reply to"),
diff --git a/src/Plugin/RulesDataProcessor/TokenProcessor.php b/src/Plugin/RulesDataProcessor/TokenProcessor.php
index 163f2c49..c9e2fd66 100644
--- a/src/Plugin/RulesDataProcessor/TokenProcessor.php
+++ b/src/Plugin/RulesDataProcessor/TokenProcessor.php
@@ -64,7 +64,9 @@ class TokenProcessor extends PluginBase implements DataProcessorInterface, Conta
     foreach ($placeholders_by_data as $variable_name => $placeholders) {
       // Note that accessing an unavailable variable will throw an evaluation
       // exception. That's exactly what needs to happen. Invalid tokens must
-      // be checked when checking integrity.
+      // be detected when checking integrity. The Rule must not be executed
+      // if the integrity check fails. Runtime is too late to handle
+      // invalid tokens gracefully.
       $data[$variable_name] = $rules_state->getVariable($variable_name);
     }
     return $this->placeholderResolver->replacePlaceHolders($value, $data);
diff --git a/src/Routing/RulesUiRouteSubscriber.php b/src/Routing/RulesUiRouteSubscriber.php
index 9cdf0e83..c444c7c8 100644
--- a/src/Routing/RulesUiRouteSubscriber.php
+++ b/src/Routing/RulesUiRouteSubscriber.php
@@ -81,6 +81,7 @@ class RulesUiRouteSubscriber extends RouteSubscriberBase {
       ->addRequirements($requirements);
     $collection->add($ui_definition->base_route . '.expression.add', $route);
 
+    // Route for editing expressions in a Rule.
     $route = (new Route($base_route->getPath() . '/edit/{uuid}'))
       ->addDefaults([
         '_form' => '\Drupal\rules\Form\EditExpressionForm',
@@ -90,6 +91,7 @@ class RulesUiRouteSubscriber extends RouteSubscriberBase {
       ->addRequirements($requirements);
     $collection->add($ui_definition->base_route . '.expression.edit', $route);
 
+    // Route for deleting expressions from a Rule.
     $route = (new Route($base_route->getPath() . '/delete/{uuid}'))
       ->addDefaults([
         '_form' => '\Drupal\rules\Form\DeleteExpressionForm',
@@ -99,6 +101,7 @@ class RulesUiRouteSubscriber extends RouteSubscriberBase {
       ->addRequirements($requirements);
     $collection->add($ui_definition->base_route . '.expression.delete', $route);
 
+    // Route to break the lock of an edited rule.
     $route = (new Route($base_route->getPath() . '/break-lock'))
       ->addDefaults([
         '_form' => '\Drupal\rules\Form\BreakLockForm',
@@ -108,6 +111,7 @@ class RulesUiRouteSubscriber extends RouteSubscriberBase {
       ->addRequirements($requirements);
     $collection->add($ui_definition->base_route . '.break_lock', $route);
 
+    // Route for data selector autocomplete.
     $route = (new Route($base_route->getPath() . '/autocomplete/{uuid}'))
       ->addDefaults([
         '_controller' => '\Drupal\rules\Controller\AutocompleteController::autocomplete',
diff --git a/src/Ui/RulesUiConfigHandler.php b/src/Ui/RulesUiConfigHandler.php
index 47c0a67b..dd40adb0 100644
--- a/src/Ui/RulesUiConfigHandler.php
+++ b/src/Ui/RulesUiConfigHandler.php
@@ -31,7 +31,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
  * @see \Drupal\rules\Ui\RulesUiDefinition::settings()
  */
 class RulesUiConfigHandler extends PluginBase implements RulesUiHandlerInterface, ContainerFactoryPluginInterface {
-
   use TempStoreTrait;
 
   /**
-- 
GitLab