获取实例

@param array $option
@return self
501297
public static function instance($option = [])
    {
        $key = md5(get_called_class() . serialize($option));
        if (! isset(static::$instances[$key])) {
            $instance = new static($option);
            $instance->instance_key = $key;
            static::$instances[$key] = $instance;
        }
        return static::instanceGet($key);
    }
749334
public function setOptions($options)
	{
		$options = is_array($options) ? $options : array($options);

		foreach ($options as $option)
		{
			$this->addOption($option);
		}

		return $this;
	}
1080237
protected function autoValidate($option)
    {
        list($validate, $scene, $message, $batch) = $option;

        if (is_array($validate)) {
            // 指定验证规则
            $v = $this->app->validate();
            $v->rule($validate);
        } else {
            // 调用验证器
            $v = $this->app->validate($validate);
            if (!empty($scene)) {
                $v->scene($scene);
            }
        }

        if (!empty($message)) {
            $v->message($message);
        }

        // 批量验证
        if ($batch) {
            $v->batch(true);
        }

        if (!$v->check($this->request->param())) {
            throw new ValidateException($v->getError());
        }
    }
1235274
public function reconfigure(array $options = []): self
    {
        /** @var string $opt */
        /** @var string $val */
        foreach ($options as $opt => $val) {
            switch ($opt) {
                case 'formIndex':
                case 'formToken':
                case 'sessionIndex':
                case 'useNativeSession':
                case 'recycle_after':
                case 'hmac_ip':
                case 'expire_old':
                    /** @psalm-suppress MixedAssignment */
                    $this->$opt = $val;
                    break;
                case 'hashAlgo':
                    if (\in_array($val, \hash_algos(), true)) {
                        $this->hashAlgo = (string) $val;
                    }
                    break;
                case 'lock_type':
                    if (\in_array($val, array('REQUEST_URI','PATH_INFO'), true)) {
                        $this->lock_type = (string) $val;
                    }
                    break;
            }
        }
        return $this;
    }
1168603
public function addOptions(array $options)
    {
        $existingOptions = $this->getOptions();
        $newOptions = empty($existingOptions) ? $options : array_merge((array)$existingOptions, $options);
        $this->setOptions($newOptions);
        return $this;
    }
363551
public function add($option)
    {
        if (is_array($option)) {
            $this->collection[] = new Option($option);
        } elseif (is_object($option) && $option instanceof Option) {
            $this->collection[] = $option;
        }

        return $this;
    }
287317
public function option($opt)
	{
		$args = \func_get_args();
		if ( \is_array($opt) && isset($opt[0], $this->_defaults[$opt[0]]) ){
			$this->_current_cfg[$opt[0]] = $opt[1];
		}
		else if ( isset($args[0], $args[1], $this->_defaults[$args[0]]) ){
			$this->_current_cfg[$args[0]] = $args[1];
		}
		else{
			throw new InvalidArgumentException('This configuration argument is imaginary... Sorry! :)');
		}
    return $this;
	}
258666
public function setOption($options = [])
    {
        $this->options = $options;
        $this->provider = Omnipay::create('PayPal_Express');
        $this->provider->setUsername($this->options['username']);
        $this->provider->setPassword($this->options['password']);
        $this->provider->setSignature($this->options['sign']);

        // 测试配置必须开启测试模式
        if ($this->options['sandbox']) {
            $this->provider->setTestMode(true);
        }

        // 查看配置选项 @see http://omnipay.thephpleague.com/gateways/configuring/
        // $this->provider->getDefaultParameters();
    }
1075726
public static function merge(...$options) {
            $o = [];

            foreach ($options as $opt) {
                if ($opt instanceof Options) {
                    $o = array_merge($o, $opt->toArray());
                } elseif (is_array($opt)) {
                    $o = array_merge($o, $opt);
                }
            }

            return new self(Util::trimNulls($o));
        }
530146
public function set_option($options = array()) {
        $options['issuerid'] = clean_param($options['issuerid'], PARAM_INT);
        $options['controlledlinkfoldername'] = clean_param($options['controlledlinkfoldername'], PARAM_TEXT);

        $ret = parent::set_option($options);
        return $ret;
    }
446404
public function withOptions($options)
    {
        if (is_array($options)) {
            $options = new RequestOptions($options);
        }

        $this->options = $options;

        return $this;
    }
463874
public function options($options = [])
    {
        // remote options
        if (is_string($options)) {
            return $this->loadRemoteOptions(...func_get_args());
        }

        if ($options instanceof Arrayable) {
            $options = $options->toArray();
        }

        if (is_callable($options)) {
            $this->options = $options;
        } else {
            $this->options = (array) $options;
        }

        return $this;
    }
85551
public function on(callable $fn, string $option = null): self
    {
        $names = \array_keys($this->allOptions());

        $this->_events[$option ?? \end($names)] = $fn;

        return $this;
    }
194851
public function options(array $options, string $selected=null) : self {
        foreach ($options as $key => $value) {
            if (is_int($key))
                $key = $value;
            if ($selected == $key)
                $this->elem("option @value=? @selected=selected", [$key])->text($value)->end();
            else
                $this->elem("option @value=?", [$key])->text($value)->end();
        }
        return $this;
    }
205457
public function setOptions(array $options)
    {
        $this->options = [];

        foreach ($options as $k => $v) {
            $this->addOption($k, (array)$v);
        }

        return $this;
    }
1337769
public function setOptions($option, $value = null) 
	{
		Argument::i()
			->test(1, 'array', 'string')
			->test(2, 'scalar', 'null');
		
		if(is_array($option)) {
			$this->options = $option;
			return $this;
		}
		
		$this->options[$option] = $value;
		return $this;
	}
302209
public function select($select = '*')
    {
        //if select is an array
        if (is_array($select)) {
            //transform into a string
            $select = implode(', ', $select);
        }
        
        $this->select = $select;
        
        return $this;
    }