Skip to content

Commit 70e8030

Browse files
committed
Cleaned up code
1 parent 204aa98 commit 70e8030

File tree

7 files changed

+33
-34
lines changed

7 files changed

+33
-34
lines changed

.github/workflows/pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
php-versions: [ '8.3' ]
27-
dependency-version: [ prefer-lowest, prefer-stable ]
26+
php-versions: ["8.3"]
27+
dependency-version: [prefer-lowest, prefer-stable]
2828
steps:
2929
- uses: actions/checkout@master
3030
- name: Setup PHP, with composer and extensions
@@ -58,7 +58,7 @@ jobs:
5858
runs-on: ubuntu-latest
5959
strategy:
6060
matrix:
61-
php-versions: [ '8.3' ]
61+
php-versions: ["8.3"]
6262
steps:
6363
- uses: actions/checkout@master
6464
- name: Setup PHP, with composer and extensions
@@ -90,7 +90,7 @@ jobs:
9090
runs-on: ubuntu-latest
9191
strategy:
9292
matrix:
93-
php-versions: [ '8.3' ]
93+
php-versions: ["8.3"]
9494
steps:
9595
- uses: actions/checkout@master
9696
- name: Setup PHP, with composer and extensions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
1515
"drupal/coder": "^8.3",
1616
"drupal/maillog": "^1.1",
17-
"ergebnis/composer-normalize": "^2.42",
17+
"ergebnis/composer-normalize": "^2.47",
1818
"mglaman/phpstan-drupal": "^1.2",
1919
"phpstan/extension-installer": "^1.3",
2020
"phpstan/phpstan-deprecation-rules": "^1.1"

config_helper.info.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
name: 'config_helper'
1+
name: "config_helper"
22
type: module
3-
description: 'Config helper'
3+
description: "Config helper"
44
# Used only for development and testing.
55
hidden: true
66
core_version_requirement: ^10
7-
package: 'ITK'
8-
7+
package: "ITK"
98
# https://www.drupal.org/node/2087879

config_helper.services.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
Drupal\config_helper\ConfigHelper:
33
arguments:
4-
- '@module_handler'
5-
- '@config.factory'
6-
- '@file_system'
4+
- "@module_handler"
5+
- "@config.factory"
6+
- "@file_system"

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
services:
44
phpfpm:
5-
image: itkdev/php8.4-fpm:latest
5+
image: itkdev/php8.3-fpm:latest
66
user: ${COMPOSE_USER:-deploy}
77
volumes:
88
- .:/app

src/ConfigHelper.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
*/
3333
public function addEnforcedDependency(
3434
string $module,
35-
array $configNames
35+
array $configNames,
3636
): void {
3737
foreach ($configNames as $name) {
3838
$this->logger->info(sprintf('Config name: %s', $name));
@@ -54,7 +54,7 @@ public function addEnforcedDependency(
5454
*/
5555
public function removeEnforcedDependency(
5656
string $module,
57-
array $configNames
57+
array $configNames,
5858
): void {
5959
foreach ($configNames as $name) {
6060
$this->logger->info(sprintf('Config name: %s', $name));
@@ -86,7 +86,7 @@ public function removeEnforcedDependency(
8686
public function writeModuleConfig(
8787
string $module,
8888
mixed $optional,
89-
array $configNames
89+
array $configNames,
9090
): void {
9191
$moduleConfigPath = $this->getModuleConfigPath($module, $optional);
9292
if (!is_dir($moduleConfigPath)) {
@@ -113,28 +113,28 @@ public function renameConfig(
113113
string $from,
114114
string $to,
115115
array $configNames,
116-
bool $regex = FALSE
116+
bool $regex = FALSE,
117117
): void {
118118
$replacer = $regex
119119
? static fn (string $subject) => preg_replace($from, $to, $subject)
120120
: static fn (string $subject) => str_replace($from, $to, $subject);
121121

122-
foreach ($configNames as $name) {
123-
$config = $this->configFactory->getEditable($name);
124-
$data = $config->getRawData();
125-
$newData = $this->replaceKeysAndValues($replacer, $data);
126-
if ($newData !== $data) {
127-
$config->setData($newData);
128-
$this->logger->info(sprintf('Saving updated config %s', $name));
129-
$config->save();
130-
}
122+
foreach ($configNames as $name) {
123+
$config = $this->configFactory->getEditable($name);
124+
$data = $config->getRawData();
125+
$newData = $this->replaceKeysAndValues($replacer, $data);
126+
if ($newData !== $data) {
127+
$config->setData($newData);
128+
$this->logger->info(sprintf('Saving updated config %s', $name));
129+
$config->save();
130+
}
131131

132-
$newName = $replacer($name);
133-
if ($newName !== $name) {
134-
$this->logger->info(sprintf('Renaming config %s to %s', $name, $newName));
135-
$this->configFactory->rename($name, $newName);
136-
}
132+
$newName = $replacer($name);
133+
if ($newName !== $name) {
134+
$this->logger->info(sprintf('Renaming config %s to %s', $name, $newName));
135+
$this->configFactory->rename($name, $newName);
137136
}
137+
}
138138
}
139139

140140
/**
@@ -218,7 +218,7 @@ public function getModuleConfigPath(string $module, bool $optional): string {
218218
*/
219219
private function replaceKeysAndValues(
220220
callable $replacer,
221-
array $input
221+
array $input,
222222
): array {
223223
$return = [];
224224
foreach ($input as $key => $value) {

src/Drush/Commands/ConfigHelperCommands.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function writeModuleConfig(
8989
array $options = [
9090
'optional' => FALSE,
9191
'enforced' => FALSE,
92-
]
92+
],
9393
): void {
9494
$this->initialize();
9595

@@ -129,7 +129,7 @@ public function rename(
129129
array $configNames,
130130
array $options = [
131131
'regex' => FALSE,
132-
]
132+
],
133133
): void {
134134
$this->initialize();
135135

0 commit comments

Comments
 (0)