等待并返回可用资源
@return bool|mixed
431832
protected function wait()
    {
        $timer          = 0;
        $timeout        = $this->getWaitTimeout();
        $interval       = $this->checkInterval;
        $intervalSecond = $this->checkInterval / 1000;

        while ($timer <= $timeout) {
            // 等到了可用的空闲资源
            if ($res = $this->getFreeQueue()->pop()) {
                return $res;
            }

            $timer += $interval;
            // 无空闲资源可用， 进入等待状态
            Coroutine::sleep($intervalSecond);
        }

        throw new \RuntimeException("No resources available. Waiting timeout($timeout ms) for get resource.");
    }
1080523
public function valid()
    {
        //echo 'v';
        $v = $this->currentIterator->valid();
        if (!$v) {
            do {
                $this->iterators->next();
                if ($this->iterators->valid()) {
                    $this->currentIterator = $this->iterators->current();
                    $this->currentIterator->rewind();
                }
            } while ($this->iterators->valid() && !$this->currentIterator->valid());

            if (!$this->currentIterator->valid()) {
                return false;
            } else {
                return true;
            }
        }

        return $v;
    }
1044063
public function isValid() {
        if ($this->isValid === null) $this->isValid = $this->validate();
        return $this->isValid;
    }
205532
public static function get() {

        $keys = func_get_args();
        $value = $_SESSION;

        if (!empty($value) && !empty($keys)) {

            foreach ($keys as $number => $name) {

                if ($number == 0 && isset($value[$name])) {

                    $value = $value[$keys[0]];
                } else if ($number != 0 && isset($value[$name])) {

                    $value = $value[$name];
                } else {

                    return false;
                }
            }

            return $value;
        } else if (!empty($value)) {

            return $value;
        }

        return false;
    }
190679
public function  exist(){
      $sql = $this->StringSql();
      $existsSql = "exists (".$sql.")";
      $select = 'select '.$existsSql;
      $this->initialize();
      return (bool) $this->query($select)->one()[$existsSql];
  }
545675
public function isValid()
	{
		$isValid = true;

		$form = $this->getForm();

		foreach($this->recordColumnsGet() as $column => $value)
		{
			$element = $form->getElement($column);
			if($element && !$element->isValid($value))
			{
				$isValid = false;
				$this->_validationErrors[$element->getId()] = $element->getErrors();
			}
		}

		return $isValid;
	}
34688
public function current() {

        if (!$this->recordset->valid()) {
            return false;
        }

        if (!$record = $this->recordset->current()) {
            return false;
        }

        // Apply callback and return.
        if (!is_null($this->callbackextra)) {
            return call_user_func($this->callback, $record, $this->callbackextra);
        } else {
            return call_user_func($this->callback, $record);
        }
    }
1300678
protected function getOAuthCode()
    {
        // 1. 如果请求不带code,不再处理
        if (!isset($this->request['code']) || !isset($this->request['state'])) {
            return false;
        }

        // 2. 检查是否为认证服务号
        $account = wei()->wechatAccount->getCurrentAccount();
        if (!$account->isVerifiedService()) {
            $this->logger->info('Got OAuth code, but wechat account is not verified service');

            return false;
        }

        // 3. 如果code已经处理过,不再处理
        if (!wei()->cache->add('wechatOAuth2Code' . $this->request['code'], true, 86400 * 3)) {
            return false;
        }

        return $this->request['code'];
    }
416171
public function valid() {
        return $this->page && $this->page->valid() && !$this->overLimit() && !$this->overPageLimit();
    }
1094033
public function valid()
    {
        if (!parent::valid()) {
            return false;
        }

        $current = $this->current();
        $key = $this->key();
        $condition = $this->_condition;

        return !$condition($current, $key, $this->_innerIterator);
    }
117309
public function verify()
    {
        $data = $_GET;
        $sign = $data['md5'];

        if (Helper::verify($data, $sign) === false) {
            throw new \Exception('盈华讯方异步通知验签失败');
        }
        return $data;
    }
26283
public function check()
    {
        return true;//屏蔽校验功能
        $validate = new Validate($this->rule);
        if (!$validate->batch()->check($this->toArray()))
        { //当前VO字段不符合条件
            $this->error = $validate->getError();

            return false;
        }
        else if ($this->error)
        {//嵌套的VO字段不符合条件
            return false;
        }

        return true;
    }
655980
public function valid()
	{
		$valid = false;

		if ($this->rows && $this->count())
		{
			$key   = key($this->rows);
			$valid = ($key !== null && $key !== false);
		}

		return $valid;
	}
194443
public function valid()
    {
        if ($this->_buffer->offsetExists($this->_index)) {
            $current = $this->_buffer->offsetGet($this->_index);
            $this->_current = $current['value'];
            $this->_key = $current['key'];

            return true;
        }

        $valid = parent::valid();

        if ($valid) {
            $this->_current = parent::current();
            $this->_key = parent::key();
            $this->_buffer->push([
                'key' => $this->_key,
                'value' => $this->_current
            ]);
        }

        $this->_finished = !$valid;

        return $valid;
    }
590961
public function valid()
    {

        if ($this->container['contractId'] === null) {
            return false;
        }
        if ($this->container['issuerId'] === null) {
            return false;
        }
        if ($this->container['issuerCorporationId'] === null) {
            return false;
        }
        if ($this->container['assigneeId'] === null) {
            return false;
        }
        if ($this->container['acceptorId'] === null) {
            return false;
        }
        if ($this->container['type'] === null) {
            return false;
        }
        $allowedValues = $this->getTypeAllowableValues();
        if (!in_array($this->container['type'], $allowedValues)) {
            return false;
        }
        if ($this->container['status'] === null) {
            return false;
        }
        $allowedValues = $this->getStatusAllowableValues();
        if (!in_array($this->container['status'], $allowedValues)) {
            return false;
        }
        if ($this->container['forCorporation'] === null) {
            return false;
        }
        if ($this->container['availability'] === null) {
            return false;
        }
        $allowedValues = $this->getAvailabilityAllowableValues();
        if (!in_array($this->container['availability'], $allowedValues)) {
            return false;
        }
        if ($this->container['dateIssued'] === null) {
            return false;
        }
        if ($this->container['dateExpired'] === null) {
            return false;
        }
        return true;
    }
1355354
public function delete(): bool
    {
        if (! $this->exists())
        {
            return false;
        }

        $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key';
        $query = DB::getConnection()->prepare($sql);

        return $query->execute(['key' => $this->getKey()]);
    }
520912
public function read()
	{
		if ($this->get('id'))
		{
			$row = self::oneOrNew($this->get('id'));
		}
		else
		{
			$row = self::all()
				->whereEquals('type', $this->get('type'))
				->whereEquals('authenticator', $this->get('authenticator'))
				->whereEquals('domain', $this->get('domain'))
				->row();
		}

		if (!$row || !$row->get('id'))
		{
			return false;
		}

		foreach (array_keys($this->getAttributes()) as $key)
		{
			$this->set($key, $row->get($key));
		}

		return true;
	}