命令行bug

浏览:488 发布日期:2020/02/11 分类:ThinkPHP6专区 关键字: command console
执行命令 php think 或 php think list会抛异常
str_repeat(): Second argument has to be greater than or equal to 0

跟踪堆栈后定位在 vendor/topthink/framework/src/think/console/output/Descriptor.php : 256行中
$spacingWidth = $width - strlen($name);
$this->writeText(sprintf(" <info>%s</info>%s%s", $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)
->getDescription()), $options);

看了下 这个$width是取所有命令获取最长的脚本名称,但它的集合里面,是取脚本里面设置的name,如果这个name和console.php配置的不一致, 是不会存在这个集合里面,而是放在了一个别名里面:

if ($command->getName() === $name) {
$this->commands[$name] = $command;
} else {
$this->aliases[$name] = $command;
}
我试了一下 ,name中和console.php配置相同名字 ,只是大小写不一样, 读取不到, 就报错了, 这个错误可否优化一下,不然要看下源码
最佳答案
评论( 相关
后面还有条评论,点击查看>>