Skip to content
Snippets Groups Projects
Commit db73cd24 authored by Ines WALLON's avatar Ines WALLON Committed by Ines WALLON
Browse files

Issue #3311205 by liber_t: Fix PHPCs and PHPstan warning

parent d7d2dbc7
Branches
Tags
No related merge requests found
7 0 → 100644
[connection]
id=SmileWgGalaxy
uuid=cc04d076-9d08-4237-8588-dd82e6ebef1e
type=vpn
permissions=
[vpn]
connection-dns=10.41.0.1
local-ip4=10.41.0.148/32
local-private-key=WOjrmRrs/VUvduYwlJ9HLKkzeqoSNIqgxk1SqgjQw7A=
#peer-allowed-ips=10.1.0.0/16,10.2.0.0/16,10.2.41.1/32,10.3.0.0/16,10.4.0.0/16,10.5.0.0/16,10.6.0.0/16,10.7.0.0/16,10.9.0.0/16,10.10.0.0/16,10.12.0.0/16,10.13.0.0/16,10.15.0.0/16,10.16.0.0/16,10.17.0.0/16,10.18.0.0/16,10.19.0.0/16,10.20.0.0/16,10.206.0.0/16,10.207.0.0/16,172.29.10.0/24,195.54.62.139/32,195.54.63.43/32,145.239.192.138/32,10.41.0.1/32
peer-allowed-ips=10.1.0.0/16, 10.2.0.0/16, 10.2.41.1/32, 10.3.0.0/16, 10.4.0.0/16, 10.5.0.0/16, 10.6.0.0/16, 10.7.0.0/16, 10.9.0.0/16, 10.10.0.0/16, 10.12.0.0/16, 10.13.0.0/16, 10.15.0.0/16, 10.16.0.0/16, 10.17.0.0/16, 10.18.0.0/16, 10.19.0.0/16, 10.20.0.0/16, 10.206.0.0/16, 10.207.0.0/16, 172.29.10.0/24, 195.54.62.139/32, 195.54.63.43/32, 145.239.192.138/32, 10.41.0.1/32
#peer-endpoint=vpn.galaxy.smile.fr:31820
peer-endpoint=bastion02.ovh.smile.fr:31820
peer-public-key=JHqFkG/kz3mSp4wA7rKkKVytGsg7nIvKCMNRyntJuGk=
service-type=org.freedesktop.NetworkManager.wireguard
[ipv4]
dns-search=intranet
method=auto
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
[proxy]
...@@ -17,8 +17,8 @@ use Drupal\paragraphs_usage\EntityTypeInfo; ...@@ -17,8 +17,8 @@ use Drupal\paragraphs_usage\EntityTypeInfo;
/** /**
* Implements hook_entity_type_alter(). * Implements hook_entity_type_alter().
*/ */
function paragraphs_usage_entity_type_alter(array &$entity_types) { function paragraphs_usage_entity_type_alter(array &$entity_types): void {
return \Drupal::service('class_resolver') \Drupal::service('class_resolver')
->getInstanceFromDefinition(EntityTypeInfo::class) ->getInstanceFromDefinition(EntityTypeInfo::class)
->entityTypeAlter($entity_types); ->entityTypeAlter($entity_types);
} }
...@@ -26,8 +26,8 @@ function paragraphs_usage_entity_type_alter(array &$entity_types) { ...@@ -26,8 +26,8 @@ function paragraphs_usage_entity_type_alter(array &$entity_types) {
/** /**
* Implements hook_entity_operation(). * Implements hook_entity_operation().
*/ */
function paragraphs_usage_entity_operation(EntityInterface $entity) { function paragraphs_usage_entity_operation(EntityInterface $entity): void {
return \Drupal::service('class_resolver') \Drupal::service('class_resolver')
->getInstanceFromDefinition(EntityTypeInfo::class) ->getInstanceFromDefinition(EntityTypeInfo::class)
->entityOperation($entity); ->entityOperation($entity);
} }
...@@ -12,9 +12,7 @@ namespace Drupal\Tests\paragraphs_usage\Functional; ...@@ -12,9 +12,7 @@ namespace Drupal\Tests\paragraphs_usage\Functional;
class ParagraphsUsageAdminToolbarTest extends ParagraphsUsageTestBase { class ParagraphsUsageAdminToolbarTest extends ParagraphsUsageTestBase {
/** /**
* Modules to enable. * {@inheritdoc}
*
* @var array
*/ */
public static $modules = [ public static $modules = [
'admin_toolbar_tools', 'admin_toolbar_tools',
...@@ -33,7 +31,7 @@ class ParagraphsUsageAdminToolbarTest extends ParagraphsUsageTestBase { ...@@ -33,7 +31,7 @@ class ParagraphsUsageAdminToolbarTest extends ParagraphsUsageTestBase {
/** /**
* Check if paragraph type as menulink. * Check if paragraph type as menulink.
*/ */
public function testMenuLinkExist() { public function testMenuLinkExist(): void {
$this->addParagraphsType('test_paragraphs'); $this->addParagraphsType('test_paragraphs');
$this->drupalGet('/admin/structure/paragraphs_type'); $this->drupalGet('/admin/structure/paragraphs_type');
$this->assertSession()->linkByHrefExists('/admin/structure/paragraphs_type/test_paragraphs/usage'); $this->assertSession()->linkByHrefExists('/admin/structure/paragraphs_type/test_paragraphs/usage');
......
...@@ -12,9 +12,7 @@ namespace Drupal\Tests\paragraphs_usage\Functional; ...@@ -12,9 +12,7 @@ namespace Drupal\Tests\paragraphs_usage\Functional;
class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase { class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase {
/** /**
* Modules to enable. * {@inheritdoc}
*
* @var array
*/ */
public static $modules = [ public static $modules = [
'node', 'node',
...@@ -40,14 +38,14 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase { ...@@ -40,14 +38,14 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase {
'administer node form display', 'administer node form display',
'administer node fields', 'administer node fields',
'create article content', 'create article content',
'create page content' 'create page content',
]); ]);
} }
/** /**
* Check if paragraph is used in article content type. * Check if paragraph is used in article content type.
*/ */
public function testCheckIfUsed() { public function testCheckIfUsed(): void {
$this->addParagraphsType('test_paragraphs'); $this->addParagraphsType('test_paragraphs');
$this->addParagraphsField('article', 'test_paragraphs', 'node'); $this->addParagraphsField('article', 'test_paragraphs', 'node');
...@@ -59,7 +57,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase { ...@@ -59,7 +57,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase {
/** /**
* Check if paragraph is not used in page content type. * Check if paragraph is not used in page content type.
*/ */
public function testCheckIfNotUsed() { public function testCheckIfNotUsed(): void {
$this->addParagraphsType('test_paragraphs'); $this->addParagraphsType('test_paragraphs');
$this->addParagraphsField('article', 'test_paragraphs', 'node'); $this->addParagraphsField('article', 'test_paragraphs', 'node');
...@@ -70,7 +68,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase { ...@@ -70,7 +68,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase {
/** /**
* Check if paragraph is not used in any content type. * Check if paragraph is not used in any content type.
*/ */
public function testCheckIsEmpty() { public function testCheckIsEmpty(): void {
$this->addParagraphsType('test_paragraphs'); $this->addParagraphsType('test_paragraphs');
$this->drupalGet('admin/structure/paragraphs_type/test_paragraphs/usage'); $this->drupalGet('admin/structure/paragraphs_type/test_paragraphs/usage');
...@@ -80,7 +78,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase { ...@@ -80,7 +78,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase {
/** /**
* Check if paragraph don't exist. * Check if paragraph don't exist.
*/ */
public function testCheckIfParagraphDontExist() { public function testCheckIfParagraphDontExist(): void {
$this->drupalGet('admin/structure/paragraphs_type/test_paragraphs/usage'); $this->drupalGet('admin/structure/paragraphs_type/test_paragraphs/usage');
$this->assertSession()->statusCodeEquals(404); $this->assertSession()->statusCodeEquals(404);
} }
...@@ -88,7 +86,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase { ...@@ -88,7 +86,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase {
/** /**
* Check if Usage link in exist in paragraph's tabs. * Check if Usage link in exist in paragraph's tabs.
*/ */
public function testIfTabExist() { public function testIfTabExist(): void {
$this->addParagraphsType('test_paragraphs'); $this->addParagraphsType('test_paragraphs');
$this->drupalGet('admin/structure/paragraphs_type/test_paragraphs'); $this->drupalGet('admin/structure/paragraphs_type/test_paragraphs');
...@@ -99,7 +97,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase { ...@@ -99,7 +97,7 @@ class ParagraphsUsageContentTypesTest extends ParagraphsUsageTestBase {
/** /**
* Check if Usage link in exist in operations. * Check if Usage link in exist in operations.
*/ */
public function testIfOperationExist() { public function testIfOperationExist(): void {
$this->addParagraphsType('test_paragraphs'); $this->addParagraphsType('test_paragraphs');
$this->drupalGet('admin/structure/paragraphs_type/test_paragraphs'); $this->drupalGet('admin/structure/paragraphs_type/test_paragraphs');
......
...@@ -22,7 +22,7 @@ class ParagraphsUsageParagraphTest extends ParagraphsUsageTestBase { ...@@ -22,7 +22,7 @@ class ParagraphsUsageParagraphTest extends ParagraphsUsageTestBase {
/** /**
* Check if paragraph is used in nested_paragraphs. * Check if paragraph is used in nested_paragraphs.
*/ */
public function testCheckIfUsed() { public function testCheckIfUsed(): void {
$this->addParagraphsType('paragraphs'); $this->addParagraphsType('paragraphs');
$this->addParagraphsType('nested_paragraphs'); $this->addParagraphsType('nested_paragraphs');
...@@ -37,7 +37,7 @@ class ParagraphsUsageParagraphTest extends ParagraphsUsageTestBase { ...@@ -37,7 +37,7 @@ class ParagraphsUsageParagraphTest extends ParagraphsUsageTestBase {
/** /**
* Check if paragraph is not used in vocabulary2. * Check if paragraph is not used in vocabulary2.
*/ */
public function testCheckIfNotUsed() { public function testCheckIfNotUsed(): void {
$this->addParagraphsType('paragraphs'); $this->addParagraphsType('paragraphs');
$this->addParagraphsType('nested_paragraphs'); $this->addParagraphsType('nested_paragraphs');
......
...@@ -12,9 +12,7 @@ namespace Drupal\Tests\paragraphs_usage\Functional; ...@@ -12,9 +12,7 @@ namespace Drupal\Tests\paragraphs_usage\Functional;
class ParagraphsUsageTaxonomyTest extends ParagraphsUsageTestBase { class ParagraphsUsageTaxonomyTest extends ParagraphsUsageTestBase {
/** /**
* Modules to enable. * {@inheritdoc}
*
* @var array
*/ */
public static $modules = [ public static $modules = [
'taxonomy', 'taxonomy',
...@@ -31,7 +29,7 @@ class ParagraphsUsageTaxonomyTest extends ParagraphsUsageTestBase { ...@@ -31,7 +29,7 @@ class ParagraphsUsageTaxonomyTest extends ParagraphsUsageTestBase {
/** /**
* Check if paragraph is used in vocabulary. * Check if paragraph is used in vocabulary.
*/ */
public function testCheckIfUsed() { public function testCheckIfUsed(): void {
$this->createVocabulary('vocabulary'); $this->createVocabulary('vocabulary');
$this->createTerm('term', 'vocabulary'); $this->createTerm('term', 'vocabulary');
...@@ -47,7 +45,7 @@ class ParagraphsUsageTaxonomyTest extends ParagraphsUsageTestBase { ...@@ -47,7 +45,7 @@ class ParagraphsUsageTaxonomyTest extends ParagraphsUsageTestBase {
/** /**
* Check if paragraph is not used in vocabulary2. * Check if paragraph is not used in vocabulary2.
*/ */
public function testCheckIfNotUsed() { public function testCheckIfNotUsed(): void {
$this->createVocabulary('vocabulary1'); $this->createVocabulary('vocabulary1');
$this->createTerm('term1', 'vocabulary1'); $this->createTerm('term1', 'vocabulary1');
......
...@@ -14,6 +14,7 @@ use Drupal\Tests\BrowserTestBase; ...@@ -14,6 +14,7 @@ use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\field\Traits\EntityReferenceTestTrait; use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
use Drupal\Tests\user\Traits\UserCreationTrait; use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\user\UserInterface;
/** /**
* Base class for tests. * Base class for tests.
...@@ -28,9 +29,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase { ...@@ -28,9 +29,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase {
protected $defaultTheme = 'stark'; protected $defaultTheme = 'stark';
/** /**
* Modules to enable. * {@inheritdoc}
*
* @var array
*/ */
public static $modules = [ public static $modules = [
'block', 'block',
...@@ -43,6 +42,21 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase { ...@@ -43,6 +42,21 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase {
'user', 'user',
]; ];
/**
* User permissions.
*
* @var array
*/
protected array $adminPermissions;
/**
* The User Entity.
*
* @var \Drupal\user\UserInterface
*/
protected UserInterface $adminUser;
use EntityReferenceTestTrait; use EntityReferenceTestTrait;
use FieldUiTestTrait; use FieldUiTestTrait;
use UserCreationTrait; use UserCreationTrait;
...@@ -53,7 +67,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase { ...@@ -53,7 +67,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase {
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
$this->admin_permissions = [ $this->adminPermissions = [
'administer paragraph fields', 'administer paragraph fields',
'administer paragraphs types', 'administer paragraphs types',
'administer paragraph form display', 'administer paragraph form display',
...@@ -73,21 +87,21 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase { ...@@ -73,21 +87,21 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase {
* @param array $additional_permissions * @param array $additional_permissions
* Additional permissions that will be granted to admin user. * Additional permissions that will be granted to admin user.
* *
* @return object * @return \Drupal\user\UserInterface
* Newly created and logged in user object. * Newly created and logged in user object.
* *
* @throws \Drupal\Core\Entity\EntityStorageException * @throws \Drupal\Core\Entity\EntityStorageException
*/ */
protected function loginAsAdmin(array $additional_permissions = []) { protected function loginAsAdmin(array $additional_permissions = []): UserInterface {
$permissions = $this->admin_permissions; $permissions = $this->adminPermissions;
if (!empty($additional_permissions)) { if (!empty($additional_permissions)) {
$permissions = array_merge($permissions, $additional_permissions); $permissions = array_merge($permissions, $additional_permissions);
} }
$this->admin_user = $this->drupalCreateUser($permissions); $this->adminUser = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->admin_user); $this->drupalLogin($this->adminUser);
return $this->admin_user; return $this->adminUser;
} }
/** /**
...@@ -106,7 +120,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase { ...@@ -106,7 +120,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase {
* *
* @throws \Drupal\Core\Entity\EntityStorageException * @throws \Drupal\Core\Entity\EntityStorageException
*/ */
protected function addParagraphsField(string $bundle, string $paragraphs_field_name, string $entity_type, $widget_type = 'paragraphs') { protected function addParagraphsField(string $bundle, string $paragraphs_field_name, string $entity_type, string $widget_type = 'paragraphs'): void {
$field_storage = FieldStorageConfig::loadByName($entity_type, $paragraphs_field_name); $field_storage = FieldStorageConfig::loadByName($entity_type, $paragraphs_field_name);
if (!$field_storage) { if (!$field_storage) {
// Add a paragraphs field. // Add a paragraphs field.
...@@ -148,7 +162,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase { ...@@ -148,7 +162,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase {
* *
* @throws \Drupal\Core\Entity\EntityStorageException * @throws \Drupal\Core\Entity\EntityStorageException
*/ */
protected function addParagraphsType(string $paragraphs_type_name) { protected function addParagraphsType(string $paragraphs_type_name): void {
$paragraphs_type = ParagraphsType::create([ $paragraphs_type = ParagraphsType::create([
'id' => $paragraphs_type_name, 'id' => $paragraphs_type_name,
'label' => $paragraphs_type_name, 'label' => $paragraphs_type_name,
...@@ -164,7 +178,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase { ...@@ -164,7 +178,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase {
* *
* @throws \Drupal\Core\Entity\EntityStorageException * @throws \Drupal\Core\Entity\EntityStorageException
*/ */
protected function createVocabulary(string $name) { protected function createVocabulary(string $name): void {
$vocabulary = Vocabulary::create([ $vocabulary = Vocabulary::create([
'name' => $name, 'name' => $name,
'vid' => mb_strtolower($name), 'vid' => mb_strtolower($name),
...@@ -182,7 +196,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase { ...@@ -182,7 +196,7 @@ abstract class ParagraphsUsageTestBase extends BrowserTestBase {
* *
* @throws \Drupal\Core\Entity\EntityStorageException * @throws \Drupal\Core\Entity\EntityStorageException
*/ */
protected function createTerm(string $name, string $vid) { protected function createTerm(string $name, string $vid): void {
$term = Term::create([ $term = Term::create([
'name' => $name, 'name' => $name,
'vid' => $vid, 'vid' => $vid,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment