diff --git a/og.views.inc b/og.views.inc
index 2d75cc3db..e21457ad9 100644
--- a/og.views.inc
+++ b/og.views.inc
@@ -59,7 +59,9 @@ function og_field_views_data(FieldStorageConfigInterface $field_storage) {
'title' => new TranslatableMarkup('@label referenced from @field_name', $args),
'label' => new TranslatableMarkup('@field_name: @label', $args),
'group' => $entity_type->getLabel(),
- 'help' => new TranslatableMarkup('Appears in: @bundles.', ['@bundles' => implode(', ', $field_storage->getBundles())]),
+ 'help' => new TranslatableMarkup('Appears in: @bundles.', [
+ '@bundles' => implode(', ', $field_storage->getBundles()),
+ ]),
'id' => 'standard',
'base' => $target_base_table,
'entity type' => $target_entity_type_id,
diff --git a/og_ui/src/Form/AdminSettingsForm.php b/og_ui/src/Form/AdminSettingsForm.php
index 69c87dc0d..710d68a1c 100644
--- a/og_ui/src/Form/AdminSettingsForm.php
+++ b/og_ui/src/Form/AdminSettingsForm.php
@@ -83,7 +83,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#default_value' => $config_og->get('node_access_strict'),
];
- // @todo: Port og_ui_admin_people_view.
+ // @todo Port og_ui_admin_people_view.
$form['og_delete_orphans'] = [
'#type' => 'checkbox',
'#title' => $this->t('Delete orphans'),
diff --git a/og_ui/tests/src/Functional/BundleFormAlterTest.php b/og_ui/tests/src/Functional/BundleFormAlterTest.php
index 7aa4574bf..7a31bb629 100644
--- a/og_ui/tests/src/Functional/BundleFormAlterTest.php
+++ b/og_ui/tests/src/Functional/BundleFormAlterTest.php
@@ -6,10 +6,10 @@
use Drupal\Core\Form\FormState;
use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\Tests\BrowserTestBase;
use Drupal\node\Entity\NodeType;
use Drupal\og\Og;
use Drupal\og_ui\BundleFormAlter;
-use Drupal\Tests\BrowserTestBase;
/**
* Test making a bundle a group and a group content.
diff --git a/src/Controller/OgAdminMembersController.php b/src/Controller/OgAdminMembersController.php
index 81f00810e..c6e67d9be 100644
--- a/src/Controller/OgAdminMembersController.php
+++ b/src/Controller/OgAdminMembersController.php
@@ -9,7 +9,7 @@
use Drupal\views\Views;
/**
- * OgAdminMembersController class.
+ * Displays the members administration page.
*/
class OgAdminMembersController extends ControllerBase {
diff --git a/src/Controller/SubscriptionController.php b/src/Controller/SubscriptionController.php
index 7ab1f6e62..11566fb66 100644
--- a/src/Controller/SubscriptionController.php
+++ b/src/Controller/SubscriptionController.php
@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
+use Drupal\og\Og;
use Drupal\og\OgAccessInterface;
use Drupal\og\OgMembershipInterface;
use Drupal\og\OgMembershipTypeInterface;
@@ -17,7 +18,6 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
-use Drupal\og\Og;
/**
* Controller for OG subscription routes.
@@ -100,7 +100,10 @@ public function subscribe($entity_type_id, EntityInterface $group, OgMembershipT
}
else {
$user_register_url = Url::fromRoute('user.register', [], $destination)->toString();
- $params = [':register' => $user_register_url, ':login' => $user_login_url];
+ $params = [
+ ':register' => $user_register_url,
+ ':login' => $user_login_url,
+ ];
$this->messenger->addMessage($this->t('In order to join any group, you must login or register a new account. After you have successfully done so, you will need to request membership again.', $params));
}
diff --git a/src/Entity/OgMembership.php b/src/Entity/OgMembership.php
index 268992d26..a347f0bc2 100644
--- a/src/Entity/OgMembership.php
+++ b/src/Entity/OgMembership.php
@@ -13,11 +13,11 @@
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
-use Drupal\user\UserInterface;
use Drupal\og\Og;
use Drupal\og\OgMembershipInterface;
use Drupal\og\OgRoleInterface;
use Drupal\user\EntityOwnerInterface;
+use Drupal\user\UserInterface;
/**
* The membership entity that connects a group and a user.
diff --git a/src/Form/GroupSubscribeForm.php b/src/Form/GroupSubscribeForm.php
index 5c4d29e84..7a7e8b7b2 100644
--- a/src/Form/GroupSubscribeForm.php
+++ b/src/Form/GroupSubscribeForm.php
@@ -39,9 +39,9 @@ class GroupSubscribeForm extends ContentEntityForm {
* The OG access service.
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository service.
- * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
+ * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface|null $entity_type_bundle_info
* The entity type bundle service.
- * @param \Drupal\Component\Datetime\TimeInterface $time
+ * @param \Drupal\Component\Datetime\TimeInterface|null $time
* The time service.
*
* @todo Set the `EntityRepositoryInterface` type hint on the second argument
@@ -50,7 +50,7 @@ class GroupSubscribeForm extends ContentEntityForm {
*
* @see https://github.com/Gizra/og/issues/397
*/
- public function __construct(OgAccessInterface $og_access, EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
+ public function __construct(OgAccessInterface $og_access, EntityRepositoryInterface $entity_repository, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, ?TimeInterface $time = NULL) {
parent::__construct($entity_repository, $entity_type_bundle_info, $time);
$this->ogAccess = $og_access;
}
diff --git a/src/GroupTypeManager.php b/src/GroupTypeManager.php
index 5a80fff91..75833b4fb 100644
--- a/src/GroupTypeManager.php
+++ b/src/GroupTypeManager.php
@@ -4,11 +4,11 @@
namespace Drupal\og;
+use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\RouteBuilderInterface;
-use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\og\Event\GroupCreationEvent;
use Drupal\og\Event\GroupCreationEventInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -268,7 +268,7 @@ public function addGroup($entity_type_id, $bundle_id) {
$groups = $editable->get('groups');
$groups[$entity_type_id][] = $bundle_id;
- // @todo, just key by bundle ID instead?
+ // @todo Key by bundle ID instead?
$groups[$entity_type_id] = array_unique($groups[$entity_type_id]);
$editable->set('groups', $groups);
diff --git a/src/MembershipManager.php b/src/MembershipManager.php
index 6d235087f..76d1fda6e 100644
--- a/src/MembershipManager.php
+++ b/src/MembershipManager.php
@@ -10,7 +10,6 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountInterface;
-use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\og\Entity\OgMembership;
use Drupal\user\UserInterface;
@@ -380,7 +379,8 @@ public function getGroupContentIds(EntityInterface $entity, array $entity_types
}
/** @var \Drupal\field\FieldStorageConfigInterface[] $fields */
- $fields = array_filter(FieldStorageConfig::loadMultiple($query->execute()), function (FieldStorageConfigInterface $field) use ($entity) {
+ $storage = $this->entityTypeManager->getStorage('field_storage_config');
+ $fields = array_filter($storage->loadMultiple($query->execute()), function (FieldStorageConfigInterface $field) use ($entity) {
$type_matches = $field->getSetting('target_type') === $entity->getEntityTypeId();
// If the list of target bundles is empty, it targets all bundles.
$bundle_matches = empty($field->getSetting('target_bundles')) || in_array($entity->bundle(), $field->getSetting('target_bundles'));
@@ -463,7 +463,7 @@ public function isMemberBlocked(EntityInterface $group, $user_id) {
* @return array
* The prepared array.
*/
- protected function prepareConditionArray(array $value, array $default = NULL) {
+ protected function prepareConditionArray(array $value, ?array $default = NULL) {
// Fall back to the default value if the passed in value is empty and a
// default value is given.
if (empty($value) && $default !== NULL) {
diff --git a/src/Og.php b/src/Og.php
index c72e8a5bb..73703952e 100644
--- a/src/Og.php
+++ b/src/Og.php
@@ -80,7 +80,7 @@ public static function createField($plugin_id, $entity_type, $bundle, array $set
$field_definition = FieldConfig::create($field_config);
$field_definition->save();
- // @todo: Verify this is still needed here.
+ // @todo Verify this is still needed here.
static::invalidateCache();
}
diff --git a/src/OgAccess.php b/src/OgAccess.php
index c8e3a826c..86576b807 100644
--- a/src/OgAccess.php
+++ b/src/OgAccess.php
@@ -129,7 +129,7 @@ public function __construct(ConfigFactoryInterface $config_factory, AccountProxy
/**
* {@inheritdoc}
*/
- public function userAccess(EntityInterface $group, string $permission, AccountInterface $user = NULL, bool $skip_alter = FALSE): AccessResultInterface {
+ public function userAccess(EntityInterface $group, string $permission, ?AccountInterface $user = NULL, bool $skip_alter = FALSE): AccessResultInterface {
$group_type_id = $group->getEntityTypeId();
$bundle = $group->bundle();
// As Og::isGroup depends on this config, we retrieve it here and set it as
@@ -223,7 +223,7 @@ public function userAccess(EntityInterface $group, string $permission, AccountIn
/**
* {@inheritdoc}
*/
- public function userAccessEntity(string $permission, EntityInterface $entity, AccountInterface $user = NULL): AccessResultInterface {
+ public function userAccessEntity(string $permission, EntityInterface $entity, ?AccountInterface $user = NULL): AccessResultInterface {
$result = AccessResult::neutral();
$entity_type = $entity->getEntityType();
@@ -262,7 +262,7 @@ public function userAccessEntity(string $permission, EntityInterface $entity, Ac
/**
* {@inheritdoc}
*/
- public function userAccessEntityOperation(string $operation, EntityInterface $entity, AccountInterface $user = NULL): AccessResultInterface {
+ public function userAccessEntityOperation(string $operation, EntityInterface $entity, ?AccountInterface $user = NULL): AccessResultInterface {
$result = AccessResult::neutral();
$entity_type = $entity->getEntityType();
@@ -307,7 +307,7 @@ public function userAccessEntityOperation(string $operation, EntityInterface $en
/**
* {@inheritdoc}
*/
- public function userAccessGroupContentEntityOperation(string $operation, EntityInterface $group_entity, EntityInterface $group_content_entity, AccountInterface $user = NULL): AccessResultInterface {
+ public function userAccessGroupContentEntityOperation(string $operation, EntityInterface $group_entity, EntityInterface $group_content_entity, ?AccountInterface $user = NULL): AccessResultInterface {
// Default to the current user.
$user = $user ?: $this->accountProxy->getAccount();
diff --git a/src/OgAccessInterface.php b/src/OgAccessInterface.php
index eecd2db18..f06704c5b 100644
--- a/src/OgAccessInterface.php
+++ b/src/OgAccessInterface.php
@@ -53,7 +53,7 @@ interface OgAccessInterface {
* @return \Drupal\Core\Access\AccessResultInterface
* An access result object.
*/
- public function userAccess(EntityInterface $group, string $permission, AccountInterface $user = NULL, bool $skip_alter = FALSE): AccessResultInterface;
+ public function userAccess(EntityInterface $group, string $permission, ?AccountInterface $user = NULL, bool $skip_alter = FALSE): AccessResultInterface;
/**
* Determines whether a user has a group permission in a given entity.
@@ -89,7 +89,7 @@ public function userAccess(EntityInterface $group, string $permission, AccountIn
*
* @see \Drupal\og\userAccess();
*/
- public function userAccessEntity(string $permission, EntityInterface $entity, AccountInterface $user = NULL): AccessResultInterface;
+ public function userAccessEntity(string $permission, EntityInterface $entity, ?AccountInterface $user = NULL): AccessResultInterface;
/**
* Checks whether a user can perform an operation on a given entity.
@@ -127,7 +127,7 @@ public function userAccessEntity(string $permission, EntityInterface $entity, Ac
*
* @see \Drupal\og\userAccessGroupContentEntityOperation();
*/
- public function userAccessEntityOperation(string $operation, EntityInterface $entity, AccountInterface $user = NULL): AccessResultInterface;
+ public function userAccessEntityOperation(string $operation, EntityInterface $entity, ?AccountInterface $user = NULL): AccessResultInterface;
/**
* Checks access for entity operations on group content in a specific group.
@@ -160,7 +160,7 @@ public function userAccessEntityOperation(string $operation, EntityInterface $en
* @return \Drupal\Core\Access\AccessResultInterface
* The access result object.
*/
- public function userAccessGroupContentEntityOperation(string $operation, EntityInterface $group_entity, EntityInterface $group_content_entity, AccountInterface $user = NULL): AccessResultInterface;
+ public function userAccessGroupContentEntityOperation(string $operation, EntityInterface $group_entity, EntityInterface $group_content_entity, ?AccountInterface $user = NULL): AccessResultInterface;
/**
* Resets the static cache.
diff --git a/src/Plugin/Action/AddSingleOgMembershipRole.php b/src/Plugin/Action/AddSingleOgMembershipRole.php
index c6064aead..a2f42007e 100644
--- a/src/Plugin/Action/AddSingleOgMembershipRole.php
+++ b/src/Plugin/Action/AddSingleOgMembershipRole.php
@@ -21,7 +21,7 @@ class AddSingleOgMembershipRole extends ChangeSingleOgMembershipRoleBase {
/**
* {@inheritdoc}
*/
- public function execute(OgMembership $membership = NULL) {
+ public function execute(?OgMembership $membership = NULL) {
if (!$membership) {
return;
}
diff --git a/src/Plugin/Action/ChangeMultipleOgMembershipRolesBase.php b/src/Plugin/Action/ChangeMultipleOgMembershipRolesBase.php
index 7ed0b606b..719bc0b7b 100644
--- a/src/Plugin/Action/ChangeMultipleOgMembershipRolesBase.php
+++ b/src/Plugin/Action/ChangeMultipleOgMembershipRolesBase.php
@@ -88,7 +88,7 @@ public function execute($object = NULL) {
/**
* {@inheritdoc}
*/
- public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+ public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
/** @var \Drupal\og\Entity\OgMembership $object */
// Only grant access if the user has permission to manage members in this
// group.
diff --git a/src/Plugin/Action/ChangeOgMembershipStateBase.php b/src/Plugin/Action/ChangeOgMembershipStateBase.php
index 08482265f..4fdb263cb 100644
--- a/src/Plugin/Action/ChangeOgMembershipStateBase.php
+++ b/src/Plugin/Action/ChangeOgMembershipStateBase.php
@@ -56,7 +56,7 @@ public static function create(ContainerInterface $container, array $configuratio
/**
* {@inheritdoc}
*/
- public function execute(OgMembership $membership = NULL) {
+ public function execute(?OgMembership $membership = NULL) {
if (!$membership) {
return;
}
@@ -66,7 +66,7 @@ public function execute(OgMembership $membership = NULL) {
/**
* {@inheritdoc}
*/
- public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+ public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
/** @var \Drupal\og\Entity\OgMembership $object */
// Deny access if the membership is not in the required state.
$original_state = $this->getOriginalState();
diff --git a/src/Plugin/Action/ChangeSingleOgMembershipRoleBase.php b/src/Plugin/Action/ChangeSingleOgMembershipRoleBase.php
index 83c1aff7d..b425c1b3a 100644
--- a/src/Plugin/Action/ChangeSingleOgMembershipRoleBase.php
+++ b/src/Plugin/Action/ChangeSingleOgMembershipRoleBase.php
@@ -105,7 +105,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
/**
* {@inheritdoc}
*/
- public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+ public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
/** @var \Drupal\og\Entity\OgMembership $object */
// Grant access if the user can manage members in this group.
$access = $this->ogAccess->userAccess($object->getGroup(), 'manage members', $account);
diff --git a/src/Plugin/Action/DeleteOgMembership.php b/src/Plugin/Action/DeleteOgMembership.php
index 2b4cd7b0d..4de67bc5a 100644
--- a/src/Plugin/Action/DeleteOgMembership.php
+++ b/src/Plugin/Action/DeleteOgMembership.php
@@ -61,7 +61,7 @@ public static function create(ContainerInterface $container, array $configuratio
/**
* {@inheritdoc}
*/
- public function execute(OgMembership $membership = NULL) {
+ public function execute(?OgMembership $membership = NULL) {
if (!$membership) {
return;
}
@@ -71,7 +71,7 @@ public function execute(OgMembership $membership = NULL) {
/**
* {@inheritdoc}
*/
- public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+ public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
/** @var \Drupal\og\Entity\OgMembership $object */
// Grant access if the user can manage members in this group.
$access = $this->ogAccess->userAccess($object->getGroup(), 'manage members', $account);
diff --git a/src/Plugin/Action/RemoveSingleOgMembershipRole.php b/src/Plugin/Action/RemoveSingleOgMembershipRole.php
index 8fb64acc3..3db38e831 100644
--- a/src/Plugin/Action/RemoveSingleOgMembershipRole.php
+++ b/src/Plugin/Action/RemoveSingleOgMembershipRole.php
@@ -20,7 +20,7 @@ class RemoveSingleOgMembershipRole extends ChangeSingleOgMembershipRoleBase {
/**
* {@inheritdoc}
*/
- public function execute(OgMembership $membership = NULL) {
+ public function execute(?OgMembership $membership = NULL) {
if (!$membership) {
return;
}
diff --git a/src/Plugin/Action/UnblockOgMembership.php b/src/Plugin/Action/UnblockOgMembership.php
index fdcb22ace..00fba336c 100644
--- a/src/Plugin/Action/UnblockOgMembership.php
+++ b/src/Plugin/Action/UnblockOgMembership.php
@@ -63,7 +63,7 @@ public static function create(ContainerInterface $container, array $configuratio
/**
* {@inheritdoc}
*/
- public function execute(OgMembership $membership = NULL) {
+ public function execute(?OgMembership $membership = NULL) {
if (!$membership) {
return;
}
@@ -73,7 +73,7 @@ public function execute(OgMembership $membership = NULL) {
/**
* {@inheritdoc}
*/
- public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+ public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
/** @var \Drupal\og\Entity\OgMembership $object */
// Deny access if the membership is not blocked.
if ($object->getState() !== OgMembershipInterface::STATE_BLOCKED) {
diff --git a/src/Plugin/Block/RecentGroupContentBlock.php b/src/Plugin/Block/RecentGroupContentBlock.php
index c3beb37c3..fcfe28ff4 100644
--- a/src/Plugin/Block/RecentGroupContentBlock.php
+++ b/src/Plugin/Block/RecentGroupContentBlock.php
@@ -10,7 +10,6 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
-use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\og\GroupTypeManagerInterface;
use Drupal\og\OgContextInterface;
@@ -219,7 +218,10 @@ public function getCacheTags() {
public function getCacheContexts() {
// The block varies by user because of the access check on the query that
// retrieves the group content.
- return Cache::mergeContexts(parent::getCacheContexts(), ['user', 'og_group_context']);
+ return Cache::mergeContexts(parent::getCacheContexts(), [
+ 'user',
+ 'og_group_context',
+ ]);
}
/**
@@ -236,14 +238,13 @@ protected function getGroupContent() {
$definition = $this->entityTypeManager->getDefinition($entity_type);
// Retrieve the fields which reference our entity type and bundle.
- $query = $this->entityTypeManager
- ->getStorage('field_storage_config')
- ->getQuery()
+ $field_storage_config_storage = $this->entityTypeManager->getStorage('field_storage_config');
+ $query = $field_storage_config_storage->getQuery()
->condition('type', OgGroupAudienceHelperInterface::GROUP_REFERENCE)
->condition('entity_type', $entity_type);
/** @var \Drupal\field\FieldStorageConfigInterface[] $fields */
- $fields = array_filter(FieldStorageConfig::loadMultiple($query->execute()), function (FieldStorageConfigInterface $field) use ($group) {
+ $fields = array_filter($field_storage_config_storage->loadMultiple($query->execute()), function (FieldStorageConfigInterface $field) use ($group) {
$type_matches = $field->getSetting('target_type') === $group->getEntityTypeId();
// If the list of target bundles is empty, it targets all bundles.
$bundle_matches = empty($field->getSetting('target_bundles')) || in_array($group->bundle(), $field->getSetting('target_bundles'));
diff --git a/src/Plugin/Condition/GroupType.php b/src/Plugin/Condition/GroupType.php
index 74e496295..09cd25407 100644
--- a/src/Plugin/Condition/GroupType.php
+++ b/src/Plugin/Condition/GroupType.php
@@ -139,7 +139,10 @@ public function summary() {
$group_types = $this->configuration['group_types'];
$last_group = array_pop($group_types);
$group_types = implode(', ', $group_types);
- return $this->t('The group type is @group_types or @last_group', ['@group_types' => $group_types, '@last_group' => $last_group]);
+ return $this->t('The group type is @group_types or @last_group', [
+ '@group_types' => $group_types,
+ '@last_group' => $last_group,
+ ]);
}
$group_type = reset($this->configuration['group_types']);
return $this->t('The group type is @group_type', ['@group_type' => $group_type]);
diff --git a/src/Plugin/Derivative/OgLocalTask.php b/src/Plugin/Derivative/OgLocalTask.php
index 66e3abe73..1ae210ca0 100644
--- a/src/Plugin/Derivative/OgLocalTask.php
+++ b/src/Plugin/Derivative/OgLocalTask.php
@@ -77,7 +77,12 @@ public function getDerivativeDefinitions($base_plugin_definition) {
];
}
+ // @todo Coder throws a false positive for this line. Remove this once the
+ // issue is fixed in the Coder project.
+ // @see https://www.drupal.org/project/coder/issues/3065679
+ // @codingStandardsIgnoreLine
foreach ($derivatives as &$entry) {
+ // @codingStandardsIgnoreLine
$entry += $base_plugin_definition;
}
diff --git a/src/Plugin/Field/FieldFormatter/GroupSubscribeFormatter.php b/src/Plugin/Field/FieldFormatter/GroupSubscribeFormatter.php
index ea8f88c3b..ee99d1404 100644
--- a/src/Plugin/Field/FieldFormatter/GroupSubscribeFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/GroupSubscribeFormatter.php
@@ -143,9 +143,15 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
return $elements;
}
- if (Og::isMember($group, $user, [OgMembershipInterface::STATE_ACTIVE, OgMembershipInterface::STATE_PENDING])) {
+ if (Og::isMember($group, $user, [
+ OgMembershipInterface::STATE_ACTIVE,
+ OgMembershipInterface::STATE_PENDING,
+ ])) {
$link['title'] = $this->t('Unsubscribe from group');
- $link['url'] = Url::fromRoute('og.unsubscribe', ['entity_type_id' => $entity_type_id, 'group' => $group->id()]);
+ $link['url'] = Url::fromRoute('og.unsubscribe', [
+ 'entity_type_id' => $entity_type_id,
+ 'group' => $group->id(),
+ ]);
$link['class'] = ['unsubscribe'];
}
else {
diff --git a/src/Plugin/Field/FieldType/OgStandardReferenceItem.php b/src/Plugin/Field/FieldType/OgStandardReferenceItem.php
index 72e728d66..ba4accd60 100644
--- a/src/Plugin/Field/FieldType/OgStandardReferenceItem.php
+++ b/src/Plugin/Field/FieldType/OgStandardReferenceItem.php
@@ -7,7 +7,7 @@
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
/**
- * Class OgStandardReferenceItem.
+ * Field item class for OG membership references.
*
* @FieldType(
* id = "og_standard_reference",
diff --git a/src/Plugin/Field/FieldWidget/OgComplex.php b/src/Plugin/Field/FieldWidget/OgComplex.php
index 3802d2c36..fe0cd54c2 100644
--- a/src/Plugin/Field/FieldWidget/OgComplex.php
+++ b/src/Plugin/Field/FieldWidget/OgComplex.php
@@ -32,7 +32,7 @@ class OgComplex extends EntityReferenceAutocompleteWidget {
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$parent = parent::formElement($items, $delta, $element, $form, $form_state);
- // todo: fix the definition in th UI level.
+ // @todo Fix the definition in the UI level.
$parent['target_id']['#selection_handler'] = 'og:default';
$parent['target_id']['#selection_settings']['field_mode'] = 'default';
@@ -110,7 +110,10 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
// table.
if ($is_multiple) {
$element = [
- '#title' => $this->t('@title (value @number)', ['@title' => $title, '@number' => $delta + 1]),
+ '#title' => $this->t('@title (value @number)', [
+ '@title' => $title,
+ '@number' => $delta + 1,
+ ]),
'#title_display' => 'invisible',
'#description' => '',
];
@@ -288,7 +291,7 @@ protected function otherGroupsWidget(FieldItemListInterface $items, FormStateInt
* @return array
* A single entity reference input.
*/
- public function otherGroupsSingle($delta, EntityInterface $entity = NULL, $weight_delta = 10) {
+ public function otherGroupsSingle(int $delta, ?EntityInterface $entity = NULL, $weight_delta = 10) {
$selection_settings = [
'other_groups' => TRUE,
'field_mode' => 'admin',
diff --git a/src/Plugin/OgDeleteOrphans/Batch.php b/src/Plugin/OgDeleteOrphans/Batch.php
index a429a54ae..103a847af 100644
--- a/src/Plugin/OgDeleteOrphans/Batch.php
+++ b/src/Plugin/OgDeleteOrphans/Batch.php
@@ -58,7 +58,10 @@ public static function batchSubmit($form, FormStateInterface $form_state) {
$batch = [];
$steps = \Drupal::queue('og_orphaned_group_content')->numberOfItems();
for ($i = 0; $i < $steps; $i++) {
- $batch['operations'][] = ['\Drupal\og\Plugin\OgDeleteOrphans\Batch::step', []];
+ $batch['operations'][] = [
+ '\Drupal\og\Plugin\OgDeleteOrphans\Batch::step',
+ [],
+ ];
}
batch_set($batch);
}
diff --git a/src/Plugin/Validation/Constraint/ValidOgMembershipReferenceConstraintValidator.php b/src/Plugin/Validation/Constraint/ValidOgMembershipReferenceConstraintValidator.php
index 4fd06b186..3cf690a43 100644
--- a/src/Plugin/Validation/Constraint/ValidOgMembershipReferenceConstraintValidator.php
+++ b/src/Plugin/Validation/Constraint/ValidOgMembershipReferenceConstraintValidator.php
@@ -17,7 +17,7 @@ class ValidOgMembershipReferenceConstraintValidator extends ConstraintValidator
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
- /* @var \Drupal\Core\Field\FieldItemInterface $value */
+ /** @var \Drupal\Core\Field\FieldItemInterface $value */
if (!isset($value)) {
return;
}
diff --git a/tests/src/Functional/GroupSubscribeFormatterTest.php b/tests/src/Functional/GroupSubscribeFormatterTest.php
index 04be293ca..ded38800d 100644
--- a/tests/src/Functional/GroupSubscribeFormatterTest.php
+++ b/tests/src/Functional/GroupSubscribeFormatterTest.php
@@ -4,12 +4,12 @@
namespace Drupal\Tests\og\Functional;
+use Drupal\Tests\BrowserTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
+use Drupal\og\Entity\OgRole;
use Drupal\og\Og;
use Drupal\og\OgRoleInterface;
-use Drupal\og\Entity\OgRole;
-use Drupal\Tests\BrowserTestBase;
/**
* Tests subscribe and un-subscribe formatter.
@@ -66,7 +66,10 @@ protected function setUp(): void {
$this->groupBundle = mb_strtolower($this->randomMachineName());
// Create a node type.
- $node_type = NodeType::create(['type' => $this->groupBundle, 'name' => $this->groupBundle]);
+ $node_type = NodeType::create([
+ 'type' => $this->groupBundle,
+ 'name' => $this->groupBundle,
+ ]);
$node_type->save();
// Define the bundles as groups.
diff --git a/tests/src/Functional/GroupTabTest.php b/tests/src/Functional/GroupTabTest.php
index 83c7a77ad..d47400f88 100644
--- a/tests/src/Functional/GroupTabTest.php
+++ b/tests/src/Functional/GroupTabTest.php
@@ -4,10 +4,10 @@
namespace Drupal\Tests\og\Functional;
+use Drupal\Tests\BrowserTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\og\Og;
-use Drupal\Tests\BrowserTestBase;
/**
* Tests the "Group" tab.
@@ -65,10 +65,16 @@ protected function setUp(): void {
$this->bundle2 = mb_strtolower($this->randomMachineName());
// Create node types.
- $node_type1 = NodeType::create(['type' => $this->bundle1, 'name' => $this->bundle1]);
+ $node_type1 = NodeType::create([
+ 'type' => $this->bundle1,
+ 'name' => $this->bundle1,
+ ]);
$node_type1->save();
- $node_type2 = NodeType::create(['type' => $this->bundle2, 'name' => $this->bundle2]);
+ $node_type2 = NodeType::create([
+ 'type' => $this->bundle2,
+ 'name' => $this->bundle2,
+ ]);
$node_type2->save();
// Define the first bundle as group.
diff --git a/tests/src/Functional/OgComplexWidgetTest.php b/tests/src/Functional/OgComplexWidgetTest.php
index 92a343665..28fbe54ba 100644
--- a/tests/src/Functional/OgComplexWidgetTest.php
+++ b/tests/src/Functional/OgComplexWidgetTest.php
@@ -4,14 +4,14 @@
namespace Drupal\Tests\og\Functional;
+use Drupal\Tests\BrowserTestBase;
+use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
+use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\node\Entity\Node;
use Drupal\og\Og;
use Drupal\og\OgGroupAudienceHelperInterface;
-use Drupal\Tests\BrowserTestBase;
-use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
-use Drupal\Tests\node\Traits\NodeCreationTrait;
/**
* Tests the complex widget.
diff --git a/tests/src/Kernel/Action/ActionTestBase.php b/tests/src/Kernel/Action/ActionTestBase.php
index 2edb2bfb8..58265e875 100644
--- a/tests/src/Kernel/Action/ActionTestBase.php
+++ b/tests/src/Kernel/Action/ActionTestBase.php
@@ -162,11 +162,17 @@ protected function createUsers() {
// A group administrator. This is a special case since this role is
// considered to have all permissions.
$this->users['group_administrator'] = $this->createUser();
- $this->memberships['group_administrator'] = $this->createOgMembership($this->group, $this->users['group_administrator'], [OgRoleInterface::AUTHENTICATED, OgRoleInterface::ADMINISTRATOR]);
+ $this->memberships['group_administrator'] = $this->createOgMembership($this->group, $this->users['group_administrator'], [
+ OgRoleInterface::AUTHENTICATED,
+ OgRoleInterface::ADMINISTRATOR,
+ ]);
// A group moderator that has the right to administer group members.
$this->users['group_moderator'] = $this->createUser();
- $this->memberships['group_moderator'] = $this->createOgMembership($this->group, $this->users['group_moderator'], [OgRoleInterface::AUTHENTICATED, 'moderator']);
+ $this->memberships['group_moderator'] = $this->createOgMembership($this->group, $this->users['group_moderator'], [
+ OgRoleInterface::AUTHENTICATED,
+ 'moderator',
+ ]);
}
/**
diff --git a/tests/src/Kernel/Cache/Context/OgRoleCacheContextTest.php b/tests/src/Kernel/Cache/Context/OgRoleCacheContextTest.php
index 5efe0139e..781f9e7cf 100644
--- a/tests/src/Kernel/Cache/Context/OgRoleCacheContextTest.php
+++ b/tests/src/Kernel/Cache/Context/OgRoleCacheContextTest.php
@@ -208,10 +208,13 @@ public function testMemberships(array $group_memberships, array $expected_identi
/**
* Returns the instantiated cache context service which is being tested.
*
+ * @param \Drupal\Core\Session\AccountInterface|null $user
+ * The user account for which to return the cache context service.
+ *
* @return \Drupal\Core\Cache\Context\CacheContextInterface
* The instantiated cache context service.
*/
- protected function getCacheContext(AccountInterface $user = NULL): CacheContextInterface {
+ protected function getCacheContext(?AccountInterface $user = NULL): CacheContextInterface {
return new OgRoleCacheContext($user, $this->entityTypeManager, $this->membershipManager, $this->database, $this->privateKey);
}
diff --git a/tests/src/Kernel/Entity/EntityCreateAccessTest.php b/tests/src/Kernel/Entity/EntityCreateAccessTest.php
index b1f3da46f..3e3f6ff22 100644
--- a/tests/src/Kernel/Entity/EntityCreateAccessTest.php
+++ b/tests/src/Kernel/Entity/EntityCreateAccessTest.php
@@ -5,12 +5,12 @@
namespace Drupal\Tests\og\Kernel\Entity;
use Drupal\KernelTests\KernelTestBase;
+use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
+use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\og\Og;
use Drupal\og\OgGroupAudienceHelperInterface;
-use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
-use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\user\Entity\Role;
use Drupal\user\Entity\User;
@@ -106,8 +106,10 @@ public function testViewPermissionDoesNotGrantCreateAccess() {
// Grant the anonymous user permission to view published content.
/** @var \Drupal\user\Entity\Role $role */
- $role = Role::create(['id' => Role::ANONYMOUS_ID, 'label' => 'anonymous user'])
- ->grantPermission('access content');
+ $role = Role::create([
+ 'id' => Role::ANONYMOUS_ID,
+ 'label' => 'anonymous user',
+ ])->grantPermission('access content');
$role->save();
// Verify that the user does not have access to the entity create form of
diff --git a/tests/src/Kernel/Entity/GetBundleByBundleTest.php b/tests/src/Kernel/Entity/GetBundleByBundleTest.php
index 0ef4cbf64..b280a64c2 100644
--- a/tests/src/Kernel/Entity/GetBundleByBundleTest.php
+++ b/tests/src/Kernel/Entity/GetBundleByBundleTest.php
@@ -291,7 +291,10 @@ public function getBundleIdsByBundleProvider() {
'node' => [
'group_content_0' => [
'node' => ['group_0' => 'group_0', 'group_1' => 'group_1'],
- 'block_content' => ['group_0' => 'group_0', 'group_1' => 'group_1'],
+ 'block_content' => [
+ 'group_0' => 'group_0',
+ 'group_1' => 'group_1',
+ ],
],
],
],
@@ -511,7 +514,10 @@ public function getBundleIdsByBundleProvider() {
'node' => [
'group_content_0' => [
'node' => ['group_0' => 'group_0'],
- 'block_content' => ['group_0' => 'group_0', 'group_1' => 'group_1'],
+ 'block_content' => [
+ 'group_0' => 'group_0',
+ 'group_1' => 'group_1',
+ ],
],
'group_content_1' => [
'block_content' => ['group_1' => 'group_1'],
@@ -522,7 +528,10 @@ public function getBundleIdsByBundleProvider() {
'node' => ['group_0' => 'group_0', 'group_1' => 'group_1'],
],
'group_content_3' => [
- 'block_content' => ['group_0' => 'group_0', 'group_1' => 'group_1'],
+ 'block_content' => [
+ 'group_0' => 'group_0',
+ 'group_1' => 'group_1',
+ ],
],
'group_content_4' => [
'node' => ['group_0' => 'group_0', 'group_1' => 'group_1'],
diff --git a/tests/src/Kernel/Entity/GetMembershipsTest.php b/tests/src/Kernel/Entity/GetMembershipsTest.php
index e6b01bc52..4ef432ed2 100644
--- a/tests/src/Kernel/Entity/GetMembershipsTest.php
+++ b/tests/src/Kernel/Entity/GetMembershipsTest.php
@@ -105,7 +105,10 @@ protected function setUp(): void {
// A user which is a pending member of the first group and blocked in the
// second group.
- [OgMembershipInterface::STATE_PENDING, OgMembershipInterface::STATE_BLOCKED],
+ [
+ OgMembershipInterface::STATE_PENDING,
+ OgMembershipInterface::STATE_BLOCKED,
+ ],
// A user which is not subscribed to either of the two groups.
[NULL, NULL],
diff --git a/tests/src/Kernel/Entity/GetUserGroupsTest.php b/tests/src/Kernel/Entity/GetUserGroupsTest.php
index 63d0ec276..17d9f17be 100644
--- a/tests/src/Kernel/Entity/GetUserGroupsTest.php
+++ b/tests/src/Kernel/Entity/GetUserGroupsTest.php
@@ -209,7 +209,10 @@ public function testIsMemberStates() {
$this->assertFalse(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_PENDING]));
$this->assertFalse(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_BLOCKED]));
- $this->assertFalse(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_PENDING, OgMembershipInterface::STATE_BLOCKED]));
+ $this->assertFalse(Og::isMember($this->group1, $this->user3, [
+ OgMembershipInterface::STATE_PENDING,
+ OgMembershipInterface::STATE_BLOCKED,
+ ]));
$this->assertFalse(Og::isMemberPending($this->group1, $this->user3));
$this->assertFalse(Og::isMemberBlocked($this->group1, $this->user3));
@@ -220,7 +223,10 @@ public function testIsMemberStates() {
$this->assertTrue(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_PENDING]));
$this->assertTrue(Og::isMemberPending($this->group1, $this->user3));
- $this->assertTrue(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_PENDING, OgMembershipInterface::STATE_BLOCKED]));
+ $this->assertTrue(Og::isMember($this->group1, $this->user3, [
+ OgMembershipInterface::STATE_PENDING,
+ OgMembershipInterface::STATE_BLOCKED,
+ ]));
$this->assertFalse(Og::isMember($this->group1, $this->user3));
$this->assertFalse(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_BLOCKED]));
@@ -233,7 +239,10 @@ public function testIsMemberStates() {
$this->assertTrue(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_BLOCKED]));
$this->assertTrue(Og::isMemberBlocked($this->group1, $this->user3));
- $this->assertTrue(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_PENDING, OgMembershipInterface::STATE_BLOCKED]));
+ $this->assertTrue(Og::isMember($this->group1, $this->user3, [
+ OgMembershipInterface::STATE_PENDING,
+ OgMembershipInterface::STATE_BLOCKED,
+ ]));
$this->assertFalse(Og::isMember($this->group1, $this->user3));
$this->assertFalse(Og::isMember($this->group1, $this->user3, [OgMembershipInterface::STATE_PENDING]));
@@ -283,11 +292,17 @@ public function testGetGroupsByRoles() {
$this->assertCount(2, $groups['entity_test']);
// Request any of multiple roles.
- $groups = $this->membershipManager->getUserGroupsByRoleIds($this->user3->id(), [$member_role->id(), $extra_role_1->id()], OgMembershipInterface::ALL_STATES, FALSE);
+ $groups = $this->membershipManager->getUserGroupsByRoleIds($this->user3->id(), [
+ $member_role->id(),
+ $extra_role_1->id(),
+ ], OgMembershipInterface::ALL_STATES, FALSE);
$this->assertCount(2, $groups['entity_test']);
// Request all of multiple roles.
- $groups = $this->membershipManager->getUserGroupsByRoleIds($this->user3->id(), [$member_role->id(), $extra_role_1->id()], OgMembershipInterface::ALL_STATES, TRUE);
+ $groups = $this->membershipManager->getUserGroupsByRoleIds($this->user3->id(), [
+ $member_role->id(),
+ $extra_role_1->id(),
+ ], OgMembershipInterface::ALL_STATES, TRUE);
$this->assertCount(1, $groups['entity_test']);
$actual = reset($groups['entity_test']);
$this->assertEquals($this->group2->id(), $actual->id());
diff --git a/tests/src/Kernel/Entity/GroupMembershipManagerTest.php b/tests/src/Kernel/Entity/GroupMembershipManagerTest.php
index fa928f34b..0a5a84793 100644
--- a/tests/src/Kernel/Entity/GroupMembershipManagerTest.php
+++ b/tests/src/Kernel/Entity/GroupMembershipManagerTest.php
@@ -4,10 +4,11 @@
namespace Drupal\Tests\og\Kernel\Entity;
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\Tests\og\Traits\OgMembershipCreationTrait;
use Drupal\entity_test\Entity\EntityTestBundle;
use Drupal\entity_test\Entity\EntityTestRev;
use Drupal\entity_test\Entity\EntityTestWithBundle;
-use Drupal\KernelTests\KernelTestBase;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
@@ -16,7 +17,6 @@
use Drupal\og\OgGroupAudienceHelperInterface;
use Drupal\og\OgMembershipInterface;
use Drupal\og\OgRoleInterface;
-use Drupal\Tests\og\Traits\OgMembershipCreationTrait;
use Drupal\user\Entity\User;
/**
@@ -234,7 +234,10 @@ public function testGetGroupIdsInvalidArguments() {
public function testStaticCache() {
$bundle_rev = mb_strtolower($this->randomMachineName());
$bundle_with_bundle = mb_strtolower($this->randomMachineName());
- EntityTestBundle::create(['id' => $bundle_with_bundle, 'label' => $bundle_with_bundle])->save();
+ EntityTestBundle::create([
+ 'id' => $bundle_with_bundle,
+ 'label' => $bundle_with_bundle,
+ ])->save();
$field_settings = [
'field_name' => 'group_audience_node',
'field_storage_config' => [
diff --git a/tests/src/Kernel/Entity/OgMembershipTest.php b/tests/src/Kernel/Entity/OgMembershipTest.php
index 8bf907991..256c4b54f 100644
--- a/tests/src/Kernel/Entity/OgMembershipTest.php
+++ b/tests/src/Kernel/Entity/OgMembershipTest.php
@@ -5,9 +5,9 @@
namespace Drupal\Tests\og\Kernel\Entity;
use Drupal\Core\Entity\EntityStorageException;
+use Drupal\KernelTests\KernelTestBase;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\entity_test\Entity\EntityTestMul;
-use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\og\Entity\OgMembership;
diff --git a/tests/src/Kernel/EntityReference/Views/OgStandardReferenceRelationshipTest.php b/tests/src/Kernel/EntityReference/Views/OgStandardReferenceRelationshipTest.php
index ea07f6a19..86d6e8982 100644
--- a/tests/src/Kernel/EntityReference/Views/OgStandardReferenceRelationshipTest.php
+++ b/tests/src/Kernel/EntityReference/Views/OgStandardReferenceRelationshipTest.php
@@ -65,10 +65,26 @@ protected function setUp($import_test_views = TRUE): void {
$this->installEntitySchema('entity_test_mul');
// Create reference from entity_test to entity_test_mul.
- Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'entity_test', 'entity_test', ['field_name' => 'field_test_data', 'field_storage_config' => ['settings' => ['target_type' => 'entity_test_mul']]]);
+ $settings = [
+ 'field_name' => 'field_test_data',
+ 'field_storage_config' => [
+ 'settings' => [
+ 'target_type' => 'entity_test_mul',
+ ],
+ ],
+ ];
+ Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'entity_test', 'entity_test', $settings);
// Create reference from entity_test_mul to entity_test.
- Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'entity_test_mul', 'entity_test_mul', ['field_name' => 'field_data_test', 'field_storage_config' => ['settings' => ['target_type' => 'entity_test']]]);
+ $settings = [
+ 'field_name' => 'field_data_test',
+ 'field_storage_config' => [
+ 'settings' => [
+ 'target_type' => 'entity_test',
+ ],
+ ],
+ ];
+ Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'entity_test_mul', 'entity_test_mul', $settings);
ViewTestData::createTestViews(get_class($this), ['og_standard_reference_test_views']);
}
diff --git a/tests/src/Traits/OgMembershipCreationTrait.php b/tests/src/Traits/OgMembershipCreationTrait.php
index aa54277bc..f8ad5b2c0 100644
--- a/tests/src/Traits/OgMembershipCreationTrait.php
+++ b/tests/src/Traits/OgMembershipCreationTrait.php
@@ -25,16 +25,16 @@ trait OgMembershipCreationTrait {
* The group for which to create the membership.
* @param \Drupal\Core\Session\AccountInterface $user
* The user for which to create the membership.
- * @param array $role_names
+ * @param array|null $role_names
* Optional array of role names to assign to the membership. Defaults to the
* 'member' role.
- * @param string $state
+ * @param string|null $state
* Optional membership state. Can be one of the following constants:
* - OgMembershipInterface::STATE_ACTIVE
* - OgMembershipInterface::STATE_PENDING
* - OgMembershipInterface::STATE_BLOCKED
* Defaults to OgMembershipInterface::STATE_ACTIVE.
- * @param string $membership_type
+ * @param string|null $membership_type
* The membership type. Defaults to 'default'.
*
* @return \Drupal\og\OgMembershipInterface
@@ -43,7 +43,7 @@ trait OgMembershipCreationTrait {
* @throws \Drupal\Core\Entity\EntityStorageException
* Thrown when the membership cannot be created.
*/
- protected function createOgMembership(EntityInterface $group, AccountInterface $user, array $role_names = NULL, $state = NULL, $membership_type = NULL) {
+ protected function createOgMembership(EntityInterface $group, AccountInterface $user, ?array $role_names = NULL, ?string $state = NULL, ?string $membership_type = NULL) {
// Provide default values.
$role_names = $role_names ?: [OgRoleInterface::AUTHENTICATED];
$state = $state ?: OgMembershipInterface::STATE_ACTIVE;
diff --git a/tests/src/Unit/Cache/Context/OgContextCacheContextTestBase.php b/tests/src/Unit/Cache/Context/OgContextCacheContextTestBase.php
index 57140d873..cfe04d3a9 100644
--- a/tests/src/Unit/Cache/Context/OgContextCacheContextTestBase.php
+++ b/tests/src/Unit/Cache/Context/OgContextCacheContextTestBase.php
@@ -98,11 +98,11 @@ abstract protected function setupExpectedContext($context);
/**
* Sets an expectation that OgContext will return the given group.
*
- * @param \Drupal\Core\Entity\EntityInterface $group
+ * @param \Drupal\Core\Entity\EntityInterface|null $group
* The group to return, or NULL if no group is expected to be returned by
* OgContext.
*/
- protected function expectGroupContext(EntityInterface $group = NULL) {
+ protected function expectGroupContext(?EntityInterface $group = NULL) {
$this->ogContext->getGroup()->willReturn($group);
}
diff --git a/tests/src/Unit/Cache/Context/OgRoleCacheContextTest.php b/tests/src/Unit/Cache/Context/OgRoleCacheContextTest.php
index 3c6dd6388..8cd718bd8 100644
--- a/tests/src/Unit/Cache/Context/OgRoleCacheContextTest.php
+++ b/tests/src/Unit/Cache/Context/OgRoleCacheContextTest.php
@@ -10,10 +10,10 @@
use Drupal\Core\PrivateKey;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings;
+use Drupal\Tests\og\Traits\OgRoleCacheContextTestTrait;
use Drupal\og\Cache\Context\OgRoleCacheContext;
use Drupal\og\MembershipManagerInterface;
use Drupal\og\OgMembershipInterface;
-use Drupal\Tests\og\Traits\OgRoleCacheContextTestTrait;
/**
* Tests the OG role cache context.
@@ -208,7 +208,7 @@ public function testMembershipsNoSql(array $group_memberships, array $expected_i
/**
* {@inheritdoc}
*/
- protected function getCacheContext(AccountInterface $user = NULL): CacheContextInterface {
+ protected function getCacheContext(?AccountInterface $user = NULL): CacheContextInterface {
return new OgRoleCacheContext($user, $this->entityTypeManager->reveal(), $this->membershipManager->reveal(), $this->database->reveal(), $this->privateKey->reveal());
}
diff --git a/tests/src/Unit/CreateMembershipTest.php b/tests/src/Unit/CreateMembershipTest.php
index 6f979a180..d1be7ce71 100644
--- a/tests/src/Unit/CreateMembershipTest.php
+++ b/tests/src/Unit/CreateMembershipTest.php
@@ -10,10 +10,10 @@
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityTypeRepositoryInterface;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\MembershipManager;
use Drupal\og\OgGroupAudienceHelperInterface;
use Drupal\og\OgMembershipInterface;
-use Drupal\Tests\UnitTestCase;
use Drupal\user\UserInterface;
use Prophecy\Argument;
diff --git a/tests/src/Unit/DefaultRoleEventTest.php b/tests/src/Unit/DefaultRoleEventTest.php
index 2ea89d8e0..a8a1a795b 100644
--- a/tests/src/Unit/DefaultRoleEventTest.php
+++ b/tests/src/Unit/DefaultRoleEventTest.php
@@ -6,10 +6,10 @@
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\Entity\OgRole;
use Drupal\og\Event\DefaultRoleEvent;
use Drupal\og\OgRoleInterface;
-use Drupal\Tests\UnitTestCase;
/**
* Tests default role events.
diff --git a/tests/src/Unit/GroupCheckTest.php b/tests/src/Unit/GroupCheckTest.php
index ddcc04d95..a303e6996 100644
--- a/tests/src/Unit/GroupCheckTest.php
+++ b/tests/src/Unit/GroupCheckTest.php
@@ -11,10 +11,10 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\Access\GroupCheck;
use Drupal\og\GroupTypeManagerInterface;
use Drupal\og\OgAccessInterface;
-use Drupal\Tests\UnitTestCase;
use Symfony\Component\Routing\Route;
/**
diff --git a/tests/src/Unit/GroupContentOperationPermissionTest.php b/tests/src/Unit/GroupContentOperationPermissionTest.php
index a5b0fea80..70b872d58 100644
--- a/tests/src/Unit/GroupContentOperationPermissionTest.php
+++ b/tests/src/Unit/GroupContentOperationPermissionTest.php
@@ -4,9 +4,9 @@
namespace Drupal\Tests\og\Unit;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\GroupContentOperationPermission;
use Drupal\og\OgRoleInterface;
-use Drupal\Tests\UnitTestCase;
/**
* Tests group content permissions.
diff --git a/tests/src/Unit/GroupPermissionTest.php b/tests/src/Unit/GroupPermissionTest.php
index 295d7c47c..1d9cbbe7d 100644
--- a/tests/src/Unit/GroupPermissionTest.php
+++ b/tests/src/Unit/GroupPermissionTest.php
@@ -4,9 +4,9 @@
namespace Drupal\Tests\og\Unit;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\GroupPermission;
use Drupal\og\OgRoleInterface;
-use Drupal\Tests\UnitTestCase;
/**
* Group permissions tests.
diff --git a/tests/src/Unit/GroupSubscribeFormatterTest.php b/tests/src/Unit/GroupSubscribeFormatterTest.php
index 5a40b2608..c7037dfe8 100644
--- a/tests/src/Unit/GroupSubscribeFormatterTest.php
+++ b/tests/src/Unit/GroupSubscribeFormatterTest.php
@@ -14,12 +14,12 @@
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\AccountProxyInterface;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\GroupTypeManagerInterface;
use Drupal\og\MembershipManagerInterface;
use Drupal\og\OgAccessInterface;
use Drupal\og\OgMembershipInterface;
use Drupal\og\Plugin\Field\FieldFormatter\GroupSubscribeFormatter;
-use Drupal\Tests\UnitTestCase;
use Drupal\user\EntityOwnerInterface;
/**
@@ -341,7 +341,10 @@ public function testMember() {
$this
->membershipManager
- ->isMember($this->group->reveal(), $this->user->reveal()->id(), [OgMembershipInterface::STATE_ACTIVE, OgMembershipInterface::STATE_PENDING])
+ ->isMember($this->group->reveal(), $this->user->reveal()->id(), [
+ OgMembershipInterface::STATE_ACTIVE,
+ OgMembershipInterface::STATE_PENDING,
+ ])
->willReturn(TRUE);
$elements = $this->getElements();
diff --git a/tests/src/Unit/GroupTypeManagerTest.php b/tests/src/Unit/GroupTypeManagerTest.php
index 4d73d4050..b46a0e30d 100644
--- a/tests/src/Unit/GroupTypeManagerTest.php
+++ b/tests/src/Unit/GroupTypeManagerTest.php
@@ -11,16 +11,16 @@
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\RouteBuilderInterface;
+use Drupal\Tests\UnitTestCase;
+use Drupal\og\Entity\OgRole;
use Drupal\og\Event\GroupCreationEvent;
use Drupal\og\Event\GroupCreationEventInterface;
+use Drupal\og\Event\PermissionEventInterface;
use Drupal\og\GroupTypeManager;
use Drupal\og\GroupTypeManagerInterface;
use Drupal\og\OgGroupAudienceHelperInterface;
-use Drupal\og\PermissionManagerInterface;
use Drupal\og\OgRoleManagerInterface;
-use Drupal\Tests\UnitTestCase;
-use Drupal\og\Entity\OgRole;
-use Drupal\og\Event\PermissionEventInterface;
+use Drupal\og\PermissionManagerInterface;
use Prophecy\Argument;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -226,7 +226,10 @@ public function testAddGroupExisting() {
$this->expectException(\InvalidArgumentException::class);
$manager->addGroup('test_entity', 'c');
- $this->assertSame(['a', 'b', 'c'], $manager->getGroupBundleIdsByEntityType('test_entity'));
+ $this->assertSame(
+ ['a', 'b', 'c'],
+ $manager->getGroupBundleIdsByEntityType('test_entity')
+ );
$this->assertTrue($manager->isGroup('test_entity', 'c'));
}
diff --git a/tests/src/Unit/OgAccessTestBase.php b/tests/src/Unit/OgAccessTestBase.php
index eac63830a..959a1867e 100644
--- a/tests/src/Unit/OgAccessTestBase.php
+++ b/tests/src/Unit/OgAccessTestBase.php
@@ -14,11 +14,11 @@
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\AccountProxyInterface;
-use Drupal\og\MembershipManagerInterface;
-use Drupal\og\OgMembershipInterface;
use Drupal\Tests\UnitTestCase;
use Drupal\og\GroupTypeManagerInterface;
+use Drupal\og\MembershipManagerInterface;
use Drupal\og\OgAccess;
+use Drupal\og\OgMembershipInterface;
use Drupal\og\PermissionManager;
use Drupal\user\EntityOwnerInterface;
use Drupal\user\RoleInterface;
@@ -173,7 +173,7 @@ protected function setUp(): void {
$this->membershipManager->getGroupCount(Argument::any())->willReturn(1);
$this->membership->getRoles()->willReturn([$this->ogRole->reveal()]);
- // @todo: Move to test.
+ // @todo Move to test.
$this->ogRole->isAdmin()->willReturn(FALSE);
$this->ogRole->getPermissions()->willReturn(['update group']);
diff --git a/tests/src/Unit/OgAdminRoutesControllerTest.php b/tests/src/Unit/OgAdminRoutesControllerTest.php
index 12d8eb8f9..7d9f7487f 100644
--- a/tests/src/Unit/OgAdminRoutesControllerTest.php
+++ b/tests/src/Unit/OgAdminRoutesControllerTest.php
@@ -10,10 +10,10 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\Controller\OgAdminRoutesController;
use Drupal\og\Event\OgAdminRoutesEvent;
use Drupal\og\Event\OgAdminRoutesEventInterface;
-use Drupal\Tests\UnitTestCase;
use Prophecy\Argument;
use Symfony\Component\Routing\Route;
diff --git a/tests/src/Unit/OgLocalTaskTest.php b/tests/src/Unit/OgLocalTaskTest.php
index 210e3d609..b0e451fdc 100644
--- a/tests/src/Unit/OgLocalTaskTest.php
+++ b/tests/src/Unit/OgLocalTaskTest.php
@@ -6,9 +6,9 @@
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Routing\RouteProvider;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\GroupTypeManagerInterface;
use Drupal\og\Plugin\Derivative\OgLocalTask;
-use Drupal\Tests\UnitTestCase;
use Symfony\Component\Routing\Route;
/**
diff --git a/tests/src/Unit/OgResolvedGroupCollectionTest.php b/tests/src/Unit/OgResolvedGroupCollectionTest.php
index 77c9e91a2..862e23250 100644
--- a/tests/src/Unit/OgResolvedGroupCollectionTest.php
+++ b/tests/src/Unit/OgResolvedGroupCollectionTest.php
@@ -5,8 +5,8 @@
namespace Drupal\Tests\og\Unit;
use Drupal\Core\Entity\ContentEntityInterface;
-use Drupal\og\OgResolvedGroupCollection;
use Drupal\Tests\UnitTestCase;
+use Drupal\og\OgResolvedGroupCollection;
/**
* Tests the collecting of resolved groups to pass as a route context.
@@ -30,7 +30,8 @@ protected function setUp(): void {
parent::setUp();
// Mock some test groups.
- foreach (['node', 'entity_test', 'taxonomy_term', 'block_content'] as $entity_type) {
+ $entity_types = ['node', 'entity_test', 'taxonomy_term', 'block_content'];
+ foreach ($entity_types as $entity_type) {
for ($i = 0; $i < 2; $i++) {
$entity_id = "$entity_type-$i";
/** @var \Drupal\Core\Entity\ContentEntityInterface|\Prophecy\Prophecy\ObjectProphecy $entity */
@@ -77,7 +78,10 @@ public function testAddGroup() {
// The cache contexts should now be associated with the group.
$info = $collection->getGroupInfo()[$key];
- $this->assertEquals(['route', 'url'], array_values($info['cache_contexts']));
+ $this->assertEquals(
+ ['route', 'url'],
+ array_values($info['cache_contexts'])
+ );
// There should now be two votes, and both should have been cast with the
// default vote weight.
@@ -92,7 +96,10 @@ public function testAddGroup() {
// The additional cache context should now be associated with the group.
$info = $collection->getGroupInfo()[$key];
- $this->assertEquals(['route', 'url', 'user'], array_values($info['cache_contexts']));
+ $this->assertEquals(
+ ['route', 'url', 'user'],
+ array_values($info['cache_contexts'])
+ );
// There should now be three votes, the last of which having the custom
// vote weight.
@@ -105,7 +112,10 @@ public function testAddGroup() {
// should not cause the cache context to be listed twice.
$collection->addGroup($group, ['url', 'user']);
$info = $collection->getGroupInfo()[$key];
- $this->assertEquals(['route', 'url', 'user'], array_values($info['cache_contexts']));
+ $this->assertEquals(
+ ['route', 'url', 'user'],
+ array_values($info['cache_contexts'])
+ );
}
}
diff --git a/tests/src/Unit/OgRoleManagerTest.php b/tests/src/Unit/OgRoleManagerTest.php
index c6ef23147..293e3eda2 100644
--- a/tests/src/Unit/OgRoleManagerTest.php
+++ b/tests/src/Unit/OgRoleManagerTest.php
@@ -6,11 +6,11 @@
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\Entity\OgRole;
use Drupal\og\OgRoleInterface;
use Drupal\og\OgRoleManager;
use Drupal\og\PermissionManagerInterface;
-use Drupal\Tests\UnitTestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
diff --git a/tests/src/Unit/OgRoleTest.php b/tests/src/Unit/OgRoleTest.php
index 1162e85ec..9f39361b6 100644
--- a/tests/src/Unit/OgRoleTest.php
+++ b/tests/src/Unit/OgRoleTest.php
@@ -4,8 +4,8 @@
namespace Drupal\Tests\og\Unit;
-use Drupal\og\Entity\OgRole;
use Drupal\Tests\UnitTestCase;
+use Drupal\og\Entity\OgRole;
/**
* Unit tests for the OgRole config entity.
diff --git a/tests/src/Unit/PermissionEventTest.php b/tests/src/Unit/PermissionEventTest.php
index 163065161..14d4f98f2 100644
--- a/tests/src/Unit/PermissionEventTest.php
+++ b/tests/src/Unit/PermissionEventTest.php
@@ -4,12 +4,12 @@
namespace Drupal\Tests\og\Unit;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\Event\PermissionEvent;
use Drupal\og\GroupContentOperationPermission;
use Drupal\og\GroupPermission;
use Drupal\og\OgAccess;
use Drupal\og\OgRoleInterface;
-use Drupal\Tests\UnitTestCase;
/**
* Tests permission events.
diff --git a/tests/src/Unit/Plugin/OgGroupResolver/OgGroupResolverTestBase.php b/tests/src/Unit/Plugin/OgGroupResolver/OgGroupResolverTestBase.php
index 370a59c04..950baabcd 100644
--- a/tests/src/Unit/Plugin/OgGroupResolver/OgGroupResolverTestBase.php
+++ b/tests/src/Unit/Plugin/OgGroupResolver/OgGroupResolverTestBase.php
@@ -6,10 +6,10 @@
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\GroupTypeManagerInterface;
use Drupal\og\MembershipManagerInterface;
use Drupal\og\OgGroupAudienceHelperInterface;
-use Drupal\Tests\UnitTestCase;
/**
* Base class for testing OgGroupResolver plugins.
diff --git a/tests/src/Unit/Plugin/OgGroupResolver/OgRouteGroupResolverTestBase.php b/tests/src/Unit/Plugin/OgGroupResolver/OgRouteGroupResolverTestBase.php
index 5e4727552..3fdb3747f 100644
--- a/tests/src/Unit/Plugin/OgGroupResolver/OgRouteGroupResolverTestBase.php
+++ b/tests/src/Unit/Plugin/OgGroupResolver/OgRouteGroupResolverTestBase.php
@@ -93,7 +93,10 @@ public function testResolve($path = NULL, $route_object_id = NULL, array $expect
// Add expectations for the groups that are added and removed by the plugin.
$test_entities = $this->testEntities;
- foreach ([&$expected_added_groups, &$expected_removed_groups] as &$expected_groups) {
+ foreach ([
+ &$expected_added_groups,
+ &$expected_removed_groups,
+ ] as &$expected_groups) {
// Replace the entity IDs from the data provider with actual test
// entities.
$expected_groups = array_map(function ($item) use ($test_entities) {
diff --git a/tests/src/Unit/SubscriptionControllerTest.php b/tests/src/Unit/SubscriptionControllerTest.php
index 4e490b58c..1335b421f 100644
--- a/tests/src/Unit/SubscriptionControllerTest.php
+++ b/tests/src/Unit/SubscriptionControllerTest.php
@@ -11,11 +11,11 @@
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
+use Drupal\Tests\UnitTestCase;
use Drupal\og\Controller\SubscriptionController;
use Drupal\og\MembershipManagerInterface;
use Drupal\og\OgAccessInterface;
use Drupal\og\OgMembershipInterface;
-use Drupal\Tests\UnitTestCase;
use Drupal\user\EntityOwnerInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;