Commit 0a0168b2 authored by Jonathan Smith's avatar Jonathan Smith Committed by Jonathan Smith
Browse files

Issue #3176822 by jonathan1055: Fix coding standards for Coder 8.3.15

parent a99315ec
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1193,7 +1193,7 @@ function scheduler_migrate_prepare_row(Row $row, MigrateSourceInterface $source,
      );
      // Two third-party-settings have changed name and value, so convert these.
      if ($config_name == 'use_vertical_tabs') {
        if (unserialize($setting->value) == 1) {
        if (unserialize($setting->value, ['allowed_classes' => FALSE]) == 1) {
          $third_party_settings['fields_display_mode'] = 'vertical_tab';
        }
        else {
@@ -1201,7 +1201,7 @@ function scheduler_migrate_prepare_row(Row $row, MigrateSourceInterface $source,
        }
      }
      elseif ($config_name == 'expand_fieldset') {
        if (unserialize($setting->value) == 1) {
        if (unserialize($setting->value, ['allowed_classes' => FALSE]) == 1) {
          $third_party_settings['expand_fieldset'] = 'always';
        }
        else {
@@ -1210,7 +1210,7 @@ function scheduler_migrate_prepare_row(Row $row, MigrateSourceInterface $source,
      }
      else {
        // The remaining eight settings are exactly the same as in Drupal 7.
        $third_party_settings[$config_name] = unserialize($setting->value);
        $third_party_settings[$config_name] = unserialize($setting->value, ['allowed_classes' => FALSE]);
      }
    }
    $row->setSourceProperty('scheduler_third_party_settings', $third_party_settings);
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ function scheduler_token_info() {
function scheduler_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $token_service = \Drupal::token();
  $date_formatter = \Drupal::service('date.formatter');
  $language_code = isset($options['langcode']) ? $options['langcode'] : NULL;
  $language_code = $options['langcode'] ?? NULL;
  $replacements = [];

  $plugin_types = \Drupal::service('scheduler.manager')->getPluginEntityTypes();
+2 −13
Original line number Diff line number Diff line
@@ -68,28 +68,17 @@ class SchedulerRulesEventsTest extends SchedulerBrowserTestBase {
      24 => ['scheduler:taxonomy_term_has_been_unpublished_via_cron', 'Scheduler has unpublished this taxonomy term during cron.'],
    ];

    // PHPCS throws a false-positive 'variable $var is undefined' message when
    // the variable is defined by list( ) syntax. To avoid the unwanted warnings
    // we can put phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
    // before each line that produces a warning of this type.
    // This has been fixed in Coder 8.3.10 which is used in Core 9.1.
    // @see https://www.drupal.org/project/coder/issues/2876245
    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
    foreach ($rule_data as $i => list($event_name, $description)) {
      // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
    $rule = [];
    foreach ($rule_data as $i => [$event_name, $description]) {
      $rule[$i] = $this->expressionManager->createRule();
      // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
      $this->message[$i] = 'RULES message ' . $i . '. ' . $description;
      // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
      $rule[$i]->addAction('rules_system_message', ContextConfig::create()
        ->setValue('message', $this->message[$i])
        ->setValue('type', 'status')
        );
      $config_entity = $this->rulesStorage->create([
        'id' => 'rule' . $i,
        // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
        'events' => [['event_name' => $event_name]],
        // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
        'expression' => $rule[$i]->getConfiguration(),
      ]);
      $config_entity->save();
+28 −28
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ function scheduler_api_test_scheduler_publishing_allowed(EntityInterface $entity
/**
 * Generic function to check if the entity is allowed to be published.
 */
function _api_publishing_allowed(EntityInterface $entity) {
function _scheduler_api_test_publishing_allowed(EntityInterface $entity) {
  // If there is no 'Approved for Publishing' field or we are not dealing with
  // an entity designed for this test then allow publishing.
  if (!isset($entity->field_approved_publishing) || !stristr($entity->label(), "blue {$entity->getEntityTypeId()}")) {
@@ -246,7 +246,7 @@ function _api_publishing_allowed(EntityInterface $entity) {
 */
function scheduler_api_test_scheduler_node_publishing_allowed(NodeInterface $node) {
  // Use the generic publishing_allowed helper function.
  return _api_publishing_allowed($node);
  return _scheduler_api_test_publishing_allowed($node);
}

/**
@@ -254,7 +254,7 @@ function scheduler_api_test_scheduler_node_publishing_allowed(NodeInterface $nod
 */
function scheduler_api_test_scheduler_media_publishing_allowed(MediaInterface $media) {
  // Use the generic publishing_allowed helper function.
  return _api_publishing_allowed($media);
  return _scheduler_api_test_publishing_allowed($media);
}

/**
@@ -262,7 +262,7 @@ function scheduler_api_test_scheduler_media_publishing_allowed(MediaInterface $m
 */
function scheduler_api_test_scheduler_commerce_product_publishing_allowed(ProductInterface $product) {
  // Use the generic publishing_allowed helper function.
  return _api_publishing_allowed($product);
  return _scheduler_api_test_publishing_allowed($product);
}

/**
@@ -275,7 +275,7 @@ function scheduler_api_test_scheduler_unpublishing_allowed(EntityInterface $enti
/**
 * Generic function to check if the entity is allowed to be unpublished.
 */
function _api_unpublishing_allowed(EntityInterface $entity) {
function _scheduler_api_test_unpublishing_allowed(EntityInterface $entity) {
  // If there is no 'Approved for Unpublishing' field or we are not dealing with
  // an entity designed for this test then allow unpublishing.
  if (!isset($entity->field_approved_unpublishing) || !stristr($entity->label(), "red {$entity->getEntityTypeId()}")) {
@@ -310,7 +310,7 @@ function _api_unpublishing_allowed(EntityInterface $entity) {
 */
function scheduler_api_test_scheduler_node_unpublishing_allowed(NodeInterface $node) {
  // Use the generic unpublishing_allowed helper function.
  return _api_unpublishing_allowed($node);
  return _scheduler_api_test_unpublishing_allowed($node);
}

/**
@@ -318,7 +318,7 @@ function scheduler_api_test_scheduler_node_unpublishing_allowed(NodeInterface $n
 */
function scheduler_api_test_scheduler_media_unpublishing_allowed(MediaInterface $media) {
  // Use the generic unpublishing_allowed helper function.
  return _api_unpublishing_allowed($media);
  return _scheduler_api_test_unpublishing_allowed($media);
}

/**
@@ -326,7 +326,7 @@ function scheduler_api_test_scheduler_media_unpublishing_allowed(MediaInterface
 */
function scheduler_api_test_scheduler_commerce_product_unpublishing_allowed(ProductInterface $product) {
  // Use the generic unpublishing_allowed helper function.
  return _api_unpublishing_allowed($product);
  return _scheduler_api_test_unpublishing_allowed($product);
}

/**
@@ -346,7 +346,7 @@ function scheduler_api_test_scheduler_hide_publish_date($form, $form_state, $ent
/**
 * Generic function to hide the publish_on date field.
 */
function _api_hide_publish_date($form, $form_state, $entity) {
function _scheduler_api_test_hide_publish_date($form, $form_state, $entity) {
  // Hide the publish_on field if the title contains 'green {type}'.
  if (stristr($entity->label(), "green {$entity->getEntityTypeId()}")) {
    \Drupal::messenger()->addMessage(t('Scheduler_Api_Test: The publish_on field is hidden for green.'), 'status', FALSE);
@@ -362,7 +362,7 @@ function _api_hide_publish_date($form, $form_state, $entity) {
 */
function scheduler_api_test_scheduler_node_hide_publish_date($form, $form_state, $entity) {
  // Use the generic hide_publish_date helper function.
  return _api_hide_publish_date($form, $form_state, $entity);
  return _scheduler_api_test_hide_publish_date($form, $form_state, $entity);
}

/**
@@ -370,7 +370,7 @@ function scheduler_api_test_scheduler_node_hide_publish_date($form, $form_state,
 */
function scheduler_api_test_scheduler_media_hide_publish_date($form, $form_state, $entity) {
  // Use the generic hide_publish_date helper function.
  return _api_hide_publish_date($form, $form_state, $entity);
  return _scheduler_api_test_hide_publish_date($form, $form_state, $entity);
}

/**
@@ -378,7 +378,7 @@ function scheduler_api_test_scheduler_media_hide_publish_date($form, $form_state
 */
function scheduler_api_test_scheduler_commerce_product_hide_publish_date($form, $form_state, $entity) {
  // Use the generic hide_publish_date helper function.
  return _api_hide_publish_date($form, $form_state, $entity);
  return _scheduler_api_test_hide_publish_date($form, $form_state, $entity);
}

/**
@@ -386,7 +386,7 @@ function scheduler_api_test_scheduler_commerce_product_hide_publish_date($form,
 */
function scheduler_api_test_scheduler_taxonomy_term_hide_publish_date($form, $form_state, $entity) {
  // Use the generic hide_publish_date helper function.
  return _api_hide_publish_date($form, $form_state, $entity);
  return _scheduler_api_test_hide_publish_date($form, $form_state, $entity);
}

/**
@@ -406,7 +406,7 @@ function scheduler_api_test_scheduler_hide_unpublish_date($form, $form_state, $e
/**
 * Generic function to hide the unpublish_on date field.
 */
function _api_hide_unpublish_date($form, $form_state, $entity) {
function _scheduler_api_test_hide_unpublish_date($form, $form_state, $entity) {
  // Hide the unpublish_on field if the title contains 'green {type}'.
  if (stristr($entity->label(), "green {$entity->getEntityTypeId()}")) {
    \Drupal::messenger()->addMessage(t('Scheduler_Api_Test: The unpublish_on field is hidden for green.'), 'status', FALSE);
@@ -422,7 +422,7 @@ function _api_hide_unpublish_date($form, $form_state, $entity) {
 */
function scheduler_api_test_scheduler_node_hide_unpublish_date($form, $form_state, $entity) {
  // Use the generic hide_unpublish_date helper function.
  return _api_hide_unpublish_date($form, $form_state, $entity);
  return _scheduler_api_test_hide_unpublish_date($form, $form_state, $entity);
}

/**
@@ -430,7 +430,7 @@ function scheduler_api_test_scheduler_node_hide_unpublish_date($form, $form_stat
 */
function scheduler_api_test_scheduler_media_hide_unpublish_date($form, $form_state, $entity) {
  // Use the generic hide_unpublish_date helper function.
  return _api_hide_unpublish_date($form, $form_state, $entity);
  return _scheduler_api_test_hide_unpublish_date($form, $form_state, $entity);
}

/**
@@ -438,7 +438,7 @@ function scheduler_api_test_scheduler_media_hide_unpublish_date($form, $form_sta
 */
function scheduler_api_test_scheduler_commerce_product_hide_unpublish_date($form, $form_state, $entity) {
  // Use the generic hide_unpublish_date helper function.
  return _api_hide_unpublish_date($form, $form_state, $entity);
  return _scheduler_api_test_hide_unpublish_date($form, $form_state, $entity);
}

/**
@@ -446,7 +446,7 @@ function scheduler_api_test_scheduler_commerce_product_hide_unpublish_date($form
 */
function scheduler_api_test_scheduler_taxonomy_term_hide_unpublish_date($form, $form_state, $entity) {
  // Use the generic hide_unpublish_date helper function.
  return _api_hide_unpublish_date($form, $form_state, $entity);
  return _scheduler_api_test_hide_unpublish_date($form, $form_state, $entity);
}

/**
@@ -467,7 +467,7 @@ function scheduler_api_test_scheduler_publish_process(EntityInterface $entity) {
/**
 * Generic function to process third-party publishing.
 */
function _api_publish_process(EntityInterface $entity) {
function _scheduler_api_test_publish_process(EntityInterface $entity) {
  // Entities with 'yellow {type}' in the title are simulated to be processed
  // by this hook, and will not be published by Scheduler.
  if (stristr($entity->label(), "yellow {$entity->getEntityTypeId()}")) {
@@ -485,7 +485,7 @@ function _api_publish_process(EntityInterface $entity) {
 */
function scheduler_api_test_scheduler_node_publish_process(NodeInterface $node) {
  // Use the generic publish_process helper function.
  return _api_publish_process($node);
  return _scheduler_api_test_publish_process($node);
}

/**
@@ -493,7 +493,7 @@ function scheduler_api_test_scheduler_node_publish_process(NodeInterface $node)
 */
function scheduler_api_test_scheduler_media_publish_process(MediaInterface $media) {
  // Use the generic publish_process helper function.
  return _api_publish_process($media);
  return _scheduler_api_test_publish_process($media);
}

/**
@@ -501,7 +501,7 @@ function scheduler_api_test_scheduler_media_publish_process(MediaInterface $medi
 */
function scheduler_api_test_scheduler_commerce_product_publish_process(ProductInterface $product) {
  // Use the generic publish_process helper function.
  return _api_publish_process($product);
  return _scheduler_api_test_publish_process($product);
}

/**
@@ -509,7 +509,7 @@ function scheduler_api_test_scheduler_commerce_product_publish_process(ProductIn
 */
function scheduler_api_test_scheduler_taxonomy_term_publish_process(TermInterface $term) {
  // Use the generic publish_process helper function.
  return _api_publish_process($term);
  return _scheduler_api_test_publish_process($term);
}

/**
@@ -530,7 +530,7 @@ function scheduler_api_test_scheduler_unpublish_process(EntityInterface $entity)
/**
 * Generic function to process third-party unpublishing.
 */
function _api_unpublish_process(EntityInterface $entity) {
function _scheduler_api_test_unpublish_process(EntityInterface $entity) {
  // Entities with 'orange {type}' in the title are simulated to be processed by
  // this hook, and will not be unpublished by Scheduler.
  if (stristr($entity->label(), "orange {$entity->getEntityTypeId()}")) {
@@ -548,7 +548,7 @@ function _api_unpublish_process(EntityInterface $entity) {
 */
function scheduler_api_test_scheduler_node_unpublish_process(NodeInterface $node) {
  // Use the generic unpublish_process helper function.
  return _api_unpublish_process($node);
  return _scheduler_api_test_unpublish_process($node);
}

/**
@@ -556,7 +556,7 @@ function scheduler_api_test_scheduler_node_unpublish_process(NodeInterface $node
 */
function scheduler_api_test_scheduler_media_unpublish_process(MediaInterface $media) {
  // Use the generic unpublish_process helper function.
  return _api_unpublish_process($media);
  return _scheduler_api_test_unpublish_process($media);
}

/**
@@ -564,7 +564,7 @@ function scheduler_api_test_scheduler_media_unpublish_process(MediaInterface $me
 */
function scheduler_api_test_scheduler_commerce_product_unpublish_process(ProductInterface $product) {
  // Use the generic unpublish_process helper function.
  return _api_unpublish_process($product);
  return _scheduler_api_test_unpublish_process($product);
}

/**
@@ -572,5 +572,5 @@ function scheduler_api_test_scheduler_commerce_product_unpublish_process(Product
 */
function scheduler_api_test_scheduler_taxonomy_term_unpublish_process(TermInterface $term) {
  // Use the generic unpublish_process helper function.
  return _api_unpublish_process($term);
  return _scheduler_api_test_unpublish_process($term);
}