PHP Class think\console\Input

Exibir arquivo Open project: top-think/framework Class Usage Examples

Protected Properties

Property Type Description
$arguments think\console\input\Argument[]
$definition think\console\input\Definition
$interactive
$options think\console\input\Option[]

Public Methods

Method Description
__construct ( $argv = null )
__toString ( ) : string 返回传递给命令的参数的字符串
bind ( Definition $definition ) 绑定实例
escapeToken ( string $token ) : string 转义指令
getArgument ( string $name ) : mixed 根据名称获取参数
getArguments ( ) : Argument[] 获取所有的参数
getFirstArgument ( ) : string | null 获取第一个参数
getOption ( string $name ) : mixed 获取选项值
getOptions ( ) : Option[] 获取所有的选项
getParameterOption ( string | array $values, mixed $default = false ) : mixed 获取原始选项的值
hasArgument ( string | integer $name ) : boolean 检查是否存在某个参数
hasOption ( string $name ) : boolean 是否有某个选项
hasParameterOption ( string | array $values ) : boolean 检查原始参数是否包含某个值
isInteractive ( ) : boolean 检查输入是否是交互的
setArgument ( string $name, string $value ) 设置参数的值
setInteractive ( $interactive ) 设置输入的交互
setOption ( string $name, string | boolean $value ) 设置选项值
validate ( ) 验证输入

Protected Methods

Method Description
parse ( ) 解析参数
setTokens ( array $tokens )

Private Methods

Method Description
addLongOption ( string $name, mixed $value ) 添加一个完整选项的值
addShortOption ( string $shortcut, mixed $value ) 添加一个短选项的值
parseArgument ( string $token ) 解析参数
parseLongOption ( string $token ) 解析完整选项
parseShortOption ( string $token ) 解析短选项
parseShortOptionSet ( string $name ) 解析短选项

Method Details

__construct() public method

public __construct ( $argv = null )

__toString() public method

返回传递给命令的参数的字符串
public __toString ( ) : string
return string

bind() public method

绑定实例
public bind ( Definition $definition )
$definition think\console\input\Definition A InputDefinition instance

escapeToken() public method

转义指令
public escapeToken ( string $token ) : string
$token string
return string

getArgument() public method

根据名称获取参数
public getArgument ( string $name ) : mixed
$name string 参数名
return mixed

getArguments() public method

获取所有的参数
public getArguments ( ) : Argument[]
return think\console\input\Argument[]

getFirstArgument() public method

获取第一个参数
public getFirstArgument ( ) : string | null
return string | null

getOption() public method

获取选项值
public getOption ( string $name ) : mixed
$name string 选项名称
return mixed

getOptions() public method

获取所有的选项
public getOptions ( ) : Option[]
return think\console\input\Option[]

getParameterOption() public method

获取原始选项的值
public getParameterOption ( string | array $values, mixed $default = false ) : mixed
$values string | array 需要检查的值
$default mixed 默认值
return mixed The option value

hasArgument() public method

检查是否存在某个参数
public hasArgument ( string | integer $name ) : boolean
$name string | integer 参数名或位置
return boolean

hasOption() public method

是否有某个选项
public hasOption ( string $name ) : boolean
$name string 选项名
return boolean

hasParameterOption() public method

检查原始参数是否包含某个值
public hasParameterOption ( string | array $values ) : boolean
$values string | array 需要检查的值
return boolean

isInteractive() public method

检查输入是否是交互的
public isInteractive ( ) : boolean
return boolean

parse() protected method

解析参数
protected parse ( )

setArgument() public method

设置参数的值
public setArgument ( string $name, string $value )
$name string 参数名
$value string

setInteractive() public method

设置输入的交互
public setInteractive ( $interactive )

setOption() public method

设置选项值
public setOption ( string $name, string | boolean $value )
$name string 选项名
$value string | boolean

setTokens() protected method

protected setTokens ( array $tokens )
$tokens array

validate() public method

验证输入
public validate ( )

Property Details

$arguments protected_oe property

protected Argument[],think\console\input $arguments
return think\console\input\Argument[]

$definition protected_oe property

protected Definition,think\console\input $definition
return think\console\input\Definition

$interactive protected_oe property

protected $interactive

$options protected_oe property

protected Option[],think\console\input $options
return think\console\input\Option[]