Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix plugin:make command, remove uppercase name #378

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions src/ZM/Command/Plugin/PluginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class PluginCommand extends Command

private static bool $loaded = false;

public function __construct(string $name = null)
public function __construct(?string $name = null)
{
parent::__construct($name);
if (!self::$loaded) {
Expand All @@ -30,16 +30,16 @@ public function __construct(string $name = null)
/**
* 插件名称合规验证器
*/
public function validatePluginName(string $answer): string
public function validatePluginName(?string $answer): string
{
if (empty($answer)) {
throw new \RuntimeException('插件名称不能为空');
}
if (is_numeric(mb_substr($answer, 0, 1))) {
throw new \RuntimeException('插件名称不能以数字开头,且只能包含字母、数字、下划线、短横线');
}
if (!preg_match('/^[\/a-zA-Z0-9_-]+$/', $answer)) {
throw new \RuntimeException('插件名称只能包含字母、数字、下划线、短横线');
if (!preg_match('/^[\/a-z0-9_-]+$/', $answer)) {
throw new \RuntimeException('插件名称只能包含小写字母、数字、下划线、短横线');
}
$exp = explode('/', $answer);
if (count($exp) !== 2) {
Expand Down Expand Up @@ -72,7 +72,7 @@ public function validateNamespace(string $answer): string
throw new \RuntimeException('插件命名空间不能以数字开头,且只能包含字母、数字、反斜线');
}
// 只能包含字母、数字和反斜线
if (!preg_match('/^[a-zA-Z0-9\\\\]+$/', $answer)) {
if (!preg_match('/^[a-zA-Z0-9\\\]+$/', $answer)) {
throw new \RuntimeException('插件命名空间只能包含字母、数字、反斜线');
}
return $answer;
Expand Down Expand Up @@ -101,7 +101,7 @@ protected function questionWithArgument(string $name, string $question, callable
* @param string $question 问题
* @param callable $validator 验证器
*/
protected function questionWithOption(string $name, string $question, callable $validator, string $default = null): void
protected function questionWithOption(string $name, string $question, callable $validator, ?string $default = null): void
{
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
Expand Down
Loading