mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-02 14:25:38 +08:00
Fix plugin:make command, remove uppercase name
This commit is contained in:
@@ -18,7 +18,7 @@ abstract class PluginCommand extends Command
|
|||||||
|
|
||||||
private static bool $loaded = false;
|
private static bool $loaded = false;
|
||||||
|
|
||||||
public function __construct(string $name = null)
|
public function __construct(?string $name = null)
|
||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
if (!self::$loaded) {
|
if (!self::$loaded) {
|
||||||
@@ -30,7 +30,7 @@ abstract class PluginCommand extends Command
|
|||||||
/**
|
/**
|
||||||
* 插件名称合规验证器
|
* 插件名称合规验证器
|
||||||
*/
|
*/
|
||||||
public function validatePluginName(string $answer): string
|
public function validatePluginName(?string $answer): string
|
||||||
{
|
{
|
||||||
if (empty($answer)) {
|
if (empty($answer)) {
|
||||||
throw new \RuntimeException('插件名称不能为空');
|
throw new \RuntimeException('插件名称不能为空');
|
||||||
@@ -38,8 +38,8 @@ abstract class PluginCommand extends Command
|
|||||||
if (is_numeric(mb_substr($answer, 0, 1))) {
|
if (is_numeric(mb_substr($answer, 0, 1))) {
|
||||||
throw new \RuntimeException('插件名称不能以数字开头,且只能包含字母、数字、下划线、短横线');
|
throw new \RuntimeException('插件名称不能以数字开头,且只能包含字母、数字、下划线、短横线');
|
||||||
}
|
}
|
||||||
if (!preg_match('/^[\/a-zA-Z0-9_-]+$/', $answer)) {
|
if (!preg_match('/^[\/a-z0-9_-]+$/', $answer)) {
|
||||||
throw new \RuntimeException('插件名称只能包含字母、数字、下划线、短横线');
|
throw new \RuntimeException('插件名称只能包含小写字母、数字、下划线、短横线');
|
||||||
}
|
}
|
||||||
$exp = explode('/', $answer);
|
$exp = explode('/', $answer);
|
||||||
if (count($exp) !== 2) {
|
if (count($exp) !== 2) {
|
||||||
@@ -72,7 +72,7 @@ abstract class PluginCommand extends Command
|
|||||||
throw new \RuntimeException('插件命名空间不能以数字开头,且只能包含字母、数字、反斜线');
|
throw new \RuntimeException('插件命名空间不能以数字开头,且只能包含字母、数字、反斜线');
|
||||||
}
|
}
|
||||||
// 只能包含字母、数字和反斜线
|
// 只能包含字母、数字和反斜线
|
||||||
if (!preg_match('/^[a-zA-Z0-9\\\\]+$/', $answer)) {
|
if (!preg_match('/^[a-zA-Z0-9\\\]+$/', $answer)) {
|
||||||
throw new \RuntimeException('插件命名空间只能包含字母、数字、反斜线');
|
throw new \RuntimeException('插件命名空间只能包含字母、数字、反斜线');
|
||||||
}
|
}
|
||||||
return $answer;
|
return $answer;
|
||||||
@@ -101,7 +101,7 @@ abstract class PluginCommand extends Command
|
|||||||
* @param string $question 问题
|
* @param string $question 问题
|
||||||
* @param callable $validator 验证器
|
* @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 */
|
/** @var QuestionHelper $helper */
|
||||||
$helper = $this->getHelper('question');
|
$helper = $this->getHelper('question');
|
||||||
|
|||||||
Reference in New Issue
Block a user