Skip to content

Commit 9d37f1d

Browse files
committed
Apply cs-fix
1 parent 78a008b commit 9d37f1d

17 files changed

Lines changed: 86 additions & 86 deletions

src/Command/CreateCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public function __invoke(): int
4343

4444
$pluginPath = Plugin::PLUGIN_PATH . '/' . $path;
4545
if (file_exists($pluginPath)) {
46-
$this->output->error(sprintf('Plugin directory %s already exists', $path));
46+
$this->output->error(\sprintf('Plugin directory %s already exists', $path));
4747
return AbstractCommand::FAILURE;
4848
}
4949
$createDirectors = [
5050
$pluginPath, $pluginPath . '/src', $pluginPath . '/Database', $pluginPath . '/Database/Migrations', $pluginPath . '/Database/Seeder', $pluginPath . '/web',
5151
];
5252
foreach ($createDirectors as $directory) {
53-
if (! mkdir($directory, 0755, true) && ! is_dir($directory)) {
54-
throw new \RuntimeException(sprintf('Directory "%s" was not created', $directory));
53+
if (! mkdir($directory, 0o755, true) && ! is_dir($directory)) {
54+
throw new \RuntimeException(\sprintf('Directory "%s" was not created', $directory));
5555
}
5656
}
5757

@@ -97,24 +97,24 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi
9797
];
9898
}
9999

100-
$output = json_encode($output, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE, 512);
100+
$output = json_encode($output, \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE, 512);
101101
file_put_contents($path . '/mine.json', $output);
102-
$this->output->success(sprintf('%s 创建成功', $path . '/mine.json'));
102+
$this->output->success(\sprintf('%s 创建成功', $path . '/mine.json'));
103103
}
104104

105105
public function createInstallScript(string $namespace, string $path): void
106106
{
107107
$installScript = $this->buildStub('InstallScript', compact('namespace'));
108108
$installScriptPath = $path . '/src/InstallScript.php';
109109
file_put_contents($installScriptPath, $installScript);
110-
$this->output->success(sprintf('%s Created Successfully', $installScriptPath));
110+
$this->output->success(\sprintf('%s Created Successfully', $installScriptPath));
111111
}
112112

113113
public function buildStub(string $stub, array $replace): string
114114
{
115115
$stubPath = $this->getStubDirectory() . '/' . $stub . '.stub';
116116
if (! file_exists($stubPath)) {
117-
throw new \RuntimeException(sprintf('File %s does not exist', $stubPath));
117+
throw new \RuntimeException(\sprintf('File %s does not exist', $stubPath));
118118
}
119119
$stubBody = file_get_contents($stubPath);
120120
foreach ($replace as $key => $value) {
@@ -133,15 +133,15 @@ public function createUninstallScript(string $namespace, string $path): void
133133
$installScript = $this->buildStub('UninstallScript', compact('namespace'));
134134
$installScriptPath = $path . '/src/UninstallScript.php';
135135
file_put_contents($installScriptPath, $installScript);
136-
$this->output->success(sprintf('%s Created Successfully', $installScriptPath));
136+
$this->output->success(\sprintf('%s Created Successfully', $installScriptPath));
137137
}
138138

139139
public function createConfigProvider(string $namespace, string $path): void
140140
{
141141
$installScript = $this->buildStub('ConfigProvider', compact('namespace'));
142142
$installScriptPath = $path . '/src/ConfigProvider.php';
143143
file_put_contents($installScriptPath, $installScript);
144-
$this->output->success(sprintf('%s Created Successfully', $installScriptPath));
144+
$this->output->success(\sprintf('%s Created Successfully', $installScriptPath));
145145
}
146146

147147
protected function configure(): void
@@ -155,6 +155,6 @@ protected function configure(): void
155155

156156
private function createViewScript(string $namespace, string $path): void
157157
{
158-
! is_dir($path . '/web') && mkdir($path . '/web', 0775);
158+
! is_dir($path . '/web') && mkdir($path . '/web', 0o775);
159159
}
160160
}

src/Command/InitialCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __invoke(): int
2828
{
2929
$this->output->info('Start initialization');
3030
$this->output->info('Publishing multilingual documents');
31-
$publishPath = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'publish';
31+
$publishPath = \dirname(__DIR__, 2) . \DIRECTORY_SEPARATOR . 'publish';
3232
$languages = BASE_PATH . '/storage/languages';
3333
FileSystem::copy($publishPath . '/trans/en.php', $languages . '/en/app-store.php');
3434
FileSystem::copy($publishPath . '/trans/zh-CN.php', $languages . '/zh_CN/app-store.php');
@@ -38,8 +38,8 @@ public function __invoke(): int
3838
$this->output->success('Publishing Configuration File Succeeded');
3939

4040
if (! is_dir(Plugin::PLUGIN_PATH)) {
41-
if (! mkdir($concurrentDirectory = Plugin::PLUGIN_PATH, 0755, true) && ! is_dir($concurrentDirectory)) {
42-
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
41+
if (! mkdir($concurrentDirectory = Plugin::PLUGIN_PATH, 0o755, true) && ! is_dir($concurrentDirectory)) {
42+
throw new \RuntimeException(\sprintf('Directory "%s" was not created', $concurrentDirectory));
4343
}
4444
$binFile = file_get_contents(BASE_PATH . '/bin/hyperf.php');
4545
if (str_contains($binFile, 'Mine\AppStore\Plugin::init();')) {

src/Command/InstallCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __invoke(): int
3333
$headers = ['Extension name', 'author', 'description', 'homepage'];
3434
$rows[] = [
3535
$info['name'],
36-
is_string($info['author']) ? $info['author'] : ($info['author'][0]['name'] ?? '--'),
36+
\is_string($info['author']) ? $info['author'] : ($info['author'][0]['name'] ?? '--'),
3737
$info['description'],
3838
$info['homepage'] ?? '--',
3939
];
@@ -44,7 +44,7 @@ public function __invoke(): int
4444
return AbstractCommand::SUCCESS;
4545
}
4646
Plugin::install($path);
47-
$this->output->success(sprintf('Plugin %s installed successfully', $path));
47+
$this->output->success(\sprintf('Plugin %s installed successfully', $path));
4848
return AbstractCommand::SUCCESS;
4949
}
5050

src/Command/ListCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __invoke(): int
4646
'identifier' => $item['identifier'],
4747
'description' => $item['description'],
4848
'author' => $item['created_by'],
49-
'homePage' => is_array($item['homepage']) ? ($item['homepage'][0] ?? null) : $item['homepage'] ?? null,
49+
'homePage' => \is_array($item['homepage']) ? ($item['homepage'][0] ?? null) : $item['homepage'] ?? null,
5050
];
5151
}, $result);
5252
$headers = [

src/Command/LocalListCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __invoke(): int
3636
$info['name'],
3737
$info['description'],
3838
];
39-
if (is_string($info['author'])) {
39+
if (\is_string($info['author'])) {
4040
$current[] = $info['author'];
4141
} else {
4242
$current[] = $info['author'][0]['name'] ?? '--';

src/Command/Repository/PushCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public function __invoke(): int
2727
{
2828
$path = $this->input->getArgument('path');
2929
$repository = $this->input->getArgument('repository');
30-
$bin = dirname(__DIR__, 3) . '/bin';
31-
$repositoryPath = Plugin::PLUGIN_PREFIX . DIRECTORY_SEPARATOR . $path;
32-
$splitLinuxBin = $bin . DIRECTORY_SEPARATOR . 'split-linux.sh';
30+
$bin = \dirname(__DIR__, 3) . '/bin';
31+
$repositoryPath = Plugin::PLUGIN_PREFIX . \DIRECTORY_SEPARATOR . $path;
32+
$splitLinuxBin = $bin . \DIRECTORY_SEPARATOR . 'split-linux.sh';
3333
$basepath = BASE_PATH;
3434
$shell = <<<SHELL
35-
cd {$basepath} && {$splitLinuxBin} {$repositoryPath} {$repository} {$bin}
36-
SHELL;
35+
cd {$basepath} && {$splitLinuxBin} {$repositoryPath} {$repository} {$bin}
36+
SHELL;
3737
$result = System::exec($shell);
3838
if ($result['code'] !== 0) {
3939
$this->output->error('Fail' . $result['output']);

src/Command/Repository/ReleaseCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public function __invoke(): int
2828
$path = $this->argument('path');
2929
$repository = $this->argument('repository');
3030
$version = $this->argument('version');
31-
$bin = dirname(__DIR__, 3) . '/bin';
32-
$repositoryPath = Plugin::PLUGIN_PREFIX . DIRECTORY_SEPARATOR . $path;
33-
$splitLinuxBin = $bin . DIRECTORY_SEPARATOR . 'release.sh';
31+
$bin = \dirname(__DIR__, 3) . '/bin';
32+
$repositoryPath = Plugin::PLUGIN_PREFIX . \DIRECTORY_SEPARATOR . $path;
33+
$splitLinuxBin = $bin . \DIRECTORY_SEPARATOR . 'release.sh';
3434
$basepath = BASE_PATH;
3535
$shell = <<<SHELL
36-
cd {$basepath} && {$splitLinuxBin} {$repositoryPath} {$repository} {$version} {$bin}
37-
SHELL;
36+
cd {$basepath} && {$splitLinuxBin} {$repositoryPath} {$repository} {$version} {$bin}
37+
SHELL;
3838
$result = System::exec($shell);
3939
if ($result['code'] !== 0) {
4040
$this->output->error('Fail' . $result['output']);

src/Command/ScriptCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,28 @@ public function __invoke(): int
4747

4848
$publish = Arr::get($config, 'publish');
4949
if (empty($publish)) {
50-
$output->writeln(sprintf('<fg=red>No file can be published from plugin [%s].</>', $path));
50+
$output->writeln(\sprintf('<fg=red>No file can be published from plugin [%s].</>', $path));
5151
return AbstractCommand::FAILURE;
5252
}
5353

5454
if ($show) {
5555
foreach ($publish as $item) {
5656
$out = '';
5757
foreach ($item as $key => $value) {
58-
$out .= sprintf('%s: %s', $key, $value) . PHP_EOL;
58+
$out .= \sprintf('%s: %s', $key, $value) . \PHP_EOL;
5959
}
60-
$output->writeln(sprintf('<fg=green>%s</>', $out));
60+
$output->writeln(\sprintf('<fg=green>%s</>', $out));
6161
}
6262
return AbstractCommand::SUCCESS;
6363
}
6464

6565
if ($id) {
66-
$item = Arr::where($publish, function ($item) use ($id) {
67-
return $item['id'] == $id;
66+
$item = Arr::where($publish, static function ($item) use ($id) {
67+
return $item['id'] === $id;
6868
});
6969

7070
if (empty($item)) {
71-
$output->writeln(sprintf('<fg=red>No file can be published from [%s].</>', $id));
71+
$output->writeln(\sprintf('<fg=red>No file can be published from [%s].</>', $id));
7272
return AbstractCommand::FAILURE;
7373
}
7474
}
@@ -97,12 +97,12 @@ protected function copy($path, $items): bool
9797
$destination = $item['destination'];
9898

9999
if (! $this->force && $this->filesystem->exists($destination)) {
100-
$this->output->writeln(sprintf('<fg=red>[%s] already exists.</>', $destination));
100+
$this->output->writeln(\sprintf('<fg=red>[%s] already exists.</>', $destination));
101101
continue;
102102
}
103103

104-
if (! $this->filesystem->exists($dirname = dirname($destination))) {
105-
$this->filesystem->makeDirectory($dirname, 0755, true);
104+
if (! $this->filesystem->exists($dirname = \dirname($destination))) {
105+
$this->filesystem->makeDirectory($dirname, 0o755, true);
106106
}
107107

108108
if ($this->filesystem->isDirectory($source)) {
@@ -111,7 +111,7 @@ protected function copy($path, $items): bool
111111
$this->filesystem->copy($source, $destination);
112112
}
113113

114-
$this->output->writeln(sprintf('<fg=green>[%s] publishes [%s] successfully.</>', $path, $id));
114+
$this->output->writeln(\sprintf('<fg=green>[%s] publishes [%s] successfully.</>', $path, $id));
115115
}
116116
return true;
117117
}

src/Command/UninstallCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function __invoke(): int
3535
$yes = $this->input->getOption('yes');
3636
$pluginPath = BASE_PATH . '/plugin/' . $path;
3737
if (! is_dir($pluginPath)) {
38-
$this->output->error(sprintf('Plugin directory %s does not exist', $pluginPath));
38+
$this->output->error(\sprintf('Plugin directory %s does not exist', $pluginPath));
3939
return AbstractCommand::FAILURE;
4040
}
4141
$info = Plugin::read($path);
4242

4343
$headers = ['Extension name', 'author', 'description', 'homepage'];
4444
$rows[] = [
4545
$info['name'],
46-
is_string($info['author']) ? $info['author'] : ($info['author'][0]['name'] ?? '--'),
46+
\is_string($info['author']) ? $info['author'] : ($info['author'][0]['name'] ?? '--'),
4747
$info['description'],
4848
$info['homepage'] ?? '--',
4949
];
@@ -54,7 +54,7 @@ public function __invoke(): int
5454
return AbstractCommand::SUCCESS;
5555
}
5656
Plugin::uninstall($path);
57-
$this->output->success(sprintf('Plugin %s uninstalled successfully', $pluginPath));
57+
$this->output->success(\sprintf('Plugin %s uninstalled successfully', $pluginPath));
5858
return AbstractCommand::SUCCESS;
5959
}
6060

src/Enums/PluginTypeEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum PluginTypeEnum: string
3434

3535
public static function fromValue(string $value): ?self
3636
{
37-
return match (strtolower($value)) {
37+
return match (mb_strtolower($value)) {
3838
'mix' => self::Mix,
3939
'frond' => self::Frond,
4040
'backend' => self::Backend,

0 commit comments

Comments
 (0)