Skip to content

Commit c3ac0f9

Browse files
authored
chore: add more trailing commas in more places (#9395)
* Apply to parameters * Apply to array destructuring * Apply to match * Apply for arguments
1 parent 155f1c1 commit c3ac0f9

File tree

270 files changed

+960
-950
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+960
-950
lines changed

.php-cs-fixer.dist.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@
4040
]);
4141

4242
$overrides = [
43-
'get_class_to_class_keyword' => true,
43+
'get_class_to_class_keyword' => true,
44+
'trailing_comma_in_multiline' => [
45+
'after_heredoc' => true,
46+
'elements' => [
47+
'arguments',
48+
'array_destructuring',
49+
'arrays',
50+
'match',
51+
'parameters',
52+
],
53+
],
4454
];
4555

4656
$options = [
@@ -55,5 +65,5 @@
5565
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
5666
'CodeIgniter 4 framework',
5767
'CodeIgniter Foundation',
58-
68+
5969
);

admin/create-new-changelog.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ function replace_file_content(string $path, string $pattern, string $replace): v
4747
replace_file_content(
4848
$changelogIndex,
4949
'/\.\. toctree::\n :titlesonly:\n/u',
50-
".. toctree::\n :titlesonly:\n\n v{$version}"
50+
".. toctree::\n :titlesonly:\n\n v{$version}",
5151
);
5252
// Replace {version}
5353
$length = mb_strlen("Version {$version}");
5454
$underline = str_repeat('#', $length);
5555
replace_file_content(
5656
$changelog,
5757
'/#################\nVersion {version}\n#################/u',
58-
"{$underline}\nVersion {$version}\n{$underline}"
58+
"{$underline}\nVersion {$version}\n{$underline}",
5959
);
6060
replace_file_content(
6161
$changelog,
6262
'/{version}/u',
63-
"{$version}"
63+
"{$version}",
6464
);
6565

6666
// Copy upgrading
@@ -72,15 +72,15 @@ function replace_file_content(string $path, string $pattern, string $replace): v
7272
replace_file_content(
7373
$upgradingIndex,
7474
'/ backward_compatibility_notes\n/u',
75-
" backward_compatibility_notes\n\n upgrade_{$versionWithoutDots}"
75+
" backward_compatibility_notes\n\n upgrade_{$versionWithoutDots}",
7676
);
7777
// Replace {version}
7878
$length = mb_strlen("Upgrading from {$versionCurrent} to {$version}");
7979
$underline = str_repeat('#', $length);
8080
replace_file_content(
8181
$upgrading,
8282
'/##############################\nUpgrading from {version} to {version}\n##############################/u',
83-
"{$underline}\nUpgrading from {$versionCurrent} to {$version}\n{$underline}"
83+
"{$underline}\nUpgrading from {$versionCurrent} to {$version}\n{$underline}",
8484
);
8585

8686
// Commits

admin/prepare-release.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,39 @@ function replace_file_content(string $path, string $pattern, string $replace): v
3333
replace_file_content(
3434
'./system/CodeIgniter.php',
3535
'/public const CI_VERSION = \'.*?\';/u',
36-
"public const CI_VERSION = '{$version}';"
36+
"public const CI_VERSION = '{$version}';",
3737
);
3838

3939
// Updates version number in "conf.py".
4040
replace_file_content(
4141
'./user_guide_src/source/conf.py',
4242
'/^version = \'.*?\'/mu',
43-
"version = '{$minor}'"
43+
"version = '{$minor}'",
4444
);
4545
replace_file_content(
4646
'./user_guide_src/source/conf.py',
4747
'/^release = \'.*?\'/mu',
48-
"release = '{$version}'"
48+
"release = '{$version}'",
4949
);
5050

5151
// Updates version number in "phpdoc.dist.xml".
5252
replace_file_content(
5353
'./phpdoc.dist.xml',
5454
'!<title>CodeIgniter v.*? API</title>!mu',
55-
"<title>CodeIgniter v{$minor} API</title>"
55+
"<title>CodeIgniter v{$minor} API</title>",
5656
);
5757
replace_file_content(
5858
'./phpdoc.dist.xml',
5959
'/<version number=".*?">/mu',
60-
"<version number=\"{$version}\">"
60+
"<version number=\"{$version}\">",
6161
);
6262

6363
// Updates release date in changelogs.
6464
$date = date('F j, Y');
6565
replace_file_content(
6666
"./user_guide_src/source/changelogs/v{$version}.rst",
6767
'/^Release Date: .*/mu',
68-
"Release Date: {$date}"
68+
"Release Date: {$date}",
6969
);
7070

7171
// Commits

admin/starter/tests/unit/HealthTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testBaseUrlHasBeenSet(): void
3232
$config = new App();
3333
$this->assertTrue(
3434
$validation->check($config->baseURL, 'valid_url'),
35-
'baseURL "' . $config->baseURL . '" in .env is not valid URL'
35+
'baseURL "' . $config->baseURL . '" in .env is not valid URL',
3636
);
3737
}
3838

@@ -43,7 +43,7 @@ public function testBaseUrlHasBeenSet(): void
4343
// BaseURL in app/Config/App.php is a valid URL?
4444
$this->assertTrue(
4545
$validation->check($reader->baseURL, 'valid_url'),
46-
'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL'
46+
'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL',
4747
);
4848
}
4949
}

preload.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function load(): void
8686
$phpFiles = new RegexIterator(
8787
$fullTree,
8888
'/.+((?<!Test)+\.php$)/i',
89-
RecursiveRegexIterator::GET_MATCH
89+
RecursiveRegexIterator::GET_MATCH,
9090
);
9191

9292
foreach ($phpFiles as $key => $file) {

public/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$message = sprintf(
1212
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
1313
$minPhpVersion,
14-
PHP_VERSION
14+
PHP_VERSION,
1515
);
1616

1717
header('HTTP/1.1 503 Service Unavailable.', true, 503);

rector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
->withCache(
6363
// Github action cache or local
6464
is_dir('/tmp') ? '/tmp/rector' : null,
65-
FileCacheStorage::class
65+
FileCacheStorage::class,
6666
)
6767
// paths to refactor; solid alternative to CLI arguments
6868
->withPaths([

spark

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
4040
$message = sprintf(
4141
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
4242
$minPhpVersion,
43-
PHP_VERSION
43+
PHP_VERSION,
4444
);
4545

4646
exit($message);

system/API/ResponseTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ protected function format($data = null)
319319
$mime = $this->request->negotiate(
320320
'media',
321321
$format->getConfig()->supportedResponseFormats,
322-
false
322+
false,
323323
);
324324
}
325325

system/Autoloader/Autoloader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public function sanitizeFilename(string $filename): string
347347

348348
throw new InvalidArgumentException(
349349
'The file path contains special characters "' . $chars
350-
. '" that are not allowed: "' . $filename . '"'
350+
. '" that are not allowed: "' . $filename . '"',
351351
);
352352
}
353353
if ($result === false) {
@@ -386,7 +386,7 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa
386386
throw new RuntimeException(
387387
'Your Composer version is too old.'
388388
. ' Please update Composer (run `composer self-update`) to v2.0.14 or later'
389-
. ' and remove your vendor/ directory, and run `composer update`.'
389+
. ' and remove your vendor/ directory, and run `composer update`.',
390390
);
391391
}
392392
// This method requires Composer 2.0.14 or later.

system/Autoloader/FileLocator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ public function findQualifiedNameFromPath(string $path)
295295
str_replace(
296296
'/',
297297
'\\',
298-
mb_substr($path, mb_strlen($namespace['path']))
298+
mb_substr($path, mb_strlen($namespace['path'])),
299299
),
300-
'\\'
300+
'\\',
301301
);
302302
// Remove the file extension (.php)
303303
$className = mb_substr($className, 0, -4);

system/BaseModel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ protected function createDataConverter(): void
379379
$this->converter = new DataConverter(
380380
$this->casts,
381381
$this->castHandlers,
382-
$this->db
382+
$this->db,
383383
);
384384
}
385385
}
@@ -1081,7 +1081,7 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
10811081
if ($updateIndex === null) {
10821082
throw new InvalidArgumentException(
10831083
'The index ("' . $index . '") for updateBatch() is missing in the data: '
1084-
. json_encode($row)
1084+
. json_encode($row),
10851085
);
10861086
}
10871087

system/Boot.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ protected static function checkMissingExtensions(): void
288288

289289
$message = sprintf(
290290
'The framework needs the following extension(s) installed and loaded: %s.',
291-
implode(', ', $missingExtensions)
291+
implode(', ', $missingExtensions),
292292
);
293293

294294
header('HTTP/1.1 503 Service Unavailable.', true, 503);

system/CLI/CLI.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,11 @@ public static function color(string $text, string $foreground, ?string $backgrou
610610
$nonColoredText = preg_replace(
611611
$pattern,
612612
'<<__colored_string__>>',
613-
$text
613+
$text,
614614
);
615615
$nonColoredChunks = preg_split(
616616
'/<<__colored_string__>>/u',
617-
$nonColoredText
617+
$nonColoredText,
618618
);
619619

620620
foreach ($nonColoredChunks as $i => $chunk) {

system/CLI/Console.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function showHeader(bool $suppress = false)
6363
'CodeIgniter v%s Command Line Tool - Server Time: %s UTC%s',
6464
CodeIgniter::CI_VERSION,
6565
date('Y-m-d H:i:s'),
66-
date('P')
66+
date('P'),
6767
), 'green');
6868
CLI::newLine();
6969
}

system/CLI/GeneratorTrait.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private function generateFile(string $target, string $content): void
171171
CLI::prompt(
172172
'Are you sure you want to continue?',
173173
['y', 'n'],
174-
'required'
174+
'required',
175175
) === 'n'
176176
) {
177177
CLI::newLine();
@@ -193,7 +193,7 @@ private function generateFile(string $target, string $content): void
193193
CLI::error(
194194
lang('CLI.generator.fileExist', [clean_path($target)]),
195195
'light_gray',
196-
'red'
196+
'red',
197197
);
198198
CLI::newLine();
199199

@@ -216,7 +216,7 @@ private function generateFile(string $target, string $content): void
216216
CLI::error(
217217
lang('CLI.generator.fileError', [clean_path($target)]),
218218
'light_gray',
219-
'red'
219+
'red',
220220
);
221221
CLI::newLine();
222222

@@ -227,7 +227,7 @@ private function generateFile(string $target, string $content): void
227227
if ($this->getOption('force') && $isFile) {
228228
CLI::write(
229229
lang('CLI.generator.fileOverwrite', [clean_path($target)]),
230-
'yellow'
230+
'yellow',
231231
);
232232
CLI::newLine();
233233

@@ -236,7 +236,7 @@ private function generateFile(string $target, string $content): void
236236

237237
CLI::write(
238238
lang('CLI.generator.fileCreate', [clean_path($target)]),
239-
'green'
239+
'green',
240240
);
241241
CLI::newLine();
242242
}
@@ -326,10 +326,10 @@ private function normalizeInputClassName(): string
326326
'\\',
327327
array_map(
328328
pascalize(...),
329-
explode('\\', str_replace('/', '\\', trim($class)))
330-
)
329+
explode('\\', str_replace('/', '\\', trim($class))),
330+
),
331331
),
332-
'\\/'
332+
'\\/',
333333
);
334334
}
335335

@@ -351,7 +351,7 @@ protected function renderTemplate(array $data = []): string
351351
return view(
352352
"CodeIgniter\\Commands\\Generators\\Views\\{$this->template}",
353353
$data,
354-
['debug' => false]
354+
['debug' => false],
355355
);
356356
}
357357
}
@@ -370,15 +370,15 @@ protected function parseTemplate(
370370
string $class,
371371
array $search = [],
372372
array $replace = [],
373-
array $data = []
373+
array $data = [],
374374
): string {
375375
// Retrieves the namespace part from the fully qualified class name.
376376
$namespace = trim(
377377
implode(
378378
'\\',
379-
array_slice(explode('\\', $class), 0, -1)
379+
array_slice(explode('\\', $class), 0, -1),
380380
),
381-
'\\'
381+
'\\',
382382
);
383383
$search[] = '<@php';
384384
$search[] = '{namespace}';
@@ -404,7 +404,7 @@ protected function buildContent(string $class): string
404404
&& preg_match(
405405
'/(?P<imports>(?:^use [^;]+;$\n?)+)/m',
406406
$template,
407-
$match
407+
$match,
408408
)
409409
) {
410410
$imports = explode("\n", trim($match['imports']));
@@ -432,7 +432,7 @@ protected function buildPath(string $class): string
432432
CLI::error(
433433
lang('CLI.namespaceNotDefined', [$namespace]),
434434
'light_gray',
435-
'red'
435+
'red',
436436
);
437437
CLI::newLine();
438438

@@ -446,16 +446,16 @@ protected function buildPath(string $class): string
446446
. str_replace(
447447
'\\',
448448
DIRECTORY_SEPARATOR,
449-
trim(str_replace($namespace . '\\', '', $class), '\\')
449+
trim(str_replace($namespace . '\\', '', $class), '\\'),
450450
) . '.php';
451451

452452
return implode(
453453
DIRECTORY_SEPARATOR,
454454
array_slice(
455455
explode(DIRECTORY_SEPARATOR, $file),
456456
0,
457-
-1
458-
)
457+
-1,
458+
),
459459
) . DIRECTORY_SEPARATOR . $this->basename($file);
460460
}
461461

@@ -470,9 +470,9 @@ protected function getNamespace(): string
470470
str_replace(
471471
'/',
472472
'\\',
473-
$this->getOption('namespace') ?? APP_NAMESPACE
473+
$this->getOption('namespace') ?? APP_NAMESPACE,
474474
),
475-
'\\'
475+
'\\',
476476
);
477477
}
478478

0 commit comments

Comments
 (0)