The expression $this->allArgvs of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an
empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using empty(..) or !empty(...) instead.
Loading history...
66
$this->setAllArgvs();
67
}
68
69
return $this->allArgvs[$name] ?? $default;
70
}
71
72
/**
73
* 设置命令行所有参数
74
*
75
* @return array
76
*/
77
public function setAllArgvs()
78
{
79
global $argv;
80
81
foreach ($argv as $a) { // Windows默认命令行无法正确传入使用引号括住的带空格参数,换个命令行终端就好,Linux不受影响
82
if (preg_match('/^-{1,2}(?P<name>\w+)(?:=([\'"]|)(?P<val>[^\n\t\v\f\r\'"]+)\2)?$/i', $a, $m)) {
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.