Skip to content

Commit

Permalink
Fix plugin:make command, remove uppercase name
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywhalecc committed Oct 1, 2024
1 parent d92e7fe commit 8c81219
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit 8c81219

Please sign in to comment.