Skip to content

Commit 330a0ea

Browse files
Fix CS issues
1 parent 616bbba commit 330a0ea

27 files changed

+959
-924
lines changed

.editorconfig

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66

77
root = true
88

9-
[*.php]
9+
[*]
1010
charset = utf-8
1111
end_of_line = lf
12-
insert_final_newline = true
12+
indent_style = tab
13+
indent_size = 2
1314
trim_trailing_whitespace = true
14-
indent_style = space
15-
indent_size = 4

.php-cs-fixer.dist.php

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('dependencies')
5+
->exclude('panel/node_modules')
6+
->in(__DIR__);
7+
8+
$config = new PhpCsFixer\Config();
9+
return $config
10+
->setRules([
11+
'@PSR12' => true,
12+
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
13+
'array_indentation' => true,
14+
'array_syntax' => ['syntax' => 'short'],
15+
'cast_spaces' => ['space' => 'none'],
16+
// 'class_keyword_remove' => true, // replaces static::class with 'static' (won't work)
17+
'combine_consecutive_issets' => true,
18+
'combine_consecutive_unsets' => true,
19+
'combine_nested_dirname' => true,
20+
'concat_space' => ['spacing' => 'one'],
21+
'declare_equal_normalize' => ['space' => 'single'],
22+
'dir_constant' => true,
23+
'function_typehint_space' => true,
24+
'include' => true,
25+
'logical_operators' => true,
26+
'lowercase_cast' => true,
27+
'lowercase_static_reference' => true,
28+
'magic_constant_casing' => true,
29+
'magic_method_casing' => true,
30+
'method_chaining_indentation' => true,
31+
'modernize_types_casting' => true,
32+
'multiline_comment_opening_closing' => true,
33+
'native_function_casing' => true,
34+
'native_function_type_declaration_casing' => true,
35+
'new_with_braces' => true,
36+
'no_blank_lines_after_class_opening' => true,
37+
'no_blank_lines_after_phpdoc' => true,
38+
'no_empty_comment' => true,
39+
'no_empty_phpdoc' => true,
40+
'no_empty_statement' => true,
41+
'no_leading_namespace_whitespace' => true,
42+
'no_mixed_echo_print' => ['use' => 'echo'],
43+
'no_unneeded_control_parentheses' => true,
44+
'no_unused_imports' => true,
45+
'no_useless_return' => true,
46+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
47+
// 'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], // adds params in the wrong order
48+
'phpdoc_align' => ['align' => 'left'],
49+
'phpdoc_indent' => true,
50+
'phpdoc_scalar' => true,
51+
'phpdoc_trim' => true,
52+
'short_scalar_cast' => true,
53+
'single_line_comment_style' => true,
54+
'single_quote' => true,
55+
'ternary_to_null_coalescing' => true,
56+
'whitespace_after_comma_in_array' => true
57+
])
58+
->setRiskyAllowed(true)
59+
->setIndent("\t")
60+
->setFinder($finder);

commands/clear/cache.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types = 1);
44

55
use Kirby\CLI\CLI;
66

77
return [
8-
'description' => 'Clears the cache',
9-
'args' => [
10-
'name' => [
11-
'description' => 'The name of the cache',
12-
]
13-
],
14-
'command' => static function (CLI $cli): void {
15-
$kirby = $cli->kirby();
16-
$name = $cli->argOrPrompt('name', 'Which cache should be emptied? (press <Enter> to clear the pages cache)', false);
17-
$name ??= 'pages';
8+
'description' => 'Clears the cache',
9+
'args' => [
10+
'name' => [
11+
'description' => 'The name of the cache',
12+
]
13+
],
14+
'command' => static function (CLI $cli): void {
15+
$kirby = $cli->kirby();
16+
$name = $cli->argOrPrompt('name', 'Which cache should be emptied? (press <Enter> to clear the pages cache)', false);
17+
$name ??= 'pages';
1818

19-
$kirby->cache($name)->flush();
19+
$kirby->cache($name)->flush();
2020

21-
$cli->success('The cache has been cleared');
22-
}
21+
$cli->success('The cache has been cleared');
22+
}
2323
];

commands/clear/media.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types = 1);
44

55
use Kirby\CLI\CLI;
66
use Kirby\Filesystem\Dir;
77

88
return [
9-
'description' => 'Deletes the media folder',
10-
'command' => static function (CLI $cli): void {
11-
Dir::remove($cli->kirby()->root('media'));
9+
'description' => 'Deletes the media folder',
10+
'command' => static function (CLI $cli): void {
11+
Dir::remove($cli->kirby()->root('media'));
1212

13-
$cli->success('The media folder has been deleted');
14-
}
13+
$cli->success('The media folder has been deleted');
14+
}
1515
];

commands/clear/sessions.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types = 1);
44

55
use Kirby\CLI\CLI;
66
use Kirby\Filesystem\Dir;
77

88
return [
9-
'description' => 'Destroys all sessions',
10-
'command' => static function (CLI $cli): void {
11-
Dir::remove($cli->kirby()->root('sessions'));
9+
'description' => 'Destroys all sessions',
10+
'command' => static function (CLI $cli): void {
11+
Dir::remove($cli->kirby()->root('sessions'));
1212

13-
$cli->success('The sessions have been destroyed');
14-
}
13+
$cli->success('The sessions have been destroyed');
14+
}
1515
];

commands/download.php

+35-41
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,43 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types = 1);
44

55
use GuzzleHttp\Client;
66
use Kirby\CLI\CLI;
77

88
return [
9-
'description' => 'Downloads a file via URL',
10-
'args' => [
11-
'url' => [
12-
'description' => 'The URL to the file',
13-
'required' => true
14-
],
15-
'file' => [
16-
'description' => 'Where to save the download',
17-
'required' => true
18-
],
19-
],
20-
'command' => static function (CLI $cli): void {
21-
22-
$client = new Client();
23-
$progress = $cli->progress()->total(100);
24-
25-
try {
26-
$response = $client->get($cli->arg('url'), [
27-
'progress' => function ($total, $downloaded) use ($cli, $progress): void {
28-
try {
29-
if ($total > 0 && $downloaded > 0) {
30-
$progress->total($total);
31-
$progress->current($downloaded);
32-
}
33-
} catch (Throwable $e) {
34-
$cli->out($e->getMessage());
35-
}
36-
},
37-
]);
38-
39-
file_put_contents($cli->arg('file'), (string)$response->getBody());
40-
41-
} catch (Throwable $e) {
42-
throw new Exception('The file could not be downloaded. (Status: ' . $e->getResponse()->getStatusCode() . ')');
43-
}
44-
45-
}
9+
'description' => 'Downloads a file via URL',
10+
'args' => [
11+
'url' => [
12+
'description' => 'The URL to the file',
13+
'required' => true
14+
],
15+
'file' => [
16+
'description' => 'Where to save the download',
17+
'required' => true
18+
],
19+
],
20+
'command' => static function (CLI $cli): void {
21+
$client = new Client();
22+
$progress = $cli->progress()->total(100);
23+
24+
try {
25+
$response = $client->get($cli->arg('url'), [
26+
'progress' => function ($total, $downloaded) use ($cli, $progress): void {
27+
try {
28+
if ($total > 0 && $downloaded > 0) {
29+
$progress->total($total);
30+
$progress->current($downloaded);
31+
}
32+
} catch (Throwable $e) {
33+
$cli->out($e->getMessage());
34+
}
35+
},
36+
]);
37+
38+
file_put_contents($cli->arg('file'), (string)$response->getBody());
39+
} catch (Throwable $e) {
40+
throw new Exception('The file could not be downloaded. (Status: ' . $e->getResponse()->getStatusCode() . ')');
41+
}
42+
}
4643
];
47-
48-
49-

commands/help.php

+27-28
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types = 1);
44

55
use Kirby\CLI\CLI;
66

77
return [
8-
'description' => 'Prints help for the Kirby CLI',
9-
'command' => static function (CLI $cli): void {
8+
'description' => 'Prints help for the Kirby CLI',
9+
'command' => static function (CLI $cli): void {
10+
$commands = $cli->commands();
1011

11-
$commands = $cli->commands();
12+
$cli->bold('Kirby CLI ' . $cli->version());
13+
$cli->br();
14+
$cli->out('Core commands:');
1215

13-
$cli->bold('Kirby CLI ' . $cli->version());
14-
$cli->br();
15-
$cli->out('Core commands:');
16+
foreach ($commands['core'] as $command) {
17+
$cli->out('- kirby ' . $command);
18+
}
1619

17-
foreach ($commands['core'] as $command) {
18-
$cli->out('- kirby ' . $command);
19-
}
20+
if (count($commands['global']) > 0) {
21+
$cli->br();
22+
$cli->out('Global commands:');
2023

21-
if (count($commands['global']) > 0) {
22-
$cli->br();
23-
$cli->out('Global commands:');
24+
foreach ($commands['global'] as $command) {
25+
$cli->out('- kirby ' . $command);
26+
}
27+
}
2428

25-
foreach ($commands['global'] as $command) {
26-
$cli->out('- kirby ' . $command);
27-
}
28-
}
29+
if (count($commands['custom']) > 0) {
30+
$cli->br();
31+
$cli->out('Custom commands:');
2932

30-
if (count($commands['custom']) > 0) {
31-
$cli->br();
32-
$cli->out('Custom commands:');
33+
foreach ($commands['custom'] as $command) {
34+
$cli->out('- kirby ' . $command);
35+
}
36+
}
3337

34-
foreach ($commands['custom'] as $command) {
35-
$cli->out('- kirby ' . $command);
36-
}
37-
}
38+
$cli->br();
3839

39-
$cli->br();
40-
41-
$cli->success('Have fun with the Kirby CLI!');
42-
}
40+
$cli->success('Have fun with the Kirby CLI!');
41+
}
4342
];

commands/install.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types = 1);
44

55
use Kirby\CLI\CLI;
66

77
return [
8-
'description' => 'Installs the kirby folder',
9-
'args' => [
10-
'version' => [
11-
'description' => 'The version corresponding with the tag name in the repo',
12-
'defaultValue' => 'latest'
13-
]
14-
],
15-
'command' => static function (CLI $cli): void {
16-
$cli->out('Installing Kirby (' . $cli->arg('version') . ') …');
17-
$cli->run('install:repo', 'getkirby/kirby', 'kirby', '--version=' . $cli->arg('version'));
18-
$cli->success('Kirby has been installed');
19-
}
8+
'description' => 'Installs the kirby folder',
9+
'args' => [
10+
'version' => [
11+
'description' => 'The version corresponding with the tag name in the repo',
12+
'defaultValue' => 'latest'
13+
]
14+
],
15+
'command' => static function (CLI $cli): void {
16+
$cli->out('Installing Kirby (' . $cli->arg('version') . ') …');
17+
$cli->run('install:repo', 'getkirby/kirby', 'kirby', '--version=' . $cli->arg('version'));
18+
$cli->success('Kirby has been installed');
19+
}
2020
];

0 commit comments

Comments
 (0)