Skip to content

🤖 Automatic code style fixes #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions LangProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class LangProcessor
{

/** @var CLI */
protected $logger;

Expand Down Expand Up @@ -63,7 +62,7 @@ public function processSettingsFile($file)
include $file;

$drop = array_diff_key($lang, $this->settingKeys);
foreach ($drop as $key => $value) {
foreach (array_keys($drop) as $key) {
$this->removeLangKey($file, $key);
}
}
Expand Down Expand Up @@ -229,7 +228,6 @@ private function extract($file, $regex)
if (!isset($found[$key])) {
$found[$key] = $file . ':' . ($lno + 1);
}

}
}

Expand Down
7 changes: 3 additions & 4 deletions SVGIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
*/
class SVGIcon
{

const SOURCES = [
public const SOURCES = [
'mdi' => "https://raw.githubusercontent.com/Templarian/MaterialDesign/master/svg/%s.svg",
'fab' => "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/svgs/brands/%s.svg",
'fas' => "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/svgs/solid/%s.svg",
Expand Down Expand Up @@ -97,7 +96,7 @@ public function cleanSVGFile($file)
public function remoteIcon($ident)
{
if (strpos($ident, ':')) {
list($prefix, $name) = explode(':', $ident);
[$prefix, $name] = explode(':', $ident);
} else {
$prefix = 'mdi';
$name = $ident;
Expand Down Expand Up @@ -130,6 +129,7 @@ protected function cleanSVG($svgdata)

$dom = new \DOMDocument();
$dom->loadXML($svgdata, LIBXML_NOBLANKS);

$dom->formatOutput = false;
$dom->preserveWhiteSpace = false;

Expand Down Expand Up @@ -225,5 +225,4 @@ protected function fetchSVG($url)

return $svg;
}

}
8 changes: 4 additions & 4 deletions Skeletor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
class Skeletor
{
// FIXME this may change upstream we may want to update it via github action
const PLUGIN_TYPES = ['auth', 'admin', 'syntax', 'action', 'renderer', 'helper', 'remote', 'cli'];
public const PLUGIN_TYPES = ['auth', 'admin', 'syntax', 'action', 'renderer', 'helper', 'remote', 'cli'];

const TYPE_PLUGIN = 'plugin';
const TYPE_TEMPLATE = 'template';
public const TYPE_PLUGIN = 'plugin';
public const TYPE_TEMPLATE = 'template';

protected $type;
protected $base;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function __construct($type, $base, $desc, $author, $email, $name = '', $u
* @param string $dir
* @return Skeletor
*/
static public function fromDir($dir)
public static function fromDir($dir)
{
if (file_exists($dir . '/plugin.info.txt')) {
$type = self::TYPE_PLUGIN;
Expand Down
80 changes: 56 additions & 24 deletions cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ protected function setup(Options $options)

$options->registerCommand('init', 'Initialize a new plugin or template in the current directory.');
$options->registerCommand('addTest', 'Add the testing framework files and a test. (_test/)');
$options->registerArgument('test', 'Optional name of the new test. Defaults to the general test.', false,
'addTest');
$options->registerArgument(
'test',
'Optional name of the new test. Defaults to the general test.',
false,
'addTest'
);
$options->registerCommand('addConf', 'Add the configuration files. (conf/)');
$options->registerCommand('addLang', 'Add the language files. (lang/)');

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

$options->registerCommand('addComponent', 'Add a new plugin component.');
$options->registerArgument('type', 'Type of the component. Needs to be one of ' . join(', ', $types), true,
'addComponent');
$options->registerArgument('name', 'Optional name of the component. Defaults to a base component.', false,
'addComponent');
$options->registerArgument(
'type',
'Type of the component. Needs to be one of ' . implode(', ', $types),
true,
'addComponent'
);
$options->registerArgument(
'name',
'Optional name of the component. Defaults to a base component.',
false,
'addComponent'
);

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

$options->registerCommand('downloadSvg', 'Download an SVG file from a known icon repository.');
$options->registerArgument('prefix:name',
'Colon-prefixed name of the icon. Available prefixes: ' . join(', ', $prefixes), true, 'downloadSvg');
$options->registerArgument('output', 'File to save, defaults to <name>.svg in current dir', false,
'downloadSvg');
$options->registerOption('keep-ns', 'Keep the SVG namespace. Use when the file is not inlined into HTML.', 'k',
false, 'downloadSvg');
$options->registerArgument(
'prefix:name',
'Colon-prefixed name of the icon. Available prefixes: ' . implode(', ', $prefixes),
true,
'downloadSvg'
);
$options->registerArgument(
'output',
'File to save, defaults to <name>.svg in current dir',
false,
'downloadSvg'
);
$options->registerOption(
'keep-ns',
'Keep the SVG namespace. Use when the file is not inlined into HTML.',
'k',
false,
'downloadSvg'
);

$options->registerCommand('cleanSvg', 'Clean a existing SVG files to reduce their file size.');
$options->registerArgument('files...', 'The files to clean (will be overwritten)', true, 'cleanSvg');
$options->registerOption('keep-ns', 'Keep the SVG namespace. Use when the file is not inlined into HTML.', 'k',
false, 'cleanSvg');
$options->registerOption(
'keep-ns',
'Keep the SVG namespace. Use when the file is not inlined into HTML.',
'k',
false,
'cleanSvg'
);

$options->registerCommand('cleanLang',
$options->registerCommand(
'cleanLang',
'Clean language files from unused language strings. Detecting which strings are truly in use may ' .
'not always correctly work. Use with caution.');
'not always correctly work. Use with caution.'
);

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

Expand Down Expand Up @@ -243,7 +275,7 @@ protected function deleteFile($file)
protected function git(...$args)
{
$args = array_map('escapeshellarg', $args);
$cmd = 'git ' . join(' ', $args);
$cmd = 'git ' . implode(' ', $args);
$output = [];
$result = 0;

Expand Down Expand Up @@ -363,14 +395,14 @@ protected function cmdDeletedFiles()
});
sort($output);

if (!count($output)) {
if ($output === []) {
$this->info('No deleted files found');
return 0;
}

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

file_put_contents('deleted.files', $content);
$this->success('written deleted.files');
Expand Down Expand Up @@ -464,7 +496,7 @@ protected function cmdTest()
'--configuration', fullpath(__DIR__ . '/../../../_test/phpunit.xml'),
'--group', $type . '_' . $base,
];
$cmd = join(' ', array_map('escapeshellarg', $args));
$cmd = implode(' ', array_map('escapeshellarg', $args));
$this->info("Running $cmd");

$result = 0;
Expand Down Expand Up @@ -492,7 +524,7 @@ protected function cmdCheck($files = [])
$args[] = fullpath($dir);
}

$cmd = join(' ', array_map('escapeshellarg', $args));
$cmd = implode(' ', array_map('escapeshellarg', $args));
$this->info("Running $cmd");

$result = 0;
Expand Down Expand Up @@ -522,12 +554,12 @@ protected function cmdFix($files = [])
$args[] = fullpath($dir);
}

$cmd = join(' ', array_map('escapeshellarg', $args));
$cmd = implode(' ', array_map('escapeshellarg', $args));
$this->info("Running $cmd");

$result = 0;
passthru($cmd, $result);
if($result !== 0) return $result;
if ($result !== 0) return $result;

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

$cmd = join(' ', array_map('escapeshellarg', $args));
$cmd = implode(' ', array_map('escapeshellarg', $args));
$this->info("Running $cmd");

$result = 0;
Expand Down
4 changes: 2 additions & 2 deletions skel/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class @@PLUGIN_COMPONENT_NAME@@ extends ActionPlugin
/** @inheritDoc */
public function register(EventHandler $controller)
{
@@REGISTER@@
@@REGISTER@@
}

@@HANDLERS@@
@@HANDLERS@@
}
3 changes: 0 additions & 3 deletions skel/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
class @@PLUGIN_COMPONENT_NAME@@ extends \dokuwiki\Extension\CLIPlugin
{

/** @inheritDoc */
protected function setup(Options $options)
{
Expand All @@ -33,6 +32,4 @@ protected function main(Options $options)
// $command = $options->getCmd()
// $arguments = $options->getArgs()
}

}

2 changes: 1 addition & 1 deletion skel/conf/default.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* Default settings for the @@PLUGIN_NAME@@ plugin
*
* @author @@AUTHOR_NAME@@ <@@AUTHOR_MAIL@@>
*/

//$conf['fixme'] = 'FIXME';

3 changes: 1 addition & 2 deletions skel/conf/metadata.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php

/**
* Options for the @@PLUGIN_NAME@@ plugin
*
* @author @@AUTHOR_NAME@@ <@@AUTHOR_MAIL@@>
*/


//$meta['fixme'] = array('string');

2 changes: 1 addition & 1 deletion skel/lang/lang.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* English language file for @@PLUGIN_NAME@@ plugin
*
Expand All @@ -10,4 +11,3 @@

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

2 changes: 1 addition & 1 deletion skel/lang/settings.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* english language file for @@PLUGIN_NAME@@ plugin
*
Expand All @@ -7,4 +8,3 @@

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

9 changes: 1 addition & 8 deletions www/PluginWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class PluginWizard
{

/**
* @throws ArchiveIllegalCompressionException
* @throws ArchiveIOException
Expand All @@ -36,7 +35,7 @@ public function handle()
if (!empty($_POST['use_test'])) $skeletor->addTest();

foreach ($_POST['components'] as $id) {
list($type, /*"plugin"*/, /*base*/, $component) = array_pad(explode('_', $id, 4), 4, '');
[$type, , , $component] = array_pad(explode('_', $id, 4), 4, '');
if (isset($_POST['options'][$id])) {
$options = array_filter(array_map('trim', explode(',', $_POST['options'][$id])));
} else {
Expand Down Expand Up @@ -69,10 +68,4 @@ public function getEvents()
{
return array_map('trim', file(__DIR__ . '/../events.txt', FILE_IGNORE_NEW_LINES));
}

}





2 changes: 1 addition & 1 deletion www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<label>
<span>Type:</span>
<select>
<?php foreach ($WIZ->getPluginTypes() as $type): ?>
<?php foreach ($WIZ->getPluginTypes() as $type) : ?>
<option value="<?php echo $type ?>"><?php echo ucfirst($type) ?></option>
<?php endforeach; ?>
</select>
Expand Down