Emit the before event.

@param string $method
@param array  $arguments

@return array [continue, call result]
327342
protected function emitBefore($method, array $arguments)
    {
        $event = new BeforeEvent($this, $method, $arguments);
        $this->emit($event, $method);

        if ($event->isPropagationStopped()) {
            return [false, $event->getResult()];
        }

        return [true, $event->getArguments()];
    }
1215426
public function command($method, array $parameters = [])
    {
        $start = microtime(true);

        $result = $this->client->{$method}(...$parameters);

        $time = round((microtime(true) - $start) * 1000, 2);

        if (isset($this->events)) {
            $this->event(new CommandExecuted($method, $parameters, $time, $this));
        }

        return $result;
    }
371956
public function invokeArgs($method, array $params)
	{
		if (
			$this->logger !== null &&
			$this->logger->isHandling(\Monolog\Logger::DEBUG)
		) {
			$methodSynopsis = $method . '(';
			foreach (array_values($params) as $index => $param) {
				if ($index > 0) {
					$methodSynopsis .= ', ';
				}
				$methodSynopsis .= var_export($param, true);
			}
			$methodSynopsis .= ')';

			$this->logger->addDebug(
				'Invoke remote object method ' . $methodSynopsis,
				array(
					 'transport' => $this->transport,
					 'method'    => $method,
					 'params'    => $params
				)
			);
		}

		$request = $this->encoder->encodeMethod($method, $params);

		$response = $this->transport->request($request);

		$result = $this->encoder->decodeResult($response);

		if (
			$this->logger !== null &&
			$this->logger->isHandling(\Monolog\Logger::DEBUG)
		) {
			$this->logger->addDebug(
				'Receive methods ' . $methodSynopsis . ' result.',
				array(
					 'transport' => $this->transport,
					 'method'    => $method,
					 'params'    => $params
				)
			);
		}

		return $result;
	}
1079000
protected function emitOnChange($method = false)
    {
        if (!$this->onChangeAlreadyEmittedBy) {
            $this->emit('change', [$this]);
            $this->onChangeAlreadyEmittedBy = $method;
        }
    }
1039764
public function emit($event, array $arguments = [])
    {
        parent::emit($event, $arguments);
        if ($this->broker) {
            $this->broker->emit($event, $arguments);
        }
    }
121989
protected function callApiMethod($name, $arguments)
    {
        $beforeMethod = 'before' . ucfirst($name);
        $afterMethod = 'after' . ucfirst($name);
        $options = isset($arguments[0]) ? $arguments[0] : [];

        if(method_exists($this, $beforeMethod)) {
            call_user_func_array([$this, $beforeMethod], $arguments);
        }
        $result = $this->post($this->apiMethods[$name], $this->createOptionResolver($name)->resolve($options));
        if(method_exists($this, $afterMethod)) {
            $result = call_user_func_array([$this, $afterMethod], array_merge([$result], $arguments));
        }

        return $result;
    }
1016309
protected function checkRetry($method, $arguments = array())
    {
        Tools::log("Run {$method} Faild. {$this->errMsg}[{$this->errCode}]", "ERR - {$this->appid}");
        if (!$this->_retry && in_array($this->errCode, array('40014', '40001', '41001', '42001'))) {
            ($this->_retry = true) && $this->resetAuth();
            $this->errCode = 40001;
            $this->errMsg = 'no access';
            Tools::log("Retry Run {$method} ...", "MSG - {$this->appid}");
            return call_user_func_array(array($this, $method), $arguments);
        }
        return false;
    }
1347757
private function callOrigin($method, $args, $callback)
    {
        $this->parseBefore($method, $args);
        // 原始方法调用
        $result = call_user_func_array($callback, $args);
        $this->parseAfter($method, $args);
        $this->parseAfterReturning($method, $args, $result);
        return $result;
    }
124615
protected function call($method, &$arguments)
    {
        $matches = array();

        if (!preg_match('/^(?:(get|set|is)_?)(\w+)$/i', $method, $matches)) {
            return null;
        }

        $action = $matches[1];
        $name   = $matches[2];

        if ($action === 'is') {
            $name   = "is$name";
            $action = 'get';
        }

        $propertyName = lcfirst($name);

        if ($action === 'set') {
            return $this->set($propertyName, $arguments[0]);
        }
        else {
            return $this->get($propertyName);
        }
    }
793084
private function doBeforeQuery($callback, $methodName, $arguments)
    {
        $traits = $this->getUsedTraits();

        if (in_array(CacheResults::class, $traits) && $this->caching && $this->isCacheableMethod($methodName)) {
            return $this->processCacheRequest($callback, $methodName, $arguments);
        }

        return $callback();
    }
1086946
public function notify(string $method, $args): \Generator
    {
        $notification = new Notification();
        $notification->method = $method;
        $notification->params = $args;

        $serializedNotification = Json::encode($this->mapper->dump($notification));
        yield Recoil::execute($this->transport->send($serializedNotification));
    }
672019
public function callRemoteArray($method, $args)
    {
        if (isset($this->remoteMethods[$method])) {
            $this->remoteMethods[$method](...$args);
            return $this;
        }
        $pct = [
            'method' => $method,
        ];
        if (sizeof($args)) {
            $callbacks = [];
            $path = [];
            $this->extractCallbacks($args, $callbacks, $path);
            $pct['arguments'] = $args;
            if (sizeof($callbacks)) {
                $pct['callbacks'] = $callbacks;
            }
        }
        $this->sendPacket($pct);
        return $this;
    }
828022
public function fireReturn(string $event, array $arguments = null) {
        $return = [];
        $arguments = (array)$arguments;

        foreach ($this->getBindings($event) as $callback) {
            if (is_callable($callback)) {
                $return[] = call_user_func_array($callback, $arguments);
            }
        }
        return array_filter($return);
    }
330662
private function callFindAllBy(string $method, array $arguments)
    {
        $whereByWithUpper = lcfirst(substr($method, 9, mb_strlen($method)));
        $whereBy = Str::convertCamelCaseToSnakeCase($whereByWithUpper);

        return $this->where($whereBy, '=', $arguments[0])->findAll();
    }
1275011
public function emit(string $name, array $arguments = [])
    {
        try {
            $this->trigger($name, $arguments);
        } catch (StopPropagation $e) {
            return $this;
        }

        return $this;
    }
597078
public static function before($method, $self, &$args)
    {
        if (!Suite::registered()) {
            return false;
        }

        list($class, $name) = explode('::', $method);

        $lsb = is_object($self) ? get_class($self) : $self;

        if (!Suite::registered($lsb) && !Suite::registered($class)) {
            return false;
        }

        if ($name === '__call' || $name === '__callStatic') {
            $name = array_shift($args);
            $args = array_shift($args);
        }

        return static::_stubbedMethod($lsb, $self, $class, $name, $args);
    }
479878
public function handle(string $method, array $arguments)
    {
        /**
         * @var Context $arguments[0]
         */
        try {
            if ($this->isRandom) {
                return $this->random($method, $arguments);
            }

            if ($method === 'evalMock') {
                return $this->evalMock($arguments);
            } else {
                $key = $arguments[1];
                //单key操作
                if (!is_array($key)) {
                    return $this->single($method, $key, $arguments);
                    // 批量操作
                } else {
                    return $this->multi($method, $key, $arguments);
                }
            }
        } catch (\Exception $e) {
            return false;
        }
    }