连接

@return boolean
777026
public function connect(): bool
    {
        if($this->connected)
        {
            return true;
        }
        $this->socket = stream_socket_client('unix://' . $this->socketFile, $errno, $errstr);
        if(false === $this->socket)
        {
            $this->connected = false;
            return false;
        }
        $this->connected = true;
        return true;
    }
939886
public function clear(): bool
    {
        if (!empty($this->tag)) {
            // 指定标签清除
            foreach ($this->tag as $tag) {
                $this->clearTag($tag);
            }

            return true;
        }

        $this->writeTimes++;

        $files = (array) glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DIRECTORY_SEPARATOR : '') . '*');

        foreach ($files as $path) {
            if (is_dir($path)) {
                $matches = glob($path . DIRECTORY_SEPARATOR . '*.php');
                if (is_array($matches)) {
                    array_map('unlink', $matches);
                }
                rmdir($path);
            } else {
                unlink($path);
            }
        }

        return true;
    }
253621
public function valid()
    {
        if (!$this->splFileObject->valid()) {
            return false;
        }

        if ($this->splFileObject->key() === 0) {
            $this->splFileObject->next();
        }

        $current = $this->splFileObject->current();

        return $current <> [null];
    }
442869
public function verify()
    {
        $data = file_get_contents("php://input");
        $data = Xml::xmlToArr($data);
        if ($data['sign'] != Helper::signature($data, Datasheet::get('md5_key'))) {
            throw new \Exception('微信异步通信签名验证失败');
        }
        return $data;
    }
32211
public function validate() {
        $validator = \validator(
                $this->attributes, $this->overrideNormalRules(static::$rules), static::$messages
        );

        $validator->addExtensions($this->overrideCustomRules(static::$customRules));

        foreach ($this->overrideComplexRules(static::$complexRules) as $field => $validation) {
            $rules = $validation["rules"];
            $check = $validation["check"];
            $validator->sometimes($field, $rules, $check);
        }

        if ($validator->passes()) {
            return true;
        }
        $this->setErrors($validator->messages());
        return false;
    }
982319
public function validate()
    {
        if (is_numeric($this->categoryId) && $this->categoryId >= 1
                && is_numeric($this->forumId) && $this->forumId >= 1
                && is_numeric($this->threadId) && $this->threadId >= 1
                && !empty($this->threadSlug)) {
            return true;
        }
        return false;
    }
54255
public function exists()
    {
        if (! array_key_exists($this->primaryKey, $this->attributes)) {
            return false;
        }

        return ! empty($this->attributes[$this->primaryKey]);
    }
751627
public function verifyReturn(){
        if(empty($_GET)) {//判断POST来的数组是否为空
            return false;
        }
        else {
            //生成签名结果
            $isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
            //获取支付宝远程服务器ATN结果（验证是否是支付宝发来的消息）
            $responseTxt = 'true';
            if (! empty($_GET["notify_id"])) {$responseTxt = $this->getResponse($_GET["notify_id"]);}

            //写日志记录
            //if ($isSign) {
            //	$isSignStr = 'true';
            //}
            //else {
            //	$isSignStr = 'false';
            //}
            //$log_text = "responseTxt=".$responseTxt."\n return_url_log:isSign=".$isSignStr.",";
            //$log_text = $log_text.createLinkString($_GET);
            //logResult($log_text);

            //验证
            //$responsetTxt的结果不是true，与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
            //isSign的结果不是true，与安全校验码、请求时的参数格式（如：带自定义参数等）、编码格式有关
            if (preg_match("/true$/i",$responseTxt) && $isSign) {
                return true;
            } else {
                return false;
            }
        }
    }
371272
protected function start()
    {
        //获取上下文内的sessionId
        $this->sessionId = $this->getContext()->getUserDefined('sessionId');
        if ($this->sessionId !== null) {
            return true;
        }

        //获取cookie里的sessionId
        $this->sessionId = $this->getContext()->getInput()->getCookie($this->sessionName);
        if (!$this->sessionId) {
            //新建sessionId
            $this->getContext()->getOutput()->setCookie($this->sessionName, $this->getContext()->getLogId());
            $this->sessionId = $this->getContext()->getLogId();
        } else {
            $this->sessionHandler->gc($this->maxLifeTime, $this->sessionId);
        }

        //设定session的访问和修改时间
        yield $this->sessionHandler->touch($this->sessionId);

        //设置上下文内的sessionId
        $this->getContext()->setUserDefined('sessionId', $this->sessionId);

        return true;
    }
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;
    }
368194
public function isChanged(): bool
    {
        $changed = false;
        $this->files = array_map(function($item){
            $item['exists'] = false;
            return $item;
        }, $this->files);
        $this->changedFiles = [];
        // 包含的路径中检测
        foreach($this->includePaths as $path)
        {
            $directory = new \RecursiveDirectoryIterator($path, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
            $iterator = new \RecursiveIteratorIterator($directory);
            if('' === $this->excludeRule)
            {
                // 无排除规则处理
                foreach($iterator as $fileName => $fileInfo)
                {
                    if($this->parseCheckFile($fileName))
                    {
                        $this->changedFiles[] = $fileName;
                        $changed = true;
                    }
                }
            }
            else
            {
                // 有排除规则处理
                $rule = "/^(?!{$this->excludeRule}).+$/i";
                $regex = new \RegexIterator($iterator, $rule, \RecursiveRegexIterator::GET_MATCH);
                foreach ($regex as $item)
                {
                    if($this->parseCheckFile($item[0]))
                    {
                        $this->changedFiles[] = $item[0];
                        $changed = true;
                    }
                }
            }
        }
        // 之前有的文件被删处理
        foreach($this->files as $fileName => $option)
        {
            if(!$option['exists'])
            {
                unset($this->files[$fileName]);
                $this->changedFiles[] = $fileName;
                $changed = true;
            }
        }
        return $changed;
    }
576447
public function valid(): bool
    {
        if ($this->getCurrentElement() !== null && $this->getCurrentElement()->getValue() !== self::DONE && $this->getCurrentElement()->getOffset() !== -1) {
            return true;
        }
        return false;
    }
1085664
public function valid()
    {
        if (key($this->_data) === null) {
            return false;
        }

        $current = current($this->_data);
        while (!$current->value()) {
            $current = $this->next();
            if (key($this->_data) === null) {
                return false;
            }
        }
        return true;
    }
344008
public function validate()
    {
        $confirmationInput = $this->inputName.'_confirmation';

        if (isset($this->input[$confirmationInput]) &&
            $this->input[$confirmationInput] == $this->getValue()) {
            return true;
        }

        return false;
    }
1189773
public function isLogin()
	{
		$ticket = $this->getTicket();
		logger('用户凭证：'.var_export($ticket,true)); // debug
		if(isset($ticket['id'])){
			logger('存在用户凭证....');
			if(($ticket['expire_time']+$ticket['create_at']) > time()){
				logger('用户凭证在有效期内....');
				$leftTimes = (time()-$ticket['check_at'])/$this->_reCheckTime;
				if($leftTimes < 1){
					logger('检查时间间隔：'.$this->_reCheckTime);
					logger('不需要向服务器核验用户凭证...'."\n");
					return true;
				}else{
					logger('需要向服务器核验用户凭证...'."\n");
					$this->toServerIsLogin();
					return;
				}
			}
			logger('用户凭证bu在有效期内....'."\n");
			$this->toServerIsLogin();
			return;
		}
		logger('bu存在用户凭证....'."\n");
		$this->toServerIsLogin();
		return;
	}
1311509
public function isPing()
    {
        $nowTime = time();
        // 心跳间隔时间
        $pingInteralTime = RabbitMqConfig::getCommon('rabbit_mq_ping_interval_time');
        if ($this->lastPingTime + $pingInteralTime < $nowTime) {
            $this->lastPingTime = $nowTime;
            return true;
        }
        return false;
    }
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()]);
    }