think\console\Command::setCode PHP Method

setCode() public method

设置执行代码
See also: execute()
public setCode ( callable $code ) : Command
$code callable callable(InputInterface $input, OutputInterface $output)
return Command
    public function setCode(callable $code)
    {
        if (!is_callable($code)) {
            throw new \InvalidArgumentException('Invalid callable provided to Command::setCode.');
        }
        if (PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
            $r = new \ReflectionFunction($code);
            if (null === $r->getClosureThis()) {
                $code = \Closure::bind($code, $this);
            }
        }
        $this->code = $code;
        return $this;
    }