Skip to content

Commit 89ff217

Browse files
committed
Cleaned up code
1 parent 204aa98 commit 89ff217

File tree

7 files changed

+30
-126
lines changed

7 files changed

+30
-126
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,12 @@
11
on: pull_request
22
name: Review
33
jobs:
4-
changelog:
5-
runs-on: ubuntu-latest
6-
name: Changelog should be updated
7-
strategy:
8-
fail-fast: false
9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v2
12-
with:
13-
fetch-depth: 2
14-
15-
- name: Git fetch
16-
run: git fetch
17-
18-
- name: Check that changelog has been updated.
19-
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0
20-
21-
test-composer-files:
22-
name: Validate composer
23-
runs-on: ubuntu-latest
24-
strategy:
25-
matrix:
26-
php-versions: [ '8.3' ]
27-
dependency-version: [ prefer-lowest, prefer-stable ]
28-
steps:
29-
- uses: actions/checkout@master
30-
- name: Setup PHP, with composer and extensions
31-
uses: shivammathur/setup-php@v2
32-
with:
33-
php-version: ${{ matrix.php-versions }}
34-
extensions: json
35-
coverage: none
36-
tools: composer:v2
37-
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
38-
- name: Get composer cache directory
39-
id: composer-cache
40-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
41-
- name: Cache dependencies
42-
uses: actions/cache@v2
43-
with:
44-
path: ${{ steps.composer-cache.outputs.dir }}
45-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
46-
restore-keys: ${{ runner.os }}-composer-
47-
- name: Validate composer files
48-
run: |
49-
composer validate --strict composer.json
50-
# Check that dependencies resolve.
51-
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
52-
- name: Check that composer file is normalized
53-
run: |
54-
composer normalize --dry-run
55-
56-
php-coding-standards:
57-
name: PHP coding standards
58-
runs-on: ubuntu-latest
59-
strategy:
60-
matrix:
61-
php-versions: [ '8.3' ]
62-
steps:
63-
- uses: actions/checkout@master
64-
- name: Setup PHP, with composer and extensions
65-
uses: shivammathur/setup-php@v2
66-
with:
67-
php-version: ${{ matrix.php-versions }}
68-
extensions: json
69-
coverage: none
70-
tools: composer:v2
71-
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
72-
- name: Get composer cache directory
73-
id: composer-cache
74-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
75-
- name: Cache dependencies
76-
uses: actions/cache@v2
77-
with:
78-
path: ${{ steps.composer-cache.outputs.dir }}
79-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
80-
restore-keys: ${{ runner.os }}-composer-
81-
- name: Install Dependencies
82-
run: |
83-
composer install --no-interaction --no-progress
84-
- name: PHPCS
85-
run: |
86-
composer coding-standards-check/phpcs
87-
884
php-code-analysis:
895
name: PHP code analysis
906
runs-on: ubuntu-latest
917
strategy:
928
matrix:
93-
php-versions: [ '8.3' ]
9+
php-versions: ["8.3"]
9410
steps:
9511
- uses: actions/checkout@master
9612
- name: Setup PHP, with composer and extensions
@@ -113,14 +29,3 @@ jobs:
11329
- name: Code analysis
11430
run: |
11531
./scripts/code-analysis
116-
117-
coding-standards-markdown:
118-
name: Markdown coding standards
119-
runs-on: ubuntu-latest
120-
steps:
121-
- name: Checkout
122-
uses: actions/checkout@v4
123-
124-
- name: Coding standards
125-
run: |
126-
docker run --rm --volume "$(pwd):/md" peterdavehello/markdownlint markdownlint --ignore LICENSE.md '**/*.md'

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)