Skip to content

Commit 98dda39

Browse files
authored
🤖 Automatic code style fixes
1 parent a038ada commit 98dda39

12 files changed

+72
-54
lines changed

‎LangProcessor.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
class LangProcessor
88
{
9-
109
/** @var CLI */
1110
protected $logger;
1211

@@ -63,7 +62,7 @@ public function processSettingsFile($file)
6362
include $file;
6463

6564
$drop = array_diff_key($lang, $this->settingKeys);
66-
foreach ($drop as $key => $value) {
65+
foreach (array_keys($drop) as $key) {
6766
$this->removeLangKey($file, $key);
6867
}
6968
}
@@ -229,7 +228,6 @@ private function extract($file, $regex)
229228
if (!isset($found[$key])) {
230229
$found[$key] = $file . ':' . ($lno + 1);
231230
}
232-
233231
}
234232
}
235233

‎SVGIcon.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
*/
1111
class SVGIcon
1212
{
13-
14-
const SOURCES = [
13+
public const SOURCES = [
1514
'mdi' => "https://raw.githubusercontent.com/Templarian/MaterialDesign/master/svg/%s.svg",
1615
'fab' => "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/svgs/brands/%s.svg",
1716
'fas' => "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/svgs/solid/%s.svg",
@@ -97,7 +96,7 @@ public function cleanSVGFile($file)
9796
public function remoteIcon($ident)
9897
{
9998
if (strpos($ident, ':')) {
100-
list($prefix, $name) = explode(':', $ident);
99+
[$prefix, $name] = explode(':', $ident);
101100
} else {
102101
$prefix = 'mdi';
103102
$name = $ident;
@@ -130,6 +129,7 @@ protected function cleanSVG($svgdata)
130129

131130
$dom = new \DOMDocument();
132131
$dom->loadXML($svgdata, LIBXML_NOBLANKS);
132+
133133
$dom->formatOutput = false;
134134
$dom->preserveWhiteSpace = false;
135135

@@ -225,5 +225,4 @@ protected function fetchSVG($url)
225225

226226
return $svg;
227227
}
228-
229228
}

‎Skeletor.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
class Skeletor
1414
{
1515
// FIXME this may change upstream we may want to update it via github action
16-
const PLUGIN_TYPES = ['auth', 'admin', 'syntax', 'action', 'renderer', 'helper', 'remote', 'cli'];
16+
public const PLUGIN_TYPES = ['auth', 'admin', 'syntax', 'action', 'renderer', 'helper', 'remote', 'cli'];
1717

18-
const TYPE_PLUGIN = 'plugin';
19-
const TYPE_TEMPLATE = 'template';
18+
public const TYPE_PLUGIN = 'plugin';
19+
public const TYPE_TEMPLATE = 'template';
2020

2121
protected $type;
2222
protected $base;
@@ -65,7 +65,7 @@ public function __construct($type, $base, $desc, $author, $email, $name = '', $u
6565
* @param string $dir
6666
* @return Skeletor
6767
*/
68-
static public function fromDir($dir)
68+
public static function fromDir($dir)
6969
{
7070
if (file_exists($dir . '/plugin.info.txt')) {
7171
$type = self::TYPE_PLUGIN;

‎cli.php

+56-24
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ protected function setup(Options $options)
3131

3232
$options->registerCommand('init', 'Initialize a new plugin or template in the current directory.');
3333
$options->registerCommand('addTest', 'Add the testing framework files and a test. (_test/)');
34-
$options->registerArgument('test', 'Optional name of the new test. Defaults to the general test.', false,
35-
'addTest');
34+
$options->registerArgument(
35+
'test',
36+
'Optional name of the new test. Defaults to the general test.',
37+
false,
38+
'addTest'
39+
);
3640
$options->registerCommand('addConf', 'Add the configuration files. (conf/)');
3741
$options->registerCommand('addLang', 'Add the language files. (lang/)');
3842

@@ -45,10 +49,18 @@ function (&$item) {
4549
);
4650

4751
$options->registerCommand('addComponent', 'Add a new plugin component.');
48-
$options->registerArgument('type', 'Type of the component. Needs to be one of ' . join(', ', $types), true,
49-
'addComponent');
50-
$options->registerArgument('name', 'Optional name of the component. Defaults to a base component.', false,
51-
'addComponent');
52+
$options->registerArgument(
53+
'type',
54+
'Type of the component. Needs to be one of ' . implode(', ', $types),
55+
true,
56+
'addComponent'
57+
);
58+
$options->registerArgument(
59+
'name',
60+
'Optional name of the component. Defaults to a base component.',
61+
false,
62+
'addComponent'
63+
);
5264

5365
$options->registerCommand('deletedFiles', 'Create the list of deleted files based on the git history.');
5466
$options->registerCommand('rmObsolete', 'Delete obsolete files.');
@@ -62,21 +74,41 @@ function (&$item) {
6274
);
6375

6476
$options->registerCommand('downloadSvg', 'Download an SVG file from a known icon repository.');
65-
$options->registerArgument('prefix:name',
66-
'Colon-prefixed name of the icon. Available prefixes: ' . join(', ', $prefixes), true, 'downloadSvg');
67-
$options->registerArgument('output', 'File to save, defaults to <name>.svg in current dir', false,
68-
'downloadSvg');
69-
$options->registerOption('keep-ns', 'Keep the SVG namespace. Use when the file is not inlined into HTML.', 'k',
70-
false, 'downloadSvg');
77+
$options->registerArgument(
78+
'prefix:name',
79+
'Colon-prefixed name of the icon. Available prefixes: ' . implode(', ', $prefixes),
80+
true,
81+
'downloadSvg'
82+
);
83+
$options->registerArgument(
84+
'output',
85+
'File to save, defaults to <name>.svg in current dir',
86+
false,
87+
'downloadSvg'
88+
);
89+
$options->registerOption(
90+
'keep-ns',
91+
'Keep the SVG namespace. Use when the file is not inlined into HTML.',
92+
'k',
93+
false,
94+
'downloadSvg'
95+
);
7196

7297
$options->registerCommand('cleanSvg', 'Clean a existing SVG files to reduce their file size.');
7398
$options->registerArgument('files...', 'The files to clean (will be overwritten)', true, 'cleanSvg');
74-
$options->registerOption('keep-ns', 'Keep the SVG namespace. Use when the file is not inlined into HTML.', 'k',
75-
false, 'cleanSvg');
99+
$options->registerOption(
100+
'keep-ns',
101+
'Keep the SVG namespace. Use when the file is not inlined into HTML.',
102+
'k',
103+
false,
104+
'cleanSvg'
105+
);
76106

77-
$options->registerCommand('cleanLang',
107+
$options->registerCommand(
108+
'cleanLang',
78109
'Clean language files from unused language strings. Detecting which strings are truly in use may ' .
79-
'not always correctly work. Use with caution.');
110+
'not always correctly work. Use with caution.'
111+
);
80112

81113
$options->registerCommand('test', 'Run the unit tests for this extension.');
82114

@@ -243,7 +275,7 @@ protected function deleteFile($file)
243275
protected function git(...$args)
244276
{
245277
$args = array_map('escapeshellarg', $args);
246-
$cmd = 'git ' . join(' ', $args);
278+
$cmd = 'git ' . implode(' ', $args);
247279
$output = [];
248280
$result = 0;
249281

@@ -363,14 +395,14 @@ protected function cmdDeletedFiles()
363395
});
364396
sort($output);
365397

366-
if (!count($output)) {
398+
if ($output === []) {
367399
$this->info('No deleted files found');
368400
return 0;
369401
}
370402

371403
$content = "# This is a list of files that were present in previous releases\n" .
372404
"# but were removed later. They should not exist in your installation.\n" .
373-
join("\n", $output) . "\n";
405+
implode("\n", $output) . "\n";
374406

375407
file_put_contents('deleted.files', $content);
376408
$this->success('written deleted.files');
@@ -464,7 +496,7 @@ protected function cmdTest()
464496
'--configuration', fullpath(__DIR__ . '/../../../_test/phpunit.xml'),
465497
'--group', $type . '_' . $base,
466498
];
467-
$cmd = join(' ', array_map('escapeshellarg', $args));
499+
$cmd = implode(' ', array_map('escapeshellarg', $args));
468500
$this->info("Running $cmd");
469501

470502
$result = 0;
@@ -492,7 +524,7 @@ protected function cmdCheck($files = [])
492524
$args[] = fullpath($dir);
493525
}
494526

495-
$cmd = join(' ', array_map('escapeshellarg', $args));
527+
$cmd = implode(' ', array_map('escapeshellarg', $args));
496528
$this->info("Running $cmd");
497529

498530
$result = 0;
@@ -522,12 +554,12 @@ protected function cmdFix($files = [])
522554
$args[] = fullpath($dir);
523555
}
524556

525-
$cmd = join(' ', array_map('escapeshellarg', $args));
557+
$cmd = implode(' ', array_map('escapeshellarg', $args));
526558
$this->info("Running $cmd");
527559

528560
$result = 0;
529561
passthru($cmd, $result);
530-
if($result !== 0) return $result;
562+
if ($result !== 0) return $result;
531563

532564
// now run phpcbf to clean up code style
533565
$args = [
@@ -543,7 +575,7 @@ protected function cmdFix($files = [])
543575
$args[] = fullpath($dir);
544576
}
545577

546-
$cmd = join(' ', array_map('escapeshellarg', $args));
578+
$cmd = implode(' ', array_map('escapeshellarg', $args));
547579
$this->info("Running $cmd");
548580

549581
$result = 0;

‎skel/action.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class @@PLUGIN_COMPONENT_NAME@@ extends ActionPlugin
1515
/** @inheritDoc */
1616
public function register(EventHandler $controller)
1717
{
18-
@@REGISTER@@
18+
@@REGISTER@@
1919
}
2020

21-
@@HANDLERS@@
21+
@@HANDLERS@@
2222
}

‎skel/cli.php

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111
class @@PLUGIN_COMPONENT_NAME@@ extends \dokuwiki\Extension\CLIPlugin
1212
{
13-
1413
/** @inheritDoc */
1514
protected function setup(Options $options)
1615
{
@@ -33,6 +32,4 @@ protected function main(Options $options)
3332
// $command = $options->getCmd()
3433
// $arguments = $options->getArgs()
3534
}
36-
3735
}
38-

‎skel/conf/default.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
2+
23
/**
34
* Default settings for the @@PLUGIN_NAME@@ plugin
45
*
56
* @author @@AUTHOR_NAME@@ <@@AUTHOR_MAIL@@>
67
*/
78

89
//$conf['fixme'] = 'FIXME';
9-

‎skel/conf/metadata.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
2+
23
/**
34
* Options for the @@PLUGIN_NAME@@ plugin
45
*
56
* @author @@AUTHOR_NAME@@ <@@AUTHOR_MAIL@@>
67
*/
78

8-
99
//$meta['fixme'] = array('string');
10-

‎skel/lang/lang.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* English language file for @@PLUGIN_NAME@@ plugin
45
*
@@ -10,4 +11,3 @@
1011

1112
// custom language strings for the plugin
1213
// $lang['fixme'] = 'FIXME';
13-

‎skel/lang/settings.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* english language file for @@PLUGIN_NAME@@ plugin
45
*
@@ -7,4 +8,3 @@
78

89
// keys need to match the config setting name
910
// $lang['fixme'] = 'FIXME';
10-

‎www/PluginWizard.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
class PluginWizard
1111
{
12-
1312
/**
1413
* @throws ArchiveIllegalCompressionException
1514
* @throws ArchiveIOException
@@ -36,7 +35,7 @@ public function handle()
3635
if (!empty($_POST['use_test'])) $skeletor->addTest();
3736

3837
foreach ($_POST['components'] as $id) {
39-
list($type, /*"plugin"*/, /*base*/, $component) = array_pad(explode('_', $id, 4), 4, '');
38+
[$type, , , $component] = array_pad(explode('_', $id, 4), 4, '');
4039
if (isset($_POST['options'][$id])) {
4140
$options = array_filter(array_map('trim', explode(',', $_POST['options'][$id])));
4241
} else {
@@ -69,10 +68,4 @@ public function getEvents()
6968
{
7069
return array_map('trim', file(__DIR__ . '/../events.txt', FILE_IGNORE_NEW_LINES));
7170
}
72-
7371
}
74-
75-
76-
77-
78-

‎www/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<label>
118118
<span>Type:</span>
119119
<select>
120-
<?php foreach ($WIZ->getPluginTypes() as $type): ?>
120+
<?php foreach ($WIZ->getPluginTypes() as $type) : ?>
121121
<option value="<?php echo $type ?>"><?php echo ucfirst($type) ?></option>
122122
<?php endforeach; ?>
123123
</select>

0 commit comments

Comments
 (0)