Renew the CSRF token on a given Phery instance
Resets any selectors that were being chained before

@param Phery $instance Instance of Phery
@return PheryResponse
355635
public function renew_csrf(Phery $instance)
    {
        if ($instance->config('csrf') === true) {
            $this->cmd(13, array($instance->csrf()));
        }

        return $this;
    }
544757
public function created($instance)
    {
        $after = $this->recordableAttributes(get_class($instance), $instance->getAttributes());

        $instance->recordActivity('created', null, $after);
    }
553265
public static function &getInstance( $instance = null )
	{
		if ( parent::hasInstance() )
		{
			return parent::getInstance();
		}

		$instance = parent::getInstance( new self() );
		$instance->fromFile();
		return $instance;
	}
1233034
public function usingCallback(string $name, $instance): self
    {
        $this->xslCallbacks->addCallback($name, $instance);
        return $this;
    }
172770
protected function issueRefreshToken(AccessTokenEntityInterface $accessToken, ClientEntityInterface $client = null)
    {
        $maxGenerationAttempts = self::MAX_RANDOM_TOKEN_GENERATION_ATTEMPTS;

        $refreshToken = $this->refreshTokenRepository->getNewRefreshToken();
        $refreshToken->setAccessToken($accessToken);
        $refreshToken->setUUID($accessToken->getUUID());

        $refresh_expire = $client->getRefreshExpire();

        if(!empty($refresh_expire)){
            $refreshToken->setExpiryDateTime(now()->addMinutes($refresh_expire));
        }else{
            $refreshToken->setExpiryDateTime((new DateTime())->add($this->refreshTokenTTL));
        }


        while ($maxGenerationAttempts-- > 0) {
            $refreshToken->setIdentifier($this->generateUniqueIdentifier());
            try {
                $this->refreshTokenRepository->persistNewRefreshToken($refreshToken);

                return $refreshToken;
            } catch (UniqueTokenIdentifierConstraintViolationException $e) {
                if ($maxGenerationAttempts === 0) {
                    throw $e;
                }
            }
        }
    }
795385
public function setInstance(\Illuminate\Database\Eloquent\Model $instance): ColumnInterface
    {
        $this->instance = $instance;

        return $this;
    }
987401
protected function resetCsrfToken($token=null)
    {
        $token || $token = $this->request->getParam($this->options['csrfTokenName']);
        FormToken::instance()->reset($token);
    }
1359394
public static function setInstance(\SwaggerValidator\Common\CollectionReference $instance)
    {
        self::$instance  = $instance;
        self::$refIdList = array();
    }
956936
public static function &getUser($instance)
	{
		static $instances;
		if (!isset($instances)) {
			$instances = array();
		}
		//only create a new user instance if it has not been created before
		if (!isset($instances[$instance])) {
			$name = static::getNameFromInstance($instance);

			static::pluginAutoLoad($name);

			$class = '\JFusion\Plugins\\' . $name . '\User';
			if (!class_exists($class)) {
				$class = '\JFusion\Plugin\User';
			}
			$instances[$instance] = new $class($instance);
		}
		return $instances[$instance];
	}
1166899
public function renew( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Iface $order )
	{
	}
270261
public function createTokenResponse(
        ServerRequestInterface $request,
        Client $client = null,
        TokenOwnerInterface $owner = null
    ): ResponseInterface {
        $postParams = $request->getParsedBody();

        $code = $postParams['code'] ?? null;

        if (null === $code) {
            throw OAuth2Exception::invalidRequest('Could not find the authorization code in the request');
        }

        /* @var \ZfrOAuth2\Server\Model\AuthorizationCode $authorizationCode */
        $authorizationCode = $this->authorizationCodeService->getToken($code);

        if (null === $authorizationCode || $authorizationCode->isExpired()) {
            throw OAuth2Exception::invalidGrant('Authorization code cannot be found or is expired');
        }

        $clientId = $postParams['client_id'] ?? null;

        if ($authorizationCode->getClient()->getId() !== $clientId) {
            throw OAuth2Exception::invalidRequest(
                'Authorization code\'s client does not match with the one that created the authorization code'
            );
        }

        // If owner is null, we reuse the same as the authorization code
        $owner = $owner ?: $authorizationCode->getOwner();

        // Everything is okey, let's start the token generation!
        $scopes = $authorizationCode->getScopes(); // reuse the scopes from the authorization code

        $accessToken = $this->accessTokenService->createToken($owner, $client, $scopes);

        // Before generating a refresh token, we must make sure the authorization server supports this grant
        $refreshToken = null;

        if ($this->authorizationServer->hasGrant(RefreshTokenGrant::GRANT_TYPE)) {
            $refreshToken = $this->refreshTokenService->createToken($owner, $client, $scopes);
        }

        return $this->prepareTokenResponse($accessToken, $refreshToken);
    }
414924
static public function register_render($instance)
  {
    if ($instance == null) {
      throw new \Exception('Instance is null.');
    }
    self::$app->renders->register($instance);
  }
1099234
public static function bindInstance($instance, $methodName, $args = null)
    {
        $helper = new self();
        return $helper->createClosure($methodName, $args)->bindTo($instance, get_class($instance));
    }
1332517
protected function initInstance(Armada $instance)
    {
        // Return if the class instance has already been initialized.
        if(!($instance) || ($instance->response))
        {
            return;
        }
        // Init the class instance
        $instance->response = $this->xResponse;
        $instance->rqFactory = new Factory\Request($instance);
        $instance->pgFactory = new Factory\Paginator($instance);

        if(($this->xInitCallback))
        {
            call_user_func_array($this->xInitCallback, array($instance));
        }
        // Apply class initializer
        foreach($this->aClassInitCallbacks as $namespace => $callback)
        {
            $classname = get_class($instance);
            if(strpos($classname, $namespace) !== false)
            {
                // Call the callback passing the class instance as parameter
                $callback($instance);
            }
        }
        // Call the init() function of the instance class
        $instance->init();
    }
1290612
public function update_instance($instance, $data) {
        global $DB;

        parent::update_instance($instance, $data);

        // Remove the fields we don't want to override.
        unset($data->id);
        unset($data->timecreated);
        unset($data->timemodified);

        // Convert to an array we can loop over.
        $fields = (array) $data;

        // Update the data in our table.
        $tool = new stdClass();
        $tool->id = $data->toolid;
        $tool->timemodified = time();
        foreach ($fields as $field => $value) {
            $tool->$field = $value;
        }

        return $DB->update_record('enrol_lti_tools', $tool);
    }
1221563
public function add($instance)
    {
        $class = get_class($instance);
        $entityPool = $this->pool[$class] ?? [];
        $entityPool[$instance->id] = $instance;
        $this->pool[$class] = $entityPool;

        return $instance;
    }
918980
public function toInstance($instance) : self
    {
        $this->untarget = null;
        $this->bound = new Instance($instance);
        $this->container->add($this);

        return $this;
    }